summaryrefslogtreecommitdiff
path: root/scripts/coccinelle
diff options
context:
space:
mode:
authorHongbo Li <lihongbo22@huawei.com>2024-09-11 09:09:21 +0800
committerJulia Lawall <Julia.Lawall@inria.fr>2024-09-28 21:22:38 +0200
commit5b7ca4507d64de729011c145d8ee9a2731f9502f (patch)
tree32b8212df4ab02db23dce620f6239d4218f1e9a8 /scripts/coccinelle
parentd4c7544002db32dedbb162b2b89e655ac437ab08 (diff)
coccinelle: Add rules to find str_lo{w}_hi{gh}() replacements
As other rules done, we add rules for str_lo{w}_hi{gh}() to check the relative opportunities. 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.cocci38
1 files changed, 38 insertions, 0 deletions
diff --git a/scripts/coccinelle/api/string_choices.cocci b/scripts/coccinelle/api/string_choices.cocci
index 7c631fd8abe2..e91d4eb30161 100644
--- a/scripts/coccinelle/api/string_choices.cocci
+++ b/scripts/coccinelle/api/string_choices.cocci
@@ -165,3 +165,41 @@ e << str_high_low_r.E;
@@
coccilib.report.print_report(p[0], "opportunity for str_high_low(%s)" % e)
+
+@str_lo_hi depends on patch@
+expression E;
+@@
+- ((E) ? "lo" : "hi")
++ str_lo_hi(E)
+
+@str_lo_hi_r depends on !patch exists@
+expression E;
+position P;
+@@
+* ((E@P) ? "lo" : "hi")
+
+@script:python depends on report@
+p << str_lo_hi_r.P;
+e << str_lo_hi_r.E;
+@@
+
+coccilib.report.print_report(p[0], "opportunity for str_lo_hi(%s)" % e)
+
+@str_low_high depends on patch@
+expression E;
+@@
+- ((E) ? "low" : "high")
++ str_low_high(E)
+
+@str_low_high_r depends on !patch exists@
+expression E;
+position P;
+@@
+* ((E@P) ? "low" : "high")
+
+@script:python depends on report@
+p << str_low_high_r.P;
+e << str_low_high_r.E;
+@@
+
+coccilib.report.print_report(p[0], "opportunity for str_low_high(%s)" % e)