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: combine two rules from qsort.cocci
Date: Tue, 12 Nov 2019 20:23:53 +0100	[thread overview]
Message-ID: <c19a6e52-3c13-1ff1-a313-d0d951328e29@web.de> (raw)

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

This script contained two transformation rules for the semantic patch language
which used duplicate code.

* Reduce duplication by merging common code from these rules.

* Use a SmPL disjunction for the pointer determination according to
  a sizeof operator.

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

diff --git a/contrib/coccinelle/qsort.cocci b/contrib/coccinelle/qsort.cocci
index 22b93a9966..1c9a12c7c0 100644
--- a/contrib/coccinelle/qsort.cocci
+++ b/contrib/coccinelle/qsort.cocci
@@ -1,14 +1,11 @@
 @@
 expression base, nmemb, compar;
 @@
-- qsort(base, nmemb, sizeof(*base), compar);
-+ QSORT(base, nmemb, compar);
-
-@@
-expression base, nmemb, compar;
-@@
-- qsort(base, nmemb, sizeof(base[0]), compar);
-+ QSORT(base, nmemb, compar);
+-qsort
++QSORT
+      (base, nmemb,
+-      sizeof( \( *base \| base[0] \) ),
+       compar);

 @@
 type T;
--
2.24.0


                 reply	other threads:[~2019-11-12 19:23 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=c19a6e52-3c13-1ff1-a313-d0d951328e29@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).