Skip to contentSkip to conversation

PATCH 8/8] kernel/libcpuset.c: remove explicit NULL check before free

LTP Maninder Singh 1 participant 1 message Jun 10, 2015

lore
Share & tools
lore
#0 lore raw

No need of NULL check before free

---
 .../controllers/cpuset/cpuset_lib/libcpuset.c      |   15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
testcases/kernel/controllers/cpuset/cpuset_lib/libcpuset.c +5 -10
index d2d3c12..83ff5cd 100644
@@ -601,8 +601,7 @@ static void update_mask_sizes()
 			nodemask_sz = s2nbits(buf + strlen(nodemask_prefix));
 	}
 done:
-	if (buf != NULL)
-		free(buf);
+	free(buf);
 	if (fp != NULL)
 		fclose(fp);
 	if (cpumask_sz == 0)
@@ -634,8 +633,7 @@ err:
 		bitmask_free(cp->cpus);
 	if (cp && cp->mems)
 		bitmask_free(cp->mems);
-	if (cp)
-		free(cp);
+	free(cp);
 	return NULL;
 }
 
@@ -2588,8 +2586,7 @@ static void add_pidblock(const char *file, struct pidblock **ppbhead)
 err:
 	if (fp)
 		fclose(fp);
-	if (pb)
-		free(pb);
+	free(pb);
 }
 
 static void read_task_file(const char *relpath, struct pidblock **ppbhead)
@@ -2722,8 +2719,7 @@ void cpuset_freepidlist(struct cpuset_pidlist *pl)
 {
 	if (pl && pl->pids)
 		free(pl->pids);
-	if (pl)
-		free(pl);
+	free(pl);
 }
 
 static int __cpuset_move(pid_t pid, const char *path)
@@ -3655,8 +3651,7 @@ eol:
 err:
 	if (elinenum)
 		*elinenum = linenum;
-	if (linebuf)
-		free(linebuf);
+	free(linebuf);
 	return -1;
 }
 
Signature · 7 lines
1.7.9.5

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