Skip to content

Commit 9b5b481

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

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
@@ -279,3 +279,22 @@ e << str_write_read_r.E;
279279
@@
280280
281281
coccilib.report.print_report(p[0], "opportunity for str_write_read(%s)" % e)
282+
283+
@str_on_off depends on patch@
284+
expression E;
285+
@@
286+
- ((E) ? "on" : "off")
287+
+ str_on_off(E)
288+
289+
@str_on_off_r depends on !patch exists@
290+
expression E;
291+
position P;
292+
@@
293+
* ((E@P) ? "on" : "off")
294+
295+
@script:python depends on report@
296+
p << str_on_off_r.P;
297+
e << str_on_off_r.E;
298+
@@
299+
300+
coccilib.report.print_report(p[0], "opportunity for str_on_off(%s)" % e)

0 commit comments

Comments
 (0)