From: Ævar Arnfjörð Bjarmason Date: Thu, 15 Jun 2017 23:15:47 +0000 (+0000) Subject: coccinelle: add a rule to make "expression" code use FREE_AND_NULL() X-Git-Tag: v2.14.0-rc0~57^2~2 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/1b83d1251edbfb49feb84c0c32d241a63e2118a9 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 Signed-off-by: Junio C Hamano --- 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);