mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-24 12:44:11 +08:00
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>
This commit is contained in:
parent
32c4656139
commit
aeb300c1db
@ -116,16 +116,32 @@ func(...)
|
||||
...>
|
||||
}
|
||||
|
||||
@pmin depends on patch@
|
||||
// Don't generate patches for errcode returns.
|
||||
@errcode depends on patch@
|
||||
position p;
|
||||
identifier func;
|
||||
expression x, y;
|
||||
binary operator cmp = {<=, <};
|
||||
expression x;
|
||||
binary operator cmp = {<, <=};
|
||||
@@
|
||||
|
||||
func(...)
|
||||
{
|
||||
<...
|
||||
- ((x) cmp (y) ? (x) : (y))
|
||||
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@p (y) ? (x) : (y))
|
||||
+ min(x, y)
|
||||
...>
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user