Skip to content

Commit 253244c

Browse files
Hongbo LiJuliaLawall
authored andcommitted
coccinelle: Add rules to find str_yes_no() replacements
As other rules done, we add rules for str_yes_no() to check the relative opportunities. Signed-off-by: Hongbo Li <lihongbo22@huawei.com> Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
1 parent 9b5b481 commit 253244c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

scripts/coccinelle/api/string_choices.cocci

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,3 +298,22 @@ e << str_on_off_r.E;
298298
@@
299299
300300
coccilib.report.print_report(p[0], "opportunity for str_on_off(%s)" % e)
301+
302+
@str_yes_no depends on patch@
303+
expression E;
304+
@@
305+
- ((E) ? "yes" : "no")
306+
+ str_yes_no(E)
307+
308+
@str_yes_no_r depends on !patch exists@
309+
expression E;
310+
position P;
311+
@@
312+
* ((E@P) ? "yes" : "no")
313+
314+
@script:python depends on report@
315+
p << str_yes_no_r.P;
316+
e << str_yes_no_r.E;
317+
@@
318+
319+
coccilib.report.print_report(p[0], "opportunity for str_yes_no(%s)" % e)

0 commit comments

Comments
 (0)