Skip to content

Commit 0336f89

Browse files
committed
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Kees Cook <[email protected]>
1 parent f5c1ca3 commit 0336f89

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

scripts/coccinelle/api/string_choices.cocci

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,26 @@ e << str_up_down_r.E;
6262
@@
6363
6464
coccilib.report.print_report(p[0], "opportunity for str_up_down(%s)" % e)
65+
66+
@str_down_up depends on patch@
67+
expression E;
68+
@@
69+
(
70+
- ((E) ? "down" : "up")
71+
+ str_down_up(E)
72+
)
73+
74+
@str_down_up_r depends on !patch exists@
75+
expression E;
76+
position P;
77+
@@
78+
(
79+
* ((E@P) ? "down" : "up")
80+
)
81+
82+
@script:python depends on report@
83+
p << str_down_up_r.P;
84+
e << str_down_up_r.E;
85+
@@
86+
87+
coccilib.report.print_report(p[0], "opportunity for str_down_up(%s)" % e)

0 commit comments

Comments
 (0)