]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
DEV: coccinelle: Add rule to use `isttrim()` where possible
authorTim Duesterhus <tim@bastelstu.be>
Mon, 8 Nov 2021 08:05:00 +0000 (09:05 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 8 Nov 2021 11:08:26 +0000 (12:08 +0100)
This replaces `if (i.len > e) i.len = e;` by `isttrim(i, e)`.

dev/coccinelle/ist.cocci

index 5b6aa6b2cf8e98e7a7552ea2c53befc2de266995..7e9a6ac0568136bea573428b5a24f08a413c0cf4 100644 (file)
@@ -44,6 +44,14 @@ struct ist i;
 - (\(i.ptr\|istptr(i)\) + \(i.len\|istlen(i)\))
 + istend(i)
 
+@@
+struct ist i;
+expression e;
+@@
+
+- if (\(i.len\|istlen(i)\) > e) { i.len = e; }
++ i = isttrim(i, e);
+
 @@
 struct ist i;
 @@