git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / 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 three rules from qsort.cocci
Date: Tue, 12 Nov 2019 19:36:46 +0100	[thread overview]
Message-ID: <41723f0e-1c8b-5e5d-9d8c-b0df1482166d@web.de> (raw)

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 12 Nov 2019 19:30:28 +0100

This script contained three transformation rules for the semantic patch language
where a condition check should be removed before QSORT() calls.
Combine these rules by using a SmPL disjunction.

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

diff --git a/contrib/coccinelle/qsort.cocci b/contrib/coccinelle/qsort.cocci
index 22b93a9966..b2130a5e51 100644
--- a/contrib/coccinelle/qsort.cocci
+++ b/contrib/coccinelle/qsort.cocci
@@ -21,17 +21,5 @@ expression nmemb, compar;
 @@
 expression base, nmemb, compar;
 @@
-- if (nmemb)
-    QSORT(base, nmemb, compar);
-
-@@
-expression base, nmemb, compar;
-@@
-- if (nmemb > 0)
-    QSORT(base, nmemb, compar);
-
-@@
-expression base, nmemb, compar;
-@@
-- if (nmemb > 1)
+- if ( \( nmemb \| nmemb > \( 0 \| 1 \) \) )
     QSORT(base, nmemb, compar);
--
2.24.0


             reply	other threads:[~2019-11-12 18:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-12 18:36 Markus Elfring [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-11-12 18:36 [PATCH] coccinelle: merge three rules from qsort.cocci Markus Elfring

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=41723f0e-1c8b-5e5d-9d8c-b0df1482166d@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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).