Skip to content

Commit e465519

Browse files
ribaldaJuliaLawall
authored andcommitted
coccinelle: misc: minmax: Suppress reports for err returns
Most of the people prefer: return ret < 0 ? ret: 0; than: return min(ret, 0); Let's tweak the cocci file to ignore those lines completely. Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
1 parent 96fca68 commit e465519

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

scripts/coccinelle/misc/minmax.cocci

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,26 @@ func(...)
5050
...>
5151
}
5252

53+
// Ignore errcode returns.
54+
@errcode@
55+
position p;
56+
identifier func;
57+
expression x;
58+
binary operator cmp = {<, <=};
59+
@@
60+
61+
func(...)
62+
{
63+
<...
64+
return ((x) cmp@p 0 ? (x) : 0);
65+
...>
66+
}
67+
5368
@rmin depends on !patch@
5469
identifier func;
5570
expression x, y;
5671
binary operator cmp = {<, <=};
57-
position p;
72+
position p != errcode.p;
5873
@@
5974

6075
func(...)
@@ -116,21 +131,6 @@ func(...)
116131
...>
117132
}
118133

119-
// Don't generate patches for errcode returns.
120-
@errcode depends on patch@
121-
position p;
122-
identifier func;
123-
expression x;
124-
binary operator cmp = {<, <=};
125-
@@
126-
127-
func(...)
128-
{
129-
<...
130-
return ((x) cmp@p 0 ? (x) : 0);
131-
...>
132-
}
133-
134134
@pmin depends on patch@
135135
identifier func;
136136
expression x, y;

0 commit comments

Comments
 (0)