From 9b80a6ca8f7e551c812f6b50f2dd67b6b0505f0f Mon Sep 17 00:00:00 2001 From: Tim Duesterhus Date: Mon, 8 Nov 2021 09:05:00 +0100 Subject: [PATCH] DEV: coccinelle: Add rule to use `isttrim()` where possible This replaces `if (i.len > e) i.len = e;` by `isttrim(i, e)`. --- dev/coccinelle/ist.cocci | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dev/coccinelle/ist.cocci b/dev/coccinelle/ist.cocci index 5b6aa6b2c..7e9a6ac05 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; @@