summaryrefslogtreecommitdiff
path: root/contrib/coccinelle
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2017-06-25 08:01:04 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-06-29 17:46:16 (GMT)
commit76d8d45ffbc2cee911a66bdc5b6280a00da1a555 (patch)
treed29755913b4f57e9b56c5c50374d83e7a934af74 /contrib/coccinelle
parent88ce3ef636b1385e861ec0e9e2155248b999b032 (diff)
downloadgit-76d8d45ffbc2cee911a66bdc5b6280a00da1a555.zip
git-76d8d45ffbc2cee911a66bdc5b6280a00da1a555.tar.gz
git-76d8d45ffbc2cee911a66bdc5b6280a00da1a555.tar.bz2
coccinelle: polish FREE_AND_NULL rules
There are two rules for using FREE_AND_NULL in free.cocci, one for pointer types and one for expressions. Both cause coccinelle to remove empty lines and even newline characters between replacements for some reason; consecutive "free(x);/x=NULL;" sequences end up as multiple FREE_AND_NULL calls on the same time. Remove the type rule, as the expression rule already covers it, and rearrange the lines of the latter to place the addition of FREE_AND_NULL between the removals, which causes coccinelle to leave surrounding whitespace untouched. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/coccinelle')
-rw-r--r--contrib/coccinelle/free.cocci10
1 files changed, 1 insertions, 9 deletions
diff --git a/contrib/coccinelle/free.cocci b/contrib/coccinelle/free.cocci
index f2d97e7..4490069 100644
--- a/contrib/coccinelle/free.cocci
+++ b/contrib/coccinelle/free.cocci
@@ -11,16 +11,8 @@ expression E;
free(E);
@@
-type T;
-T *ptr;
-@@
-- free(ptr);
-- ptr = NULL;
-+ FREE_AND_NULL(ptr);
-
-@@
expression E;
@@
- free(E);
-- E = NULL;
+ FREE_AND_NULL(E);
+- E = NULL;