Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Ricardo Ribalda and committed by
Julia Lawall
e4655196 96fca68c

+16 -16
+16 -16
scripts/coccinelle/misc/minmax.cocci
··· 50 50 ...> 51 51 } 52 52 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 + 53 68 @rmin depends on !patch@ 54 69 identifier func; 55 70 expression x, y; 56 71 binary operator cmp = {<, <=}; 57 - position p; 72 + position p != errcode.p; 58 73 @@ 59 74 60 75 func(...) ··· 128 113 - max_val = y; 129 114 - } 130 115 + max_val = max(x, y); 131 - ...> 132 - } 133 - 134 - // Don't generate patches for errcode returns. 135 - @errcode depends on patch@ 136 - position p; 137 - identifier func; 138 - expression x; 139 - binary operator cmp = {<, <=}; 140 - @@ 141 - 142 - func(...) 143 - { 144 - <... 145 - return ((x) cmp@p 0 ? (x) : 0); 146 116 ...> 147 117 } 148 118