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

[PATCH] coccinelle: merge two rules from flex_alloc.cocci

From
MEMarkus Elfring <markus.elfring@web.de>
Date
Nov 12, 2019, 15:34 UTC
Message-ID
<f867512c-e5b2-6bca-2a37-2976f4c182bd@web.de>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 12 Nov 2019 16:30:14 +0100

This script contained two transformation rules for the semantic patch language which used duplicate code. Thus combine these rules by using a SmPL disjunction for the replacement of two identifiers.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 contrib/coccinelle/flex_alloc.cocci | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/contrib/coccinelle/flex_alloc.cocci b/contrib/coccinelle/flex_alloc.cocci
index e9f7f6d861..1b4fa8f801 100644
--- a/contrib/coccinelle/flex_alloc.cocci
+++ b/contrib/coccinelle/flex_alloc.cocci
@@ -1,13 +1,14 @@
-@@
+@adjustment@
 expression str;
-identifier x, flexname;
-@@
-- FLEX_ALLOC_MEM(x, flexname, str, strlen(str));
-+ FLEX_ALLOC_STR(x, flexname, str);
-
-@@
-expression str;
-identifier x, ptrname;
-@@
-- FLEXPTR_ALLOC_MEM(x, ptrname, str, strlen(str));
-+ FLEXPTR_ALLOC_STR(x, ptrname, str);
+identifier x, name;
+@@
+(
+-FLEX_ALLOC_MEM
++FLEX_ALLOC_STR
+|
+-FLEXPTR_ALLOC_MEM
++FLEXPTR_ALLOC_STR
+)
+               (x, name, str
+-                           , strlen(str)
+               );
--
2.24.0
Next: Denton Liu
Message 1 of 9 in “coccinelle: merge two rules from flex_alloc.cocci”
  1. coccinelle: merge two rules from flex_alloc.cocciMarkus Elfring, Nov 12, 2019
  2. Denton LiuNov 12, 2019
  3. Martin ÅgrenNov 13, 2019
  4. Markus ElfringNov 13, 2019
  5. Martin ÅgrenNov 14, 2019
  6. Markus ElfringNov 14, 2019
  7. SZEDER GáborNov 14, 2019
  8. Markus ElfringNov 14, 2019
  9. Junio C HamanoNov 15, 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.