git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] coccinelle: merge two rules from free.cocci
@ 2019-11-12 14:15 Markus Elfring
  0 siblings, 0 replies; only message in thread
From: Markus Elfring @ 2019-11-12 14:15 UTC (permalink / raw)
  To: git; +Cc: René Scharfe

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 12 Nov 2019 15:00:29 +0100

This script contained two transformation rules for the semantic patch language
where a condition check should be removed before free() calls.
It should not matter if a corresponding expression begins with a not operator
(or not). Thus combine these rules by using a SmPL disjunction.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 contrib/coccinelle/free.cocci | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/contrib/coccinelle/free.cocci b/contrib/coccinelle/free.cocci
index 4490069df9..63e442d3ef 100644
--- a/contrib/coccinelle/free.cocci
+++ b/contrib/coccinelle/free.cocci
@@ -1,13 +1,7 @@
 @@
 expression E;
 @@
-- if (E)
-  free(E);
-
-@@
-expression E;
-@@
-- if (!E)
+- if ( \( E \| !E \) )
   free(E);

 @@
--
2.24.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2019-11-12 14:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-12 14:15 [PATCH] coccinelle: merge two rules from free.cocci Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).