From: Tim Duesterhus Date: Mon, 8 Nov 2021 08:05:00 +0000 (+0100) Subject: DEV: coccinelle: Add rule to use `isttrim()` where possible X-Git-Tag: v2.5-dev14~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b80a6ca8f7e551c812f6b50f2dd67b6b0505f0f;p=thirdparty%2Fhaproxy.git DEV: coccinelle: Add rule to use `isttrim()` where possible This replaces `if (i.len > e) i.len = e;` by `isttrim(i, e)`. --- diff --git a/dev/coccinelle/ist.cocci b/dev/coccinelle/ist.cocci index 5b6aa6b2cf..7e9a6ac056 100644 --- a/dev/coccinelle/ist.cocci +++ b/dev/coccinelle/ist.cocci @@ -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; @@