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

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

From
MEMarkus Elfring <markus.elfring@web.de>
Date
Nov 12, 2019, 14:15 UTC
Message-ID
<17c6e9d5-5a06-8150-fa82-e20e7b850fe4@web.de>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 12 Nov 2019 15:00:29 +0100

This script contained two transformation rules for the semantic patch language where a condition check should be removed before free() calls. It should not matter if a corresponding expression begins with a not operator (or not). Thus combine these rules by using a SmPL disjunction.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 contrib/coccinelle/free.cocci | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/contrib/coccinelle/free.cocci b/contrib/coccinelle/free.cocci
index 4490069df9..63e442d3ef 100644
--- a/contrib/coccinelle/free.cocci
+++ b/contrib/coccinelle/free.cocci
@@ -1,13 +1,7 @@
 @@
 expression E;
 @@
-- if (E)
-  free(E);
-
-@@
-expression E;
-@@
-- if (!E)
+- if ( \( E \| !E \) )
   free(E);

 @@
--
2.24.0
Message 1 of 1 in “coccinelle: merge two rules from free.cocci”
  1. coccinelle: merge two rules from free.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.