No need of NULL check before free
Signed-off-by: Maninder Singh <[email protected]>
Signed-off-by: Akhilesh Kumar <[email protected]>
---
tools/top-LTP/proc/readproc.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/tools/top-LTP/proc/readproc.c b/tools/top-LTP/proc/readproc.c
index fd366e7..ead9623 100644
--- a/tools/top-LTP/proc/readproc.c
+++ b/tools/top-LTP/proc/readproc.c
@@ -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 */
--
1.7.9.5
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list