summaryrefslogtreecommitdiff
path: root/scripts/coccinelle
diff options
context:
space:
mode:
authorHongbo Li <lihongbo22@huawei.com>2024-09-11 09:09:18 +0800
committerJulia Lawall <Julia.Lawall@inria.fr>2024-09-28 21:21:04 +0200
commit716bf84ef39218a56fadaa413f70da008ad85888 (patch)
tree2a85effda59f8bd74a1a6402c782d7bfb8f63e15 /scripts/coccinelle
parent3efc57369a0ce8f76bf0804f7e673982384e4ac9 (diff)
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>
Diffstat (limited to 'scripts/coccinelle')
-rw-r--r--scripts/coccinelle/api/string_choices.cocci19
1 files changed, 19 insertions, 0 deletions
diff --git a/scripts/coccinelle/api/string_choices.cocci b/scripts/coccinelle/api/string_choices.cocci
index 5e729f187f22..6942ad7c4224 100644
--- a/scripts/coccinelle/api/string_choices.cocci
+++ b/scripts/coccinelle/api/string_choices.cocci
@@ -85,3 +85,22 @@ e << str_down_up_r.E;
@@
coccilib.report.print_report(p[0], "opportunity for str_down_up(%s)" % e)
+
+@str_true_false depends on patch@
+expression E;
+@@
+- ((E) ? "true" : "false")
++ str_true_false(E)
+
+@str_true_false_r depends on !patch exists@
+expression E;
+position P;
+@@
+* ((E@P) ? "true" : "false")
+
+@script:python depends on report@
+p << str_true_false_r.P;
+e << str_true_false_r.E;
+@@
+
+coccilib.report.print_report(p[0], "opportunity for str_true_false(%s)" % e)