Skip to contentSkip to conversation

coccinelle: Add rules to find str_down_up() replacements

PATCH In review Kees Cook 2 participants 2 messages Aug 12, 2024

Subsystems (2)
lore
Share & tools
lore

Kees Cook

author maintainer
#0 lore raw

PATCH 1/1 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.

---
Cc: Andy Shevchenko <[email protected]>
Cc: Michal Wajdeczko <[email protected]>
Cc: Julia Lawall <[email protected]>
Cc: Nicolas Palix <[email protected]>
Cc: [email protected]
Cc: [email protected]

---
 scripts/coccinelle/api/string_choices.cocci | 23 +++++++++++++++++++++
 1 file changed, 23 insertions(+)
scripts/coccinelle/api/string_choices.cocci +23 -0
index d517f6bc850b..5e729f187f22 100644
@@ -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)
Signature · 1 line
2.34.1
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 2 lines · Kees Cook

As done with str_up_down(), add checks for str_down_up() opportunities. 5 cases currently exist in the tree.

Signature · 2 lines
With Best Regards,
Andy Shevchenko