cocci: detect useless free(3) calls

Add a semantic patch for removing checks that cause free(3) to only be called with a NULL pointer, as that must be a programming mistake. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Feb 11, 2017 at 14:58 UTC ec6cd14c7a869b32776c1d3387afc93f369aea62
1 file changed +6
contrib/coccinelle/free.cocci
+6
@@ -3,3 +3,9 @@ expression E;
3 @@
4 - if (E)
5 free(E);
6 +
7 +@@
8 +expression E;
9 +@@
10 +- if (!E)
11 + free(E);