From ec6cd14c7a869b32776c1d3387afc93f369aea62 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ren=C3=A9=20Scharfe?= Date: Sat, 11 Feb 2017 14:58:44 +0100 Subject: [PATCH] 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 Signed-off-by: Junio C Hamano --- contrib/coccinelle/free.cocci | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/contrib/coccinelle/free.cocci b/contrib/coccinelle/free.cocci index e28213161a..c03ba737e5 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); -- 2.11.4.GIT