From: Jim Meyering Date: Tue, 24 Feb 2009 14:58:37 +0000 (+0100) Subject: blkid: remove useless if-before-free tests X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0e4ed1aab091de221bd54a188691943b1d1c803f;p=util-linux blkid: remove useless if-before-free tests [kzak@redhat.com: - port the original e2fsprogs patch to util-linux-ng] Signed-off-by: Jim Meyering Signed-off-by: Karel Zak --- diff --git a/libs/blkid/src/cache.c b/libs/blkid/src/cache.c index 96499228..3dd40d09 100644 --- a/libs/blkid/src/cache.c +++ b/libs/blkid/src/cache.c @@ -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); } diff --git a/libs/blkid/src/dev.c b/libs/blkid/src/dev.c index a1dc567e..856e7d3e 100644 --- a/libs/blkid/src/dev.c +++ b/libs/blkid/src/dev.c @@ -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; diff --git a/libs/blkid/src/devno.c b/libs/blkid/src/devno.c index aaaca1ba..3b1d2c32 100644 --- a/libs/blkid/src/devno.c +++ b/libs/blkid/src/devno.c @@ -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 diff --git a/libs/blkid/src/resolve.c b/libs/blkid/src/resolve.c index 86fa9fe8..b6ca827c 100644 --- a/libs/blkid/src/resolve.c +++ b/libs/blkid/src/resolve.c @@ -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); } diff --git a/libs/blkid/src/save.c b/libs/blkid/src/save.c index 994b65c0..12d385d0 100644 --- a/libs/blkid/src/save.c +++ b/libs/blkid/src/save.c @@ -153,8 +153,7 @@ int blkid_flush_cache(blkid_cache cache) } errout: - if (tmp) - free(tmp); + free(tmp); return ret; } diff --git a/libs/blkid/src/tag.c b/libs/blkid/src/tag.c index 3de6bfa2..bb9171d9 100644 --- a/libs/blkid/src/tag.c +++ b/libs/blkid/src/tag.c @@ -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;