summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2017-06-15 23:15:47 +0000
committerJunio C Hamano <gitster@pobox.com>2017-06-16 12:44:04 -0700
commit1b83d1251edbfb49feb84c0c32d241a63e2118a9 (patch)
tree8cd6b7bbcafa2da07e575537a506a33f7d09365f
parent6a83d902073803c4141e02c53decf8c03e35da27 (diff)
downloadgit-1b83d1251edbfb49feb84c0c32d241a63e2118a9.tar.gz
coccinelle: add a rule to make "expression" code use FREE_AND_NULL()
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 <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--contrib/coccinelle/free.cocci7
1 files changed, 7 insertions, 0 deletions
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);