Thread (8 messages) 8 messages, 2 authors, 2017-06-15

[PATCH v4 4/6] coccinelle: add a rule to make "expression" code use FREE_AND_NULL()

flat view
STALE3401d

From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2017-06-15 23:19:00
Subsystem: the rest · Maintainer: Linus Torvalds

Possibly related (same subject, not in this thread)

A follow-up to the existing "type" rule added in an earlier
change. This catches some occurrences that are missed by the previous
rule.

Signed-off-by: Ævar Arnfjörð Bjarmason <redacted>
---
 contrib/coccinelle/free.cocci | 7 +++++++
 1 file changed, 7 insertions(+)
diff --git a/contrib/coccinelle/free.cocci b/contrib/coccinelle/free.cocci
index 35fb992621..f2d97e755b 100644
--- a/contrib/coccinelle/free.cocci
+++ b/contrib/coccinelle/free.cocci
@@ -17,3 +17,10 @@ T *ptr;
 - free(ptr);
 - ptr = NULL;
 + FREE_AND_NULL(ptr);
+
+@@
+expression E;
+@@
+- free(E);
+- E = NULL;
++ FREE_AND_NULL(E);
-- 
2.13.1.508.gb3defc5cc
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help