aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2017-06-15 23:15:45 +0000
committerJunio C Hamano <gitster@pobox.com>2017-06-16 12:41:54 -0700
commitcf9f49ea4817b36e93e64909a918a912cc32c28b (patch)
tree12aecc186db45e1cd2da6fc76ce8227287f6e836 /contrib
parent481df65f4f72582369eea8d002070c5dff38f8e6 (diff)
downloadgit-cf9f49ea4817b36e93e64909a918a912cc32c28b.tar.gz
git-cf9f49ea4817b36e93e64909a918a912cc32c28b.tar.xz
coccinelle: add a rule to make "type" code use FREE_AND_NULL()
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib')
-rw-r--r--contrib/coccinelle/free.cocci8
1 files changed, 8 insertions, 0 deletions
diff --git a/contrib/coccinelle/free.cocci b/contrib/coccinelle/free.cocci
index c03ba737e..35fb99262 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);