[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241027125858.1804-2-thorsten.blum@linux.dev>
Date: Sun, 27 Oct 2024 13:58:59 +0100
From: Thorsten Blum <thorsten.blum@...ux.dev>
To: Kees Cook <kees@...nel.org>,
Andy Shevchenko <andy@...nel.org>,
Julia Lawall <Julia.Lawall@...ia.fr>,
Nicolas Palix <nicolas.palix@...g.fr>
Cc: Thorsten Blum <thorsten.blum@...ux.dev>,
linux-hardening@...r.kernel.org,
cocci@...ia.fr,
linux-kernel@...r.kernel.org
Subject: [PATCH] coccinelle: Add str_off_on() and str_no_yes() rules
In addition to str_on_off() and str_yes_no(), add rules to search for
str_off_on() and str_no_yes() replacements.
Signed-off-by: Thorsten Blum <thorsten.blum@...ux.dev>
---
scripts/coccinelle/api/string_choices.cocci | 38 +++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/scripts/coccinelle/api/string_choices.cocci b/scripts/coccinelle/api/string_choices.cocci
index 375045086912..93de05aeded2 100644
--- a/scripts/coccinelle/api/string_choices.cocci
+++ b/scripts/coccinelle/api/string_choices.cocci
@@ -282,6 +282,25 @@ e << str_on_off_r.E;
coccilib.report.print_report(p[0], "opportunity for str_on_off(%s)" % e)
+@..._off_on depends on patch@
+expression E;
+@@
+- ((E) ? "off" : "on")
++ str_off_on(E)
+
+@..._off_on_r depends on !patch@
+expression E;
+position P;
+@@
+* E@P ? "off" : "on"
+
+@...ipt:python depends on report@
+p << str_off_on_r.P;
+e << str_off_on_r.E;
+@@
+
+coccilib.report.print_report(p[0], "opportunity for str_off_on(%s)" % e)
+
@str_yes_no depends on patch@
expression E;
@@
@@ -300,3 +319,22 @@ e << str_yes_no_r.E;
@@
coccilib.report.print_report(p[0], "opportunity for str_yes_no(%s)" % e)
+
+@..._no_yes depends on patch@
+expression E;
+@@
+- ((E) ? "no" : "yes")
++ str_no_yes(E)
+
+@..._no_yes_r depends on !patch@
+expression E;
+position P;
+@@
+* E@P ? "no" : "yes"
+
+@...ipt:python depends on report@
+p << str_no_yes_r.P;
+e << str_no_yes_r.E;
+@@
+
+coccilib.report.print_report(p[0], "opportunity for str_no_yes(%s)" % e)
--
2.47.0
Powered by blists - more mailing lists