fix if(p)/free(p) construct
authorManinder Singh <maninder1.s@samsung.com>
Mon, 1 Jun 2015 10:38:07 +0000 (10:38 +0000)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sun, 7 Jun 2015 16:19:43 +0000 (18:19 +0200)
No need of explicit NULL check before free.

Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
Signed-off-by: Akhilesh Kumar <akhilesh.k@samsung.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
e2fsprogs/old_e2fsprogs/blkid/dev.c
e2fsprogs/old_e2fsprogs/fsck.c
scripts/kconfig/confdata.c
scripts/kconfig/util.c

index 84b7b0a7211d372c4f2c3bfccfbe912811066e0e..c2bbb06f3f8bb559d242828c162f0be804522b69 100644 (file)
@@ -44,8 +44,7 @@ void blkid_free_dev(blkid_dev dev)
                                           bit_tags);
                blkid_free_tag(tag);
        }
-       if (dev->bid_name)
-               free(dev->bid_name);
+       free(dev->bid_name);
        free(dev);
 }
 
index 91cce970c340fbfad290a406e7efa0490ec04d24..87874ce71c3933abb335204705da823935ec53c7 100644 (file)
@@ -354,12 +354,9 @@ static void parse_escape(char *word)
 
 static void free_instance(struct fsck_instance *i)
 {
-       if (i->prog)
-               free(i->prog);
-       if (i->device)
-               free(i->device);
-       if (i->base_device)
-               free(i->base_device);
+       free(i->prog);
+       free(i->device);
+       free(i->base_device);
        free(i);
 }
 
@@ -432,8 +429,7 @@ static int parse_fstab_line(char *line, struct fs_info **ret_fs)
        fs = create_fs_device(device, mntpnt, type ? type : "auto", opts,
                              freq ? atoi(freq) : -1,
                              passno ? atoi(passno) : -1);
-       if (dev)
-               free(dev);
+       free(dev);
 
        if (!fs)
                return -1;
index 303df0be7295b450976265b8003649d0e279a436..8f4ecbd337a4146d44a0f1ac16ad8b9f9c0fba34 100644 (file)
@@ -124,8 +124,7 @@ int conf_read_simple(const char *name)
                case S_INT:
                case S_HEX:
                case S_STRING:
-                       if (sym->user.val)
-                               free(sym->user.val);
+                       free(sym->user.val);
                default:
                        sym->user.val = NULL;
                        sym->user.tri = no;
index 263091945739f8aad8f49bf84a906a4d181ad8a3..13369e6a17cd32fdd0693151149c7b76304d9cd3 100644 (file)
@@ -79,8 +79,7 @@ struct gstr str_assign(const char *s)
 /* Free storage for growable string */
 void str_free(struct gstr *gs)
 {
-       if (gs->s)
-               free(gs->s);
+       free(gs->s);
        gs->s = NULL;
        gs->len = 0;
 }