git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] coccinelle: combine two rules from qsort.cocci
@ 2019-11-12 19:23 Markus Elfring
  0 siblings, 0 replies; only message in thread
From: Markus Elfring @ 2019-11-12 19:23 UTC (permalink / raw)
  To: git; +Cc: René Scharfe

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


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

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

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

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).