diff options
author | Hongbo Li <lihongbo22@huawei.com> | 2024-09-11 09:09:24 +0800 |
---|---|---|
committer | Julia Lawall <Julia.Lawall@inria.fr> | 2024-09-28 21:23:05 +0200 |
commit | c81ca023c30691dcae543bd770e7a3a4c63263ff (patch) | |
tree | 47fd192757ce756632d0a317bb2488551c62aee3 /scripts | |
parent | ba4b514a6f4ac420d872b8f16245e3ffa05c10a5 (diff) |
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>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/coccinelle/api/string_choices.cocci | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/scripts/coccinelle/api/string_choices.cocci b/scripts/coccinelle/api/string_choices.cocci index 29c507d86ffd..64f04da2e9f4 100644 --- a/scripts/coccinelle/api/string_choices.cocci +++ b/scripts/coccinelle/api/string_choices.cocci @@ -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) |