Skip to content

Commit

Permalink
coccinelle: Add rules to find str_write_read() replacements
Browse files Browse the repository at this point in the history
As other rules done, we add rules for str_write_read()
to check the relative opportunities.

Signed-off-by: Hongbo Li <[email protected]>
Signed-off-by: Julia Lawall <[email protected]>
  • Loading branch information
Hongbo Li authored and JuliaLawall committed Sep 28, 2024
1 parent ba4b514 commit c81ca02
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions scripts/coccinelle/api/string_choices.cocci
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,22 @@ e << str_read_write_r.E;
@@
coccilib.report.print_report(p[0], "opportunity for str_read_write(%s)" % e)
@str_write_read depends on patch@
expression E;
@@
- ((E) ? "write" : "read")
+ str_write_read(E)

@str_write_read_r depends on !patch exists@
expression E;
position P;
@@
* ((E@P) ? "write" : "read")

@script:python depends on report@
p << str_write_read_r.P;
e << str_write_read_r.E;
@@
coccilib.report.print_report(p[0], "opportunity for str_write_read(%s)" % e)

0 comments on commit c81ca02

Please sign in to comment.