Commit aeb300c1 authored by Denis Efremov's avatar Denis Efremov Committed by Julia Lawall

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: default avatarDenis Efremov <efremov@linux.com>
parent 32c46561
...@@ -116,16 +116,32 @@ func(...) ...@@ -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@ @pmin depends on patch@
identifier func; identifier func;
expression x, y; expression x, y;
binary operator cmp = {<=, <}; binary operator cmp = {<=, <};
position p != errcode.p;
@@ @@
func(...) func(...)
{ {
<... <...
- ((x) cmp (y) ? (x) : (y)) - ((x) cmp@p (y) ? (x) : (y))
+ min(x, y) + min(x, y)
...> ...>
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment