Cleanup patch from Denis Vlasenko. Mostly variants of removing the if(x)

from before "if(x) free(x)".
This commit is contained in:
Rob Landley
2006-03-01 16:39:45 +00:00
parent 93f2286e6e
commit e7c43b66d7
33 changed files with 139 additions and 281 deletions

View File

@@ -88,8 +88,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);
}

View File

@@ -218,8 +218,7 @@ int main(int argc, char** argv)
}
printf("Looking for device 0x%04Lx\n", devno);
devname = blkid_devno_to_devname(devno);
if (devname)
free(devname);
free(devname);
return 0;
}
#endif

View File

@@ -96,10 +96,8 @@ char *blkid_get_devname(blkid_cache cache, const char *token,
ret = blkid_strdup(blkid_dev_devname(dev));
errout:
if (t)
free(t);
if (v)
free(v);
free(t);
free(v);
if (!cache) {
blkid_put_cache(c);
}

View File

@@ -148,8 +148,7 @@ int blkid_flush_cache(blkid_cache cache)
}
errout:
if (tmp)
free(tmp);
free(tmp);
return ret;
}

View File

@@ -41,11 +41,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);
}
@@ -112,8 +109,7 @@ int blkid_set_tag(blkid_dev dev, const char *name,
return -BLKID_ERR_MEM;
t = blkid_find_tag_dev(dev, name);
if (!value) {
if (t)
blkid_free_tag(t);
blkid_free_tag(t);
} else if (t) {
if (!strcmp(t->bit_val, val)) {
/* Same thing, exit */
@@ -165,12 +161,10 @@ int blkid_set_tag(blkid_dev dev, const char *name,
return 0;
errout:
if (t)
blkid_free_tag(t);
else if (val)
blkid_free_tag(t);
if (!t)
free(val);
if (head)
blkid_free_tag(head);
blkid_free_tag(head);
return -BLKID_ERR_MEM;
}