Skip to contentSkip to conversation

tools:proc/readproc.c: remove explicit NULL check before free

PATCH In review Maninder Singh 1 participant 1 message Jun 10, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 3/8 tools:proc/readproc.c: remove explicit NULL check before free

No need of NULL check before free

---
 tools/top-LTP/proc/readproc.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
tools/top-LTP/proc/readproc.c +2 -4
index fd366e7..ead9623 100644
@@ -275,8 +275,7 @@ static char **file2strvec(const char *directory, const char *what)
 		if (n == 0 && rbuf == 0)
 			return NULL;	/* process died between our open and read */
 		if (n < 0) {
-			if (rbuf)
-				free(rbuf);
+			free(rbuf);
 			return NULL;	/* read error */
 		}
 		if (end_of_file && buf[n - 1])	/* last read char not null */
@@ -289,8 +288,7 @@ static char **file2strvec(const char *directory, const char *what)
 	}
 	close(fd);
 	if (n <= 0 && !end_of_file) {
-		if (rbuf)
-			free(rbuf);
+		free(rbuf);
 		return NULL;	/* read error */
 	}
 	endbuf = rbuf + tot;	/* count space for pointers */
Signature · 7 lines
1.7.9.5

------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list