coccinelle: misc: minmax: suppress patch generation for err returns
[linux-2.6-microblaze.git] / scripts / coccinelle / misc / minmax.cocci
index eccdd3e..fcf908b 100644 (file)
@@ -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)
        ...>
 }