Skip to content

Commit 8a0236b

Browse files
Hongbo LiJuliaLawall
authored andcommitted
coccinelle: Add rules to find str_false_true() replacements
As done with str_true_false(), add checks for str_false_true() opportunities. A simple test can find over 9 cases currently exist in the tree. Signed-off-by: Hongbo Li <lihongbo22@huawei.com> Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
1 parent 716bf84 commit 8a0236b

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
@@ -104,3 +104,22 @@ e << str_true_false_r.E;
104104
@@
105105
106106
coccilib.report.print_report(p[0], "opportunity for str_true_false(%s)" % e)
107+
108+
@str_false_true depends on patch@
109+
expression E;
110+
@@
111+
- ((E) ? "false" : "true")
112+
+ str_false_true(E)
113+
114+
@str_false_true_r depends on !patch exists@
115+
expression E;
116+
position P;
117+
@@
118+
* ((E@P) ? "false" : "true")
119+
120+
@script:python depends on report@
121+
p << str_false_true_r.P;
122+
e << str_false_true_r.E;
123+
@@
124+
125+
coccilib.report.print_report(p[0], "opportunity for str_false_true(%s)" % e)

0 commit comments

Comments
 (0)