History

coccinelle: Add rules to find str_hi{gh}_lo{w}() replacements

As other rules done, we add rules for str_hi{gh}_lo{w}() to check the relative opportunities.

Hongbo Li committed 2 years ago

Commit d4c75441 parent 8a0236b1 file · +42 −0Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/coccinelle/api/string_choices.cocci+42−0
@@ -123,3 +123,45 @@ e << str_false_true_r.E; · 122 unmodified lines
123123 @@
124124
125125 coccilib.report.print_report(p[0], "opportunity for str_false_true(%s)" % e)
126+
127+@str_hi_lo depends on patch@
128+expression E;
129+@@
130+(
131+- ((E) ? "hi" : "lo")
132++ str_hi_lo(E)
133+)
134+
135+@str_hi_lo_r depends on !patch exists@
136+expression E;
137+position P;
138+@@
139+(
140+* ((E@P) ? "hi" : "lo")
141+)
142+
143+@script:python depends on report@
144+p << str_hi_lo_r.P;
145+e << str_hi_lo_r.E;
146+@@
147+
148+coccilib.report.print_report(p[0], "opportunity for str_hi_lo(%s)" % e)
149+
150+@str_high_low depends on patch@
151+expression E;
152+@@
153+- ((E) ? "high" : "low")
154++ str_high_low(E)
155+
156+@str_high_low_r depends on !patch exists@
157+expression E;
158+position P;
159+@@
160+* ((E@P) ? "high" : "low")
161+
162+@script:python depends on report@
163+p << str_high_low_r.P;
164+e << str_high_low_r.E;
165+@@
166+
167+coccilib.report.print_report(p[0], "opportunity for str_high_low(%s)" % e)