coccinelle: add a rule to make "expression" code use FREE_AND_NULL()
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Thu, 15 Jun 2017 23:15:47 +0000 (23:15 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 16 Jun 2017 19:44:04 +0000 (12:44 -0700)
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>
contrib/coccinelle/free.cocci
index 35fb992621ff7c718d91258f4b8ac18a28db17ab..f2d97e755b891aac988121212a3bb2188b3a150a 100644 (file)
@@ -17,3 +17,10 @@ T *ptr;
 - free(ptr);
 - ptr = NULL;
 + FREE_AND_NULL(ptr);
+
+@@
+expression E;
+@@
+- free(E);
+- E = NULL;
++ FREE_AND_NULL(E);