]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
remove unnecessary checks for NULL before free
authorStephen Hemminger <shemming@brocade.com>
Tue, 21 Jul 2015 17:49:54 +0000 (10:49 -0700)
committerStephen Hemminger <shemming@brocade.com>
Tue, 21 Jul 2015 17:49:54 +0000 (10:49 -0700)
Since free(NULL) is a no-op, it is safe to remove unnecesary
if checks.

misc/lnstat_util.c
misc/ss.c

index 9492baf025973d290bfc2180c5b6b79d655a8c68..6dde7c49432714431157df06d32e8d56bc5d9433 100644 (file)
@@ -322,8 +322,7 @@ struct lnstat_field *lnstat_find_field(struct lnstat_file *lnstat_files,
                }
        }
 out:
-       if (file)
-               free(file);
+       free(file);
 
        return ret;
 }
index 6abd1d1206b34981d47d17f3093105f1a1a02ee4..17ec21603975d79ee6c30e10d89307262389135b 100644 (file)
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -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_in = info->tcpi_segs_in;
                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)
 outerr:
        do {
                int saved_errno = errno;
-               if (buf)
-                       free(buf);
+               free(buf);
                if (fp)
                        fclose(fp);
                errno = saved_errno;
@@ -2514,8 +2512,7 @@ static void unix_list_free(struct sockstat *list)
 
                list = list->next;
 
-               if (name)
-                       free(name);
+               free(name);
                free(s);
        }
 }
@@ -2679,8 +2676,7 @@ static int unix_show_sock(const struct sockaddr_nl *addr, struct nlmsghdr *nlh,
        if (show_mem || show_details)
                printf("\n");
 
-       if (name)
-               free(name);
+       free(name);
        return 0;
 }