git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] coccinelle: combine two rules from qsort.cocci

From
MEMarkus Elfring <markus.elfring@web.de>
Date
Nov 12, 2019, 19:23 UTC
Message-ID
<c19a6e52-3c13-1ff1-a313-d0d951328e29@web.de>
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
Message 1 of 1 in “coccinelle: combine two rules from qsort.cocci”
  1. coccinelle: combine two rules from qsort.cocciMarkus Elfring, Nov 12, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.