diff options
author | Kees Cook <kees@kernel.org> | 2024-08-12 11:36:38 -0700 |
---|---|---|
committer | Kees Cook <kees@kernel.org> | 2024-08-15 09:26:02 -0700 |
commit | 0336f898881ae13b92dfd8b72e69ed1246eac762 (patch) | |
tree | 3fab5a84f91d0856df216631a6fb8c89268ea26a /scripts | |
parent | f5c1ca3a15fdb867d2b535003f74e0b975eff116 (diff) |
coccinelle: Add rules to find str_down_up() replacements
As done with str_up_down(), add checks for str_down_up() opportunities.
5 cases currently exist in the tree.
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20240812183637.work.999-kees@kernel.org
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Signed-off-by: Kees Cook <kees@kernel.org>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/coccinelle/api/string_choices.cocci | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/scripts/coccinelle/api/string_choices.cocci b/scripts/coccinelle/api/string_choices.cocci index d517f6bc850b..5e729f187f22 100644 --- a/scripts/coccinelle/api/string_choices.cocci +++ b/scripts/coccinelle/api/string_choices.cocci @@ -62,3 +62,26 @@ e << str_up_down_r.E; @@ coccilib.report.print_report(p[0], "opportunity for str_up_down(%s)" % e) + +@str_down_up depends on patch@ +expression E; +@@ +( +- ((E) ? "down" : "up") ++ str_down_up(E) +) + +@str_down_up_r depends on !patch exists@ +expression E; +position P; +@@ +( +* ((E@P) ? "down" : "up") +) + +@script:python depends on report@ +p << str_down_up_r.P; +e << str_down_up_r.E; +@@ + +coccilib.report.print_report(p[0], "opportunity for str_down_up(%s)" % e) |