diff options
author | 2024-07-25 12:18:41 +0200 | |
---|---|---|
committer | 2024-08-15 09:26:02 -0700 | |
commit | 9b97452bcce77f8ef29b20c9662d95988b5990e4 (patch) | |
tree | d3269920e119649dff34fd2d41f263988e5b1b83 /scripts | |
parent | lib/string_choices: Add str_up_down() helper (diff) | |
download | wireguard-linux-9b97452bcce77f8ef29b20c9662d95988b5990e4.tar.xz wireguard-linux-9b97452bcce77f8ef29b20c9662d95988b5990e4.zip |
coccinelle: Add rules to find str_up_down() replacements
Add rules for finding places where str_up_down() can be used.
This currently finds over 20 locations.
Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Link: https://lore.kernel.org/r/20240725101841.574-2-michal.wajdeczko@intel.com
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 a71966c0494e..d517f6bc850b 100644 --- a/scripts/coccinelle/api/string_choices.cocci +++ b/scripts/coccinelle/api/string_choices.cocci @@ -39,3 +39,26 @@ e << str_plural_r.E; @@ coccilib.report.print_report(p[0], "opportunity for str_plural(%s)" % e) + +@str_up_down depends on patch@ +expression E; +@@ +( +- ((E) ? "up" : "down") ++ str_up_down(E) +) + +@str_up_down_r depends on !patch exists@ +expression E; +position P; +@@ +( +* ((E@P) ? "up" : "down") +) + +@script:python depends on report@ +p << str_up_down_r.P; +e << str_up_down_r.E; +@@ + +coccilib.report.print_report(p[0], "opportunity for str_up_down(%s)" % e) |