git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cocci: detect useless free(3) calls
@ 2017-02-11 13:58 René Scharfe
  2017-02-11 19:01 ` Junio C Hamano
  2017-02-11 19:31 ` Lars Schneider
  0 siblings, 2 replies; 4+ messages in thread
From: René Scharfe @ 2017-02-11 13:58 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano, Pranit Bauva

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>
---
No cases are found in master or next, but 1d263b93 (bisect--helper:
`bisect_next_check` & bisect_voc shell function in C) introduced four
of them to pu.

 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.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-02-11 19:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-11 13:58 [PATCH] cocci: detect useless free(3) calls René Scharfe
2017-02-11 19:01 ` Junio C Hamano
2017-02-11 19:31 ` Lars Schneider
2017-02-11 19:50   ` René Scharfe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).