projects
/
linux
/
.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
a98ae7f
)
coccinelle: Add rules to find str_up_down() replacements
author
Michal Wajdeczko
<michal.wajdeczko@intel.com>
Thu, 25 Jul 2024 10:18:41 +0000
(12:18 +0200)
committer
Kees Cook
<kees@kernel.org>
Thu, 15 Aug 2024 16:26:02 +0000
(09:26 -0700)
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>
scripts/coccinelle/api/string_choices.cocci
patch
|
blob
|
history
diff --git
a/scripts/coccinelle/api/string_choices.cocci
b/scripts/coccinelle/api/string_choices.cocci
index a71966c0494ef68c9e13268293da110d80e89ca0..d517f6bc850b4a2a92e1c542434080db11bc6dab 100644
(file)
--- 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)