mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 12:44:03 +02:00
coccinelle: misc: minmax: check for the presence of if cases
As done previously for the ternary command, check that a file contains the min or max if pattern before applying the minif and maxif rules. Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
This commit is contained in:
parent
fd0a63f086
commit
af8613c863
|
|
@ -45,7 +45,19 @@ func(...)
|
|||
...>
|
||||
}
|
||||
|
||||
@rmaxif depends on !patch@
|
||||
@maxif_candidate@
|
||||
expression x, y;
|
||||
expression max_val;
|
||||
binary operator cmp = {>, >=};
|
||||
@@
|
||||
|
||||
if ((x) cmp (y)) {
|
||||
max_val = (x);
|
||||
} else {
|
||||
max_val = (y);
|
||||
}
|
||||
|
||||
@rmaxif depends on !patch && maxif_candidate@
|
||||
identifier func;
|
||||
expression x, y;
|
||||
expression max_val;
|
||||
|
|
@ -93,7 +105,19 @@ func(...)
|
|||
...>
|
||||
}
|
||||
|
||||
@rminif depends on !patch@
|
||||
@minif_candidate@
|
||||
expression x, y;
|
||||
expression min_val;
|
||||
binary operator cmp = {<, <=};
|
||||
@@
|
||||
|
||||
if ((x) cmp (y)) {
|
||||
min_val = (x);
|
||||
} else {
|
||||
min_val = (y);
|
||||
}
|
||||
|
||||
@rminif depends on !patch && minif_candidate@
|
||||
identifier func;
|
||||
expression x, y;
|
||||
expression min_val;
|
||||
|
|
@ -126,7 +150,7 @@ func(...)
|
|||
...>
|
||||
}
|
||||
|
||||
@pmaxif depends on patch@
|
||||
@pmaxif depends on patch && maxif_candidate@
|
||||
identifier func;
|
||||
expression x, y;
|
||||
expression max_val;
|
||||
|
|
@ -160,7 +184,7 @@ func(...)
|
|||
...>
|
||||
}
|
||||
|
||||
@pminif depends on patch@
|
||||
@pminif depends on patch && maxif_candidate@
|
||||
identifier func;
|
||||
expression x, y;
|
||||
expression min_val;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user