summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorDenis Efremov <efremov@linux.com>2021-04-28 08:03:50 +0200
committerJulia Lawall <Julia.Lawall@inria.fr>2021-05-01 21:27:10 +0200
commitaeb300c1dbfc77b493728f608dd14d6814676546 (patch)
tree1b4bddc69fd4193e1e262b5fdf96b14a164bd5ed /scripts
parentdrop unneeded *s (diff)
downloadlinux-aeb300c1dbfc77b493728f608dd14d6814676546.tar.xz
linux-aeb300c1dbfc77b493728f608dd14d6814676546.zip
coccinelle: misc: minmax: suppress patch generation for err returns
There is a standard idiom for "if 'ret' holds an error, return it": return ret < 0 ? ret : 0; Developers prefer to keep the things as they are because stylistic change to "return min(ret, 0);" breaks readability. Let's suppress automatic generation for this type of patches. Signed-off-by: Denis Efremov <efremov@linux.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/coccinelle/misc/minmax.cocci18
1 files changed, 17 insertions, 1 deletions
diff --git a/scripts/coccinelle/misc/minmax.cocci b/scripts/coccinelle/misc/minmax.cocci
index eccdd3eb3452..fcf908b34f27 100644
--- a/scripts/coccinelle/misc/minmax.cocci
+++ b/scripts/coccinelle/misc/minmax.cocci
@@ -116,16 +116,32 @@ func(...)
...>
}
+// Don't generate patches for errcode returns.
+@errcode depends on patch@
+position p;
+identifier func;
+expression x;
+binary operator cmp = {<, <=};
+@@
+
+func(...)
+{
+ <...
+ return ((x) cmp@p 0 ? (x) : 0);
+ ...>
+}
+
@pmin depends on patch@
identifier func;
expression x, y;
binary operator cmp = {<=, <};
+position p != errcode.p;
@@
func(...)
{
<...
-- ((x) cmp (y) ? (x) : (y))
+- ((x) cmp@p (y) ? (x) : (y))
+ min(x, y)
...>
}