Commit 92de1c2c authored by Stephen Hemminger's avatar Stephen Hemminger

remove unnecessary checks for NULL before free

Since free(NULL) is a no-op, it is safe to remove unnecesary
if checks.
parent 122f2fc5
...@@ -322,8 +322,7 @@ struct lnstat_field *lnstat_find_field(struct lnstat_file *lnstat_files, ...@@ -322,8 +322,7 @@ struct lnstat_field *lnstat_find_field(struct lnstat_file *lnstat_files,
} }
} }
out: out:
if (file) free(file);
free(file);
return ret; return ret;
} }
...@@ -1994,8 +1994,7 @@ static void tcp_show_info(const struct nlmsghdr *nlh, struct inet_diag_msg *r, ...@@ -1994,8 +1994,7 @@ static void tcp_show_info(const struct nlmsghdr *nlh, struct inet_diag_msg *r,
s.segs_out = info->tcpi_segs_out; s.segs_out = info->tcpi_segs_out;
s.segs_in = info->tcpi_segs_in; s.segs_in = info->tcpi_segs_in;
tcp_stats_print(&s); tcp_stats_print(&s);
if (s.dctcp) free(s.dctcp);
free(s.dctcp);
} }
} }
...@@ -2380,8 +2379,7 @@ static int tcp_show(struct filter *f, int socktype) ...@@ -2380,8 +2379,7 @@ static int tcp_show(struct filter *f, int socktype)
outerr: outerr:
do { do {
int saved_errno = errno; int saved_errno = errno;
if (buf) free(buf);
free(buf);
if (fp) if (fp)
fclose(fp); fclose(fp);
errno = saved_errno; errno = saved_errno;
...@@ -2514,8 +2512,7 @@ static void unix_list_free(struct sockstat *list) ...@@ -2514,8 +2512,7 @@ static void unix_list_free(struct sockstat *list)
list = list->next; list = list->next;
if (name) free(name);
free(name);
free(s); free(s);
} }
} }
...@@ -2679,8 +2676,7 @@ static int unix_show_sock(const struct sockaddr_nl *addr, struct nlmsghdr *nlh, ...@@ -2679,8 +2676,7 @@ static int unix_show_sock(const struct sockaddr_nl *addr, struct nlmsghdr *nlh,
if (show_mem || show_details) if (show_mem || show_details)
printf("\n"); printf("\n");
if (name) free(name);
free(name);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment