git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: git@vger.kernel.org
Cc: "René Scharfe" <l.s.r@web.de>
Subject: [PATCH] coccinelle: merge two rules from free.cocci
Date: Tue, 12 Nov 2019 15:15:05 +0100	[thread overview]
Message-ID: <17c6e9d5-5a06-8150-fa82-e20e7b850fe4@web.de> (raw)

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


                 reply	other threads:[~2019-11-12 14:15 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=17c6e9d5-5a06-8150-fa82-e20e7b850fe4@web.de \
    --to=markus.elfring@web.de \
    --cc=git@vger.kernel.org \
    --cc=l.s.r@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).