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>

René Scharfe committed Jun 25, 2017 at 10:01 UTC 76d8d45ffbc2cee911a66bdc5b6280a00da1a555
1 file changed +1 -9
contrib/coccinelle/free.cocci
+1 -9
@@ -10,17 +10,9 @@ expression E;
10 - if (!E)
11 free(E);
12
13 -@@
14 -type T;
15 -T *ptr;
16 -@@
17 -- free(ptr);
18 -- ptr = NULL;
19 -+ FREE_AND_NULL(ptr);
20 -
13 @@
14 expression E;
15 @@
16 - free(E);
25 -- E = NULL;
17 + FREE_AND_NULL(E);
18 +- E = NULL;