]> err.no Git - util-linux/commitdiff
blkid: remove useless if-before-free tests
authorJim Meyering <meyering@redhat.com>
Tue, 24 Feb 2009 14:58:37 +0000 (15:58 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 24 Feb 2009 15:07:03 +0000 (16:07 +0100)
[kzak@redhat.com: - port the original e2fsprogs patch to util-linux-ng]

Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
libs/blkid/src/cache.c
libs/blkid/src/dev.c
libs/blkid/src/devno.c
libs/blkid/src/resolve.c
libs/blkid/src/save.c
libs/blkid/src/tag.c

index 964992285785bcd449ee31c67532049c0f1c2700..3dd40d094810540cc1b5630a277eb1ae994db4ef 100644 (file)
@@ -179,8 +179,7 @@ void blkid_put_cache(blkid_cache cache)
                }
                blkid_free_tag(tag);
        }
-       if (cache->bic_filename)
-               free(cache->bic_filename);
+       free(cache->bic_filename);
 
        free(cache);
 }
index a1dc567ec8bc4fe583a22d3dcd2471391b9fde76..856e7d3ed509f19c861f9a5cd615841930c81dd6 100644 (file)
@@ -45,8 +45,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);
 }
 
@@ -137,18 +136,14 @@ extern int blkid_dev_set_search(blkid_dev_iterate iter,
        new_type = malloc(strlen(search_type)+1);
        new_value = malloc(strlen(search_value)+1);
        if (!new_type || !new_value) {
-               if (new_type)
-                       free(new_type);
-               if (new_value)
-                       free(new_value);
+               free(new_type);
+               free(new_value);
                return -1;
        }
        strcpy(new_type, search_type);
        strcpy(new_value, search_value);
-       if (iter->search_type)
-               free(iter->search_type);
-       if (iter->search_value)
-               free(iter->search_value);
+       free(iter->search_type);
+       free(iter->search_value);
        iter->search_type = new_type;
        iter->search_value = new_value;
        return 0;
index aaaca1ba0c5d93abb267240b03cd6dd8135c6dde..3b1d2c3294ae29db1cdd4d14a00d50e784dcac14 100644 (file)
@@ -222,8 +222,7 @@ int main(int argc, char** argv)
        }
        printf("Looking for device 0x%04llx\n", (long long)devno);
        devname = blkid_devno_to_devname(devno);
-       if (devname)
-               free(devname);
+       free(devname);
        return 0;
 }
 #endif
index 86fa9fe8865ae48415042f296ea9e56cd243055a..b6ca827ccf59454bc54064917432627eb4c52516 100644 (file)
@@ -97,10 +97,8 @@ char *blkid_get_devname(blkid_cache cache, const char *token,
        ret = blkid_strdup(blkid_dev_devname(dev));
 
 out:
-       if (t)
-               free(t);
-       if (v)
-               free(v);
+       free(t);
+       free(v);
        if (!cache) {
                blkid_put_cache(c);
        }
index 994b65c0a5eb6cb78c9e453e4484770176200392..12d385d0a75871cc1d0ddfc67a19c887dc6abff2 100644 (file)
@@ -153,8 +153,7 @@ int blkid_flush_cache(blkid_cache cache)
        }
 
 errout:
-       if (tmp)
-               free(tmp);
+       free(tmp);
        return ret;
 }
 
index 3de6bfa2ac23f96ef98f46325a138a30f126a375..bb9171d992832a9d265a05919467923716cb5f6f 100644 (file)
@@ -54,10 +54,8 @@ void blkid_free_tag(blkid_tag tag)
        list_del(&tag->bit_tags);       /* list of tags for this device */
        list_del(&tag->bit_names);      /* list of tags with this type */
 
-       if (tag->bit_name)
-               free(tag->bit_name);
-       if (tag->bit_val)
-               free(tag->bit_val);
+       free(tag->bit_name);
+       free(tag->bit_val);
 
        free(tag);
 }
@@ -206,8 +204,7 @@ int blkid_set_tag(blkid_dev dev, const char *name,
 errout:
        if (t)
                blkid_free_tag(t);
-       else if (val)
-               free(val);
+       else free(val);
        if (head)
                blkid_free_tag(head);
        return -BLKID_ERR_MEM;