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

Unified · Split

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