[PATCH] Coccinelle: atomic_as_refcounter: Merge two SmPL rules
From: SF Markus Elfring
Date: Wed Aug 01 2018 - 08:30:46 EST
From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 1 Aug 2018 14:16:01 +0200
Two rules of a script for the semantic patch language displayed
the same message.
Thus reduce duplicate SmPL code so that the desired data processing
is achieved by another nested SmPL disjunction in a single SmPL rule.
Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
---
.../coccinelle/api/atomic_as_refcounter.cocci | 50 ++++---------------
1 file changed, 10 insertions(+), 40 deletions(-)
diff --git a/scripts/coccinelle/api/atomic_as_refcounter.cocci b/scripts/coccinelle/api/atomic_as_refcounter.cocci
index 1e2278ff3261..292a029d5a51 100644
--- a/scripts/coccinelle/api/atomic_as_refcounter.cocci
+++ b/scripts/coccinelle/api/atomic_as_refcounter.cocci
@@ -11,12 +11,11 @@ virtual report
@r1 exists@
expression a;
-identifier x;
position p1, p2;
-identifier fname =~ "free";
-identifier fname2 =~ "(?:call_rcu|de(?:l|stroy)|(?:queue|schedule)_work)";
+identifier x, y,
+ fname =~ "free",
+ fname2 =~ "(?:call_rcu|de(?:l|stroy)|(?:queue|schedule)_work)";
@@
-
(
(atomic_dec_and_test@p1
|atomic_long_dec_and_test@p1
@@ -28,14 +27,17 @@ identifier fname2 =~ "(?:call_rcu|de(?:l|stroy)|(?:queue|schedule)_work)";
|atomic_long_dec_and_lock@p1
) (&(a)->x, ...)
)
-...
+ ...
(
- fname@p2(a, ...);
+(fname@p2(a, ...)
+|fname2@p2(...)
+);
|
- fname2@p2(...);
+ y = a
+ ...
+ fname@p2(y, ...);
)
-
@script:python depends on report@
p1 << r1.p1;
p2 << r1.p2;
@@ -44,38 +46,6 @@ coccilib.report.print_report(p1[0],
"atomic_dec_and_test variation before object free at line %s."
% (p2[0].line))
-@r4 exists@
-expression a;
-identifier x, y;
-position p1, p2;
-identifier fname =~ "free";
-@@
-
-(
-(atomic_dec_and_test@p1
-|atomic_long_dec_and_test@p1
-|atomic64_dec_and_test@p1
-|local_dec_and_test@p1
-) (&(a)->x)
-|
-(atomic_dec_and_lock@p1
-|atomic_long_dec_and_lock@p1
-) (&(a)->x, ...)
-)
-...
-y=a
-...
-fname@p2(y, ...);
-
-
-@script:python depends on report@
-p1 << r4.p1;
-p2 << r4.p2;
-@@
-coccilib.report.print_report(p1[0],
- "atomic_dec_and_test variation before object free at line %s."
- % (p2[0].line))
-
@r2 exists@
expression a;
identifier F =~ "^atomic(?:64|_long)?_add_unless$", x;
--
2.18.0