From: Ævar Arnfjörð Bjarmason Date: Thu, 15 Jun 2017 23:15:45 +0000 (+0000) Subject: coccinelle: add a rule to make "type" code use FREE_AND_NULL() X-Git-Tag: v2.14.0-rc0~57^2~4 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/cf9f49ea4817b36e93e64909a918a912cc32c28b coccinelle: add a rule to make "type" code use FREE_AND_NULL() 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 c03ba737e5..35fb992621 100644 --- a/contrib/coccinelle/free.cocci +++ b/contrib/coccinelle/free.cocci @@ -9,3 +9,11 @@ expression E; @@ - if (!E) free(E); + +@@ +type T; +T *ptr; +@@ +- free(ptr); +- ptr = NULL; ++ FREE_AND_NULL(ptr);