]> granicus.if.org Git - sysstat/commitdiff
Remove redundant NULL checks.
authorMuneyuki Noguchi <nogu.dev@gmail.com>
Sat, 29 Jun 2013 03:00:14 +0000 (12:00 +0900)
committerMuneyuki Noguchi <nogu.dev@gmail.com>
Sat, 29 Jun 2013 03:33:06 +0000 (12:33 +0900)
Remove NULL checks before free() because free(NULL) performs no operation.

cifsiostat.c
count.c
ioconf.c
iostat.c
mpstat.c
nfsiostat.c
pidstat.c
sadf.c
sar.c

index 9c5054a3cd585bf9b42fad42385660db6daafe34..f898420a76c4d532d68ca57a2ca7007f4a6ba884 100644 (file)
@@ -201,15 +201,10 @@ void io_sys_free(void)
 
        /* Free CIFS directories structures */
        for (i = 0; i < 2; i++) {
-
-               if (st_cifs[i]) {
-                       free(st_cifs[i]);
-               }
+               free(st_cifs[i]);
        }
        
-       if (st_hdr_cifs) {
-               free(st_hdr_cifs);
-       }
+       free(st_hdr_cifs);
 }
 
 /*
diff --git a/count.c b/count.c
index d14fe794e0649dc083597c3e20c8d16c3c8dc8e9..1c76013ffb22583a20fc3001bf9e7aa3e7b4a9d6 100644 (file)
--- a/count.c
+++ b/count.c
@@ -362,9 +362,7 @@ int get_irqcpu_nr(char *file, int max_nr_irqcpu, int cpu_nr)
 
        fclose(fp);
 
-       if (line) {
-               free(line);
-       }
+       free(line);
 
        return irq;
 }
index 001132049572e9a582f6525c8b4a83d4b1f9bfde..763a2e30174cb1351b0aec8835014ab31d5d124f 100644 (file)
--- a/ioconf.c
+++ b/ioconf.c
@@ -340,10 +340,8 @@ int ioc_init(void)
         * after IOC_ALLOC( blkp->desc ... ).
         * Right now, we don't.
         */
-       if (blkp != NULL)
-               free(blkp);
-       if (iocp != NULL)
-               free(iocp);
+       free(blkp);
+       free(iocp);
 
        /* Indicate that ioconf file has been parsed */
        ioc_parsed = 1;
index 8b5034e2ac935444a9741d95df6eb2ce8b736084..be249933b9633ae22fb1a49290725d87e8aa1c06 100644 (file)
--- a/iostat.c
+++ b/iostat.c
@@ -251,9 +251,7 @@ void salloc_dev_list(int list_len)
  */
 void sfree_dev_list(void)
 {
-       if (st_dev_list) {
-               free(st_dev_list);
-       }
+       free(st_dev_list);
 }
 
 /*
@@ -402,21 +400,14 @@ void io_sys_free(void)
        int i;
        
        for (i = 0; i < 2; i++) {
-
                /* Free CPU structures */
-               if (st_cpu[i]) {
-                       free(st_cpu[i]);
-               }
+               free(st_cpu[i]);
 
                /* Free I/O device structures */
-               if (st_iodev[i]) {
-                       free(st_iodev[i]);
-               }
+               free(st_iodev[i]);
        }
        
-       if (st_hdr_iodev) {
-               free(st_hdr_iodev);
-       }
+       free(st_hdr_iodev);
 }
 
 /*
index efe7170086b189f102f92f7cc4b15926d22614f5..1521755c0521cc9c9e4d97a72e58d01b9954ac74 100644 (file)
--- a/mpstat.c
+++ b/mpstat.c
@@ -183,24 +183,13 @@ void sfree_mp_struct(void)
        int i;
 
        for (i = 0; i < 3; i++) {
-
-               if (st_cpu[i]) {
-                       free(st_cpu[i]);
-               }
-               if (st_irq[i]) {
-                       free(st_irq[i]);
-               }
-               if (st_irqcpu[i]) {
-                       free(st_irqcpu[i]);
-               }
-               if (st_softirqcpu[i]) {
-                       free(st_softirqcpu[i]);
-               }
+               free(st_cpu[i]);
+               free(st_irq[i]);
+               free(st_irqcpu[i]);
+               free(st_softirqcpu[i]);
        }
 
-       if (cpu_bitmap) {
-               free(cpu_bitmap);
-       }
+       free(cpu_bitmap);
 }
 
 /*
@@ -718,9 +707,7 @@ void read_interrupts_stat(char *file, struct stats_irqcpu *st_ic[], int ic_nr, i
 
                fclose(fp);
                
-               if (line) {
-                       free(line);
-               }
+               free(line);
        }
 
        while (irq < ic_nr) {
index b437a39045e3c10c0830c77a93744bc8f5fe6298..7c219b46d8ebc86b0d8ced5f7aabd51a7cd4c040 100644 (file)
@@ -225,15 +225,10 @@ void io_sys_free(void)
 
        /* Free I/O NFS directories structures */
        for (i = 0; i < 2; i++) {
-
-               if (st_ionfs[i]) {
-                       free(st_ionfs[i]);
-               }
+               free(st_ionfs[i]);
        }
        
-       if (st_hdr_ionfs) {
-               free(st_hdr_ionfs);
-       }
+       free(st_hdr_ionfs);
 }
 
 /*
index ab565a6bd32142ec4ac7f9c5b1f3a36b9ac52c8c..57d7b9514ce66dec21f0b262a9ef91c169ebba1d 100644 (file)
--- a/pidstat.c
+++ b/pidstat.c
@@ -174,9 +174,7 @@ void sfree_pid(void)
        int i;
        
        for (i = 0; i < 3; i++) {
-               if (st_pid_list[i]) {
-                       free(st_pid_list[i]);
-               }
+               free(st_pid_list[i]);
        }
 }
 
@@ -2259,9 +2257,7 @@ int main(int argc, char **argv)
        rw_pidstat_loop(dis_hdr, rows);
        
        /* Free structures */
-       if (pid_array) {
-               free(pid_array);
-       }
+       free(pid_array);
        sfree_pid();
 
        return 0;
diff --git a/sadf.c b/sadf.c
index 1cad7bf2d63ff3f7df9b095b1fa48c199b32b948..8bc0f562b9f7df47735aaa80a58c36cf1c084251 100644 (file)
--- a/sadf.c
+++ b/sadf.c
@@ -1338,9 +1338,7 @@ void read_stats_from_file(char dfile[])
 
        close(ifd);
        
-       if (file_actlst) {
-               free(file_actlst);
-       }
+       free(file_actlst);
        free_structures(act);
 }
 
diff --git a/sar.c b/sar.c
index 06b459179c7d1abe0ecd9fc48092adf76a145aa4..9eafc6a743640093f6bdd32551de8df9b9ace78f 100644 (file)
--- a/sar.c
+++ b/sar.c
@@ -1007,9 +1007,7 @@ void read_stats_from_file(char from_file[])
 
        close(ifd);
        
-       if (file_actlst) {
-               free(file_actlst);
-       }
+       free(file_actlst);
 }
 
 /*