Skip to content

Commit c81ca02

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

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
@@ -260,3 +260,22 @@ e << str_read_write_r.E;
260260
@@
261261
262262
coccilib.report.print_report(p[0], "opportunity for str_read_write(%s)" % e)
263+
264+
@str_write_read depends on patch@
265+
expression E;
266+
@@
267+
- ((E) ? "write" : "read")
268+
+ str_write_read(E)
269+
270+
@str_write_read_r depends on !patch exists@
271+
expression E;
272+
position P;
273+
@@
274+
* ((E@P) ? "write" : "read")
275+
276+
@script:python depends on report@
277+
p << str_write_read_r.P;
278+
e << str_write_read_r.E;
279+
@@
280+
281+
coccilib.report.print_report(p[0], "opportunity for str_write_read(%s)" % e)

0 commit comments

Comments
 (0)