]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
coccinelle: Add rules to find str_yes_no() replacements
authorHongbo Li <lihongbo22@huawei.com>
Wed, 11 Sep 2024 01:09:26 +0000 (09:09 +0800)
committerJulia Lawall <Julia.Lawall@inria.fr>
Sat, 28 Sep 2024 19:23:21 +0000 (21:23 +0200)
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>
scripts/coccinelle/api/string_choices.cocci

index 34ff8f48965ceb1d7676a6ab5eeb82fae1da6c79..96dc7090395d7e7ac21e71e73c12feb08ecabb00 100644 (file)
@@ -298,3 +298,22 @@ e << str_on_off_r.E;
 @@
 
 coccilib.report.print_report(p[0], "opportunity for str_on_off(%s)" % e)
+
+@str_yes_no depends on patch@
+expression E;
+@@
+-      ((E) ? "yes" : "no")
++      str_yes_no(E)
+
+@str_yes_no_r depends on !patch exists@
+expression E;
+position P;
+@@
+*      ((E@P) ? "yes" : "no")
+
+@script:python depends on report@
+p << str_yes_no_r.P;
+e << str_yes_no_r.E;
+@@
+
+coccilib.report.print_report(p[0], "opportunity for str_yes_no(%s)" % e)