Skip to content

Commit 5b7ca45

Browse files
Hongbo LiJuliaLawall
authored andcommitted
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>
1 parent d4c7544 commit 5b7ca45

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

scripts/coccinelle/api/string_choices.cocci

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,41 @@ e << str_high_low_r.E;
165165
@@
166166
167167
coccilib.report.print_report(p[0], "opportunity for str_high_low(%s)" % e)
168+
169+
@str_lo_hi depends on patch@
170+
expression E;
171+
@@
172+
- ((E) ? "lo" : "hi")
173+
+ str_lo_hi(E)
174+
175+
@str_lo_hi_r depends on !patch exists@
176+
expression E;
177+
position P;
178+
@@
179+
* ((E@P) ? "lo" : "hi")
180+
181+
@script:python depends on report@
182+
p << str_lo_hi_r.P;
183+
e << str_lo_hi_r.E;
184+
@@
185+
186+
coccilib.report.print_report(p[0], "opportunity for str_lo_hi(%s)" % e)
187+
188+
@str_low_high depends on patch@
189+
expression E;
190+
@@
191+
- ((E) ? "low" : "high")
192+
+ str_low_high(E)
193+
194+
@str_low_high_r depends on !patch exists@
195+
expression E;
196+
position P;
197+
@@
198+
* ((E@P) ? "low" : "high")
199+
200+
@script:python depends on report@
201+
p << str_low_high_r.P;
202+
e << str_low_high_r.E;
203+
@@
204+
205+
coccilib.report.print_report(p[0], "opportunity for str_low_high(%s)" % e)

0 commit comments

Comments
 (0)