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

[PATCH 2/2] cocci: FLEX_ALLOC_MEM to FLEX_ALLOC_STR

From
Denton Liu <liu.denton@gmail.com>
Date
Apr 3, 2019, 22:00 UTC
Message-ID
<78b6d3f58dc409477e801aa3d83e83ccee3841cb.1554328261.git.liu.denton@gmail.com>
In-Reply-To
<cover.1554328261.git.liu.denton@gmail.com>

Ensure that a FLEX_MALLOC_MEM that uses 'strlen' for its 'len' uses FLEX_ALLOC_STR instead, since these are equivalent forms.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
 contrib/coccinelle/flex_alloc.cocci | 13 +++++++++++++
 1 file changed, 13 insertions(+)
 create mode 100644 contrib/coccinelle/flex_alloc.cocci
diff --git a/contrib/coccinelle/flex_alloc.cocci b/contrib/coccinelle/flex_alloc.cocci
new file mode 100644
index 0000000000..e9f7f6d861
--- /dev/null
+++ b/contrib/coccinelle/flex_alloc.cocci
@@ -0,0 +1,13 @@
+@@
+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);
-- 
2.21.0.834.geaa57a21fa
Previous: Denton LiuNext: Jeff King
Message 3 of 4 in “create FLEX_ALLOC_MEM to FLEX_ALLOC_STR cocci rule”
  1. 0/2 create FLEX_ALLOC_MEM to FLEX_ALLOC_STR cocci ruleDenton Liu, Apr 3, 2019
  2. 1/2 midx.c: convert FLEX_ALLOC_MEM to FLEX_ALLOC_STRDenton Liu, Apr 3, 2019
  3. 2/2 cocci: FLEX_ALLOC_MEM to FLEX_ALLOC_STRDenton Liu, Apr 3, 2019
  4. Jeff KingApr 4, 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.