[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240904091451.3328272-6-lihongbo22@huawei.com>
Date: Wed, 4 Sep 2024 17:14:47 +0800
From: Hongbo Li <lihongbo22@...wei.com>
To: <kees@...nel.org>, <andy@...nel.org>, <Julia.Lawall@...ia.fr>,
<nicolas.palix@...g.fr>
CC: <linux-hardening@...r.kernel.org>, <cocci@...ia.fr>,
<lihongbo22@...wei.com>
Subject: [PATCH -next v2 5/9] coccinelle: Add rules to find str_enable{d}_disable{d}() replacements
As other rules done, we add rules for str_enable{d}_
disable{d}() to check the relative opportunities.
Signed-off-by: Hongbo Li <lihongbo22@...wei.com>
---
scripts/coccinelle/api/string_choices.cocci | 46 +++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/scripts/coccinelle/api/string_choices.cocci b/scripts/coccinelle/api/string_choices.cocci
index 53fd34a0fcb4..7400eafdf040 100644
--- a/scripts/coccinelle/api/string_choices.cocci
+++ b/scripts/coccinelle/api/string_choices.cocci
@@ -223,3 +223,49 @@ e << str_low_high_r.E;
@@
coccilib.report.print_report(p[0], "opportunity for str_low_high(%s)" % e)
+
+@..._enable_disable depends on patch@
+expression E;
+@@
+(
+- ((E) ? "enable" : "disable")
++ str_enable_disable(E)
+)
+
+@..._enable_disable_r depends on !patch exists@
+expression E;
+position P;
+@@
+(
+* ((E@P) ? "enable" : "disable")
+)
+
+@...ipt:python depends on report@
+p << str_enable_disable_r.P;
+e << str_enable_disable_r.E;
+@@
+
+coccilib.report.print_report(p[0], "opportunity for str_enable_disable(%s)" % e)
+
+@..._enabled_disabled depends on patch@
+expression E;
+@@
+(
+- ((E) ? "enabled" : "disabled")
++ str_enabled_disabled(E)
+)
+
+@..._enabled_disabled_r depends on !patch exists@
+expression E;
+position P;
+@@
+(
+* ((E@P) ? "enabled" : "disabled")
+)
+
+@...ipt:python depends on report@
+p << str_enabled_disabled_r.P;
+e << str_enabled_disabled_r.E;
+@@
+
+coccilib.report.print_report(p[0], "opportunity for str_enabled_disabled(%s)" % e)
--
2.34.1
Powered by blists - more mailing lists