summaryrefslogtreecommitdiff
path: root/contrib/coccinelle
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2017-02-11 13:58:44 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-02-11 19:29:12 (GMT)
commitec6cd14c7a869b32776c1d3387afc93f369aea62 (patch)
treec7b5928a3c577c169c1fa2d0bc1f6bc7617e1fb9 /contrib/coccinelle
parent3b9e3c2cede15057af3ff8076c45ad5f33829436 (diff)
downloadgit-ec6cd14c7a869b32776c1d3387afc93f369aea62.zip
git-ec6cd14c7a869b32776c1d3387afc93f369aea62.tar.gz
git-ec6cd14c7a869b32776c1d3387afc93f369aea62.tar.bz2
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>
Diffstat (limited to 'contrib/coccinelle')
-rw-r--r--contrib/coccinelle/free.cocci6
1 files changed, 6 insertions, 0 deletions
diff --git a/contrib/coccinelle/free.cocci b/contrib/coccinelle/free.cocci
index e282131..c03ba73 100644
--- a/contrib/coccinelle/free.cocci
+++ b/contrib/coccinelle/free.cocci
@@ -3,3 +3,9 @@ expression E;
@@
- if (E)
free(E);
+
+@@
+expression E;
+@@
+- if (!E)
+ free(E);