Skip to content

Commit ba4b514

Browse files
Hongbo LiJuliaLawall
authored andcommitted
coccinelle: Add rules to find str_read_write() replacements
As other rules done, we add rules for str_read_write() to check the relative opportunities. Signed-off-by: Hongbo Li <lihongbo22@huawei.com> Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
1 parent dd2275d commit ba4b514

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

scripts/coccinelle/api/string_choices.cocci

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,3 +241,22 @@ e << str_enabled_disabled_r.E;
241241
@@
242242
243243
coccilib.report.print_report(p[0], "opportunity for str_enabled_disabled(%s)" % e)
244+
245+
@str_read_write depends on patch@
246+
expression E;
247+
@@
248+
- ((E) ? "read" : "write")
249+
+ str_read_write(E)
250+
251+
@str_read_write_r depends on !patch exists@
252+
expression E;
253+
position P;
254+
@@
255+
* ((E@P) ? "read" : "write")
256+
257+
@script:python depends on report@
258+
p << str_read_write_r.P;
259+
e << str_read_write_r.E;
260+
@@
261+
262+
coccilib.report.print_report(p[0], "opportunity for str_read_write(%s)" % e)

0 commit comments

Comments
 (0)