Skip to content

Commit 716bf84

Browse files
Hongbo LiJuliaLawall
authored andcommitted
coccinelle: Add rules to find str_true_false() replacements
After str_true_false() has been introduced in the tree, we can add rules for finding places where str_true_false() can be used. A simple test can find over 10 locations. Signed-off-by: Hongbo Li <lihongbo22@huawei.com> Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
1 parent 3efc573 commit 716bf84

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
@@ -85,3 +85,22 @@ e << str_down_up_r.E;
8585
@@
8686
8787
coccilib.report.print_report(p[0], "opportunity for str_down_up(%s)" % e)
88+
89+
@str_true_false depends on patch@
90+
expression E;
91+
@@
92+
- ((E) ? "true" : "false")
93+
+ str_true_false(E)
94+
95+
@str_true_false_r depends on !patch exists@
96+
expression E;
97+
position P;
98+
@@
99+
* ((E@P) ? "true" : "false")
100+
101+
@script:python depends on report@
102+
p << str_true_false_r.P;
103+
e << str_true_false_r.E;
104+
@@
105+
106+
coccilib.report.print_report(p[0], "opportunity for str_true_false(%s)" % e)

0 commit comments

Comments
 (0)