Skip to content

Commit 76d8d45

Browse files
rscharfegitster
authored andcommitted
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>
1 parent 88ce3ef commit 76d8d45

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

contrib/coccinelle/free.cocci

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,9 @@ expression E;
1010
- if (!E)
1111
free(E);
1212

13-
@@
14-
type T;
15-
T *ptr;
16-
@@
17-
- free(ptr);
18-
- ptr = NULL;
19-
+ FREE_AND_NULL(ptr);
20-
2113
@@
2214
expression E;
2315
@@
2416
- free(E);
25-
- E = NULL;
2617
+ FREE_AND_NULL(E);
18+
- E = NULL;

0 commit comments

Comments
 (0)