[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <94b3299b-becf-1026-e855-2c4826cd33ab@users.sourceforge.net>
Date: Mon, 16 Jul 2018 19:32:38 +0200
From: SF Markus Elfring <elfring@...rs.sourceforge.net>
To: kernel-janitors@...r.kernel.org,
Elena Reshetova <elena.reshetova@...el.com>,
Julia Lawall <julia.lawall@...6.fr>,
Kees Cook <keescook@...omium.org>,
Masahiro Yamada <yamada.masahiro@...ionext.com>
Cc: LKML <linux-kernel@...r.kernel.org>,
Coccinelle <cocci@...teme.lip6.fr>,
Gilles Muller <Gilles.Muller@...6.fr>,
Michal Marek <michal.lkml@...kovi.net>,
Nicolas Palix <nicolas.palix@...g.fr>
Subject: [PATCH v2 5/8] Coccinelle: atomic_as_refcounter: Replace disjunction
by a constraint in two SmPL rules
From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Mon, 16 Jul 2018 18:12:10 +0200
Three function names were specified for a search of function calls
by the means of a disjunction in two rules of a script for
the semantic patch language.
Use a regular expression as a constraint for this source code search
pattern instead so that duplication of SmPL code can be avoided.
Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
.../coccinelle/api/atomic_as_refcounter.cocci | 23 ++++---------------
1 file changed, 5 insertions(+), 18 deletions(-)
diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index 62b0132d65fc..4484bea6c9d8 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -47,17 +47,10 @@ coccilib.report.print_report(p1[0], msg % (p2[0].line))
@r2 exists@
expression a;
-identifier x;
+identifier F =~ "^atomic(?:64|_long)?_add_unless$", x;
position p1;
@@
-
-(
-atomic_add_unless(&(a)->x,-1,1)@p1
-|
-atomic_long_add_unless(&(a)->x,-1,1)@p1
-|
-atomic64_add_unless(&(a)->x,-1,1)@p1
-)
+ F(&(a)->x, -1, 1)@p1
@script:python depends on report@
p1 << r2.p1;
@@ -66,17 +59,11 @@ msg = "atomic_add_unless"
coccilib.report.print_report(p1[0], msg)
@r3 exists@
-identifier x;
+expression E;
+identifier F =~ "^atomic(?:64|_long)?_add_return$";
position p1;
@@
-
-(
-x = atomic_add_return@p1(-1, ...);
-|
-x = atomic_long_add_return@p1(-1, ...);
-|
-x = atomic64_add_return@p1(-1, ...);
-)
+ E = F@p1(-1, ...);
@script:python depends on report@
p1 << r3.p1;
--
2.18.0
Powered by blists - more mailing lists