summaryrefslogtreecommitdiff
path: root/e2fsprogs/ext2fs
diff options
context:
space:
mode:
Diffstat (limited to 'e2fsprogs/ext2fs')
-rw-r--r--e2fsprogs/ext2fs/bmap.c3
-rw-r--r--e2fsprogs/ext2fs/bmove.c6
-rw-r--r--e2fsprogs/ext2fs/brel_ma.c6
-rw-r--r--e2fsprogs/ext2fs/dblist.c3
-rw-r--r--e2fsprogs/ext2fs/fileio.c6
-rw-r--r--e2fsprogs/ext2fs/freefs.c52
-rw-r--r--e2fsprogs/ext2fs/get_pathname.c3
-rw-r--r--e2fsprogs/ext2fs/icount.c9
-rw-r--r--e2fsprogs/ext2fs/imager.c3
-rw-r--r--e2fsprogs/ext2fs/inode.c2
-rw-r--r--e2fsprogs/ext2fs/irel_ma.c18
-rw-r--r--e2fsprogs/ext2fs/mkdir.c3
-rw-r--r--e2fsprogs/ext2fs/namei.c3
-rw-r--r--e2fsprogs/ext2fs/rw_bitmaps.c11
-rw-r--r--e2fsprogs/ext2fs/test_io.c9
-rw-r--r--e2fsprogs/ext2fs/unix_io.c9
16 files changed, 47 insertions, 99 deletions
diff --git a/e2fsprogs/ext2fs/bmap.c b/e2fsprogs/ext2fs/bmap.c
index 45d49f9..4a53ebc 100644
--- a/e2fsprogs/ext2fs/bmap.c
+++ b/e2fsprogs/ext2fs/bmap.c
@@ -257,8 +257,7 @@ errcode_t ext2fs_bmap(ext2_filsys fs, ext2_ino_t ino, struct ext2_inode *inode,
retval = block_tind_bmap(fs, bmap_flags, b, block_buf,
&blocks_alloc, block, phys_blk);
done:
- if (buf)
- ext2fs_free_mem(&buf);
+ ext2fs_free_mem(&buf);
if ((retval == 0) && (blocks_alloc || inode_dirty)) {
inode->i_blocks += (blocks_alloc * fs->blocksize) / 512;
retval = ext2fs_write_inode(fs, ino, inode);
diff --git a/e2fsprogs/ext2fs/bmove.c b/e2fsprogs/ext2fs/bmove.c
index fb319f8..7e98c0f 100644
--- a/e2fsprogs/ext2fs/bmove.c
+++ b/e2fsprogs/ext2fs/bmove.c
@@ -119,10 +119,8 @@ errcode_t ext2fs_move_blocks(ext2_filsys fs,
* block move.
*/
if (flags & EXT2_BMOVE_GET_DBLIST) {
- if (fs->dblist) {
- ext2fs_free_dblist(fs->dblist);
- fs->dblist = NULL;
- }
+ ext2fs_free_dblist(fs->dblist);
+ fs->dblist = NULL;
retval = ext2fs_init_dblist(fs, 0);
if (retval)
return retval;
diff --git a/e2fsprogs/ext2fs/brel_ma.c b/e2fsprogs/ext2fs/brel_ma.c
index 4dcfded..557143d 100644
--- a/e2fsprogs/ext2fs/brel_ma.c
+++ b/e2fsprogs/ext2fs/brel_ma.c
@@ -186,12 +186,10 @@ static errcode_t bma_free(ext2_brel brel)
ma = brel->priv_data;
if (ma) {
- if (ma->entries)
- ext2fs_free_mem(&ma->entries);
+ ext2fs_free_mem(&ma->entries);
ext2fs_free_mem(&ma);
}
- if (brel->name)
- ext2fs_free_mem(&brel->name);
+ ext2fs_free_mem(&brel->name);
ext2fs_free_mem(&brel);
return 0;
}
diff --git a/e2fsprogs/ext2fs/dblist.c b/e2fsprogs/ext2fs/dblist.c
index 0cf5698..73313fa 100644
--- a/e2fsprogs/ext2fs/dblist.c
+++ b/e2fsprogs/ext2fs/dblist.c
@@ -99,8 +99,7 @@ static errcode_t make_dblist(ext2_filsys fs, ext2_ino_t size, ext2_ino_t count,
fs->dblist = dblist;
return 0;
cleanup:
- if (dblist)
- ext2fs_free_mem(&dblist);
+ ext2fs_free_mem(&dblist);
return retval;
}
diff --git a/e2fsprogs/ext2fs/fileio.c b/e2fsprogs/ext2fs/fileio.c
index 669e80c..da349fe 100644
--- a/e2fsprogs/ext2fs/fileio.c
+++ b/e2fsprogs/ext2fs/fileio.c
@@ -73,8 +73,7 @@ errcode_t ext2fs_file_open2(ext2_filsys fs, ext2_ino_t ino,
return 0;
fail:
- if (file->buf)
- ext2fs_free_mem(&file->buf);
+ ext2fs_free_mem(&file->buf);
ext2fs_free_mem(&file);
return retval;
}
@@ -197,8 +196,7 @@ errcode_t ext2fs_file_close(ext2_file_t file)
retval = ext2fs_file_flush(file);
- if (file->buf)
- ext2fs_free_mem(&file->buf);
+ ext2fs_free_mem(&file->buf);
ext2fs_free_mem(&file);
return retval;
diff --git a/e2fsprogs/ext2fs/freefs.c b/e2fsprogs/ext2fs/freefs.c
index 3fd51f2..f0f7b3e 100644
--- a/e2fsprogs/ext2fs/freefs.c
+++ b/e2fsprogs/ext2fs/freefs.c
@@ -30,25 +30,17 @@ void ext2fs_free(ext2_filsys fs)
if (fs->io) {
io_channel_close(fs->io);
}
- if (fs->device_name)
- ext2fs_free_mem(&fs->device_name);
- if (fs->super)
- ext2fs_free_mem(&fs->super);
- if (fs->orig_super)
- ext2fs_free_mem(&fs->orig_super);
- if (fs->group_desc)
- ext2fs_free_mem(&fs->group_desc);
- if (fs->block_map)
- ext2fs_free_block_bitmap(fs->block_map);
- if (fs->inode_map)
- ext2fs_free_inode_bitmap(fs->inode_map);
-
- if (fs->badblocks)
- ext2fs_badblocks_list_free(fs->badblocks);
+ ext2fs_free_mem(&fs->device_name);
+ ext2fs_free_mem(&fs->super);
+ ext2fs_free_mem(&fs->orig_super);
+ ext2fs_free_mem(&fs->group_desc);
+ ext2fs_free_block_bitmap(fs->block_map);
+ ext2fs_free_inode_bitmap(fs->inode_map);
+
+ ext2fs_badblocks_list_free(fs->badblocks);
fs->badblocks = 0;
- if (fs->dblist)
- ext2fs_free_dblist(fs->dblist);
+ ext2fs_free_dblist(fs->dblist);
if (fs->icache)
ext2fs_free_inode_cache(fs->icache);
@@ -64,14 +56,8 @@ void ext2fs_free_generic_bitmap(ext2fs_inode_bitmap bitmap)
return;
bitmap->magic = 0;
- if (bitmap->description) {
- ext2fs_free_mem(&bitmap->description);
- bitmap->description = 0;
- }
- if (bitmap->bitmap) {
- ext2fs_free_mem(&bitmap->bitmap);
- bitmap->bitmap = 0;
- }
+ ext2fs_free_mem(&bitmap->description);
+ ext2fs_free_mem(&bitmap->bitmap);
ext2fs_free_mem(&bitmap);
}
@@ -100,10 +86,8 @@ static void ext2fs_free_inode_cache(struct ext2_inode_cache *icache)
{
if (--icache->refcount)
return;
- if (icache->buffer)
- ext2fs_free_mem(&icache->buffer);
- if (icache->cache)
- ext2fs_free_mem(&icache->cache);
+ ext2fs_free_mem(&icache->buffer);
+ ext2fs_free_mem(&icache->cache);
icache->buffer_blk = 0;
ext2fs_free_mem(&icache);
}
@@ -113,12 +97,10 @@ static void ext2fs_free_inode_cache(struct ext2_inode_cache *icache)
*/
void ext2fs_u32_list_free(ext2_u32_list bb)
{
- if (bb->magic != EXT2_ET_MAGIC_BADBLOCKS_LIST)
+ if (!bb || bb->magic != EXT2_ET_MAGIC_BADBLOCKS_LIST)
return;
- if (bb->list)
- ext2fs_free_mem(&bb->list);
- bb->list = 0;
+ ext2fs_free_mem(&bb->list);
ext2fs_free_mem(&bb);
}
@@ -136,9 +118,7 @@ void ext2fs_free_dblist(ext2_dblist dblist)
if (!dblist || (dblist->magic != EXT2_ET_MAGIC_DBLIST))
return;
- if (dblist->list)
- ext2fs_free_mem(&dblist->list);
- dblist->list = 0;
+ ext2fs_free_mem(&dblist->list);
if (dblist->fs && dblist->fs->dblist == dblist)
dblist->fs->dblist = 0;
dblist->magic = 0;
diff --git a/e2fsprogs/ext2fs/get_pathname.c b/e2fsprogs/ext2fs/get_pathname.c
index 594090d..0004790 100644
--- a/e2fsprogs/ext2fs/get_pathname.c
+++ b/e2fsprogs/ext2fs/get_pathname.c
@@ -132,8 +132,7 @@ static errcode_t ext2fs_get_pathname_int(ext2_filsys fs, ext2_ino_t dir,
retval = 0;
cleanup:
- if (gp.name)
- ext2fs_free_mem(&gp.name);
+ ext2fs_free_mem(&gp.name);
return retval;
}
diff --git a/e2fsprogs/ext2fs/icount.c b/e2fsprogs/ext2fs/icount.c
index 0167777..7ae2a5c 100644
--- a/e2fsprogs/ext2fs/icount.c
+++ b/e2fsprogs/ext2fs/icount.c
@@ -59,12 +59,9 @@ void ext2fs_free_icount(ext2_icount_t icount)
return;
icount->magic = 0;
- if (icount->list)
- ext2fs_free_mem(&icount->list);
- if (icount->single)
- ext2fs_free_inode_bitmap(icount->single);
- if (icount->multiple)
- ext2fs_free_inode_bitmap(icount->multiple);
+ ext2fs_free_mem(&icount->list);
+ ext2fs_free_inode_bitmap(icount->single);
+ ext2fs_free_inode_bitmap(icount->multiple);
ext2fs_free_mem(&icount);
}
diff --git a/e2fsprogs/ext2fs/imager.c b/e2fsprogs/ext2fs/imager.c
index 00eb717..ece66fc 100644
--- a/e2fsprogs/ext2fs/imager.c
+++ b/e2fsprogs/ext2fs/imager.c
@@ -371,7 +371,6 @@ errcode_t ext2fs_image_bitmap_read(ext2_filsys fs, int fd, int flags)
retval = 0;
errout:
- if (buf)
- free(buf);
+ free(buf);
return (retval);
}
diff --git a/e2fsprogs/ext2fs/inode.c b/e2fsprogs/ext2fs/inode.c
index e50bece..4c386c7 100644
--- a/e2fsprogs/ext2fs/inode.c
+++ b/e2fsprogs/ext2fs/inode.c
@@ -123,7 +123,7 @@ errcode_t ext2fs_open_inode_scan(ext2_filsys fs, int buffer_blocks,
save_get_blocks = fs->get_blocks;
fs->get_blocks = 0;
retval = ext2fs_read_bb_inode(fs, &fs->badblocks);
- if (retval && fs->badblocks) {
+ if (retval) {
ext2fs_badblocks_list_free(fs->badblocks);
fs->badblocks = 0;
}
diff --git a/e2fsprogs/ext2fs/irel_ma.c b/e2fsprogs/ext2fs/irel_ma.c
index d9e73f7..f4fe1e0 100644
--- a/e2fsprogs/ext2fs/irel_ma.c
+++ b/e2fsprogs/ext2fs/irel_ma.c
@@ -309,8 +309,7 @@ static errcode_t ima_move(ext2_irel irel, ext2_ino_t old, ext2_ino_t new)
return ENOENT;
ma->entries[(unsigned) new] = ma->entries[(unsigned) old];
- if (ma->ref_entries[(unsigned) new].refs)
- ext2fs_free_mem(&ma->ref_entries[(unsigned) new].refs);
+ ext2fs_free_mem(&ma->ref_entries[(unsigned) new].refs);
ma->ref_entries[(unsigned) new] = ma->ref_entries[(unsigned) old];
ma->entries[(unsigned) old].new = 0;
@@ -332,8 +331,7 @@ static errcode_t ima_delete(ext2_irel irel, ext2_ino_t old)
return ENOENT;
ma->entries[old].new = 0;
- if (ma->ref_entries[(unsigned) old].refs)
- ext2fs_free_mem(&ma->ref_entries[(unsigned) old].refs);
+ ext2fs_free_mem(&ma->ref_entries[(unsigned) old].refs);
ma->orig_map[ma->entries[(unsigned) old].orig] = 0;
ma->ref_entries[(unsigned) old].num = 0;
@@ -352,21 +350,17 @@ static errcode_t ima_free(ext2_irel irel)
ma = irel->priv_data;
if (ma) {
- if (ma->orig_map)
- ext2fs_free_mem(&ma->orig_map);
- if (ma->entries)
- ext2fs_free_mem(&ma->entries);
+ ext2fs_free_mem(&ma->orig_map);
+ ext2fs_free_mem(&ma->entries);
if (ma->ref_entries) {
for (ino = 0; ino <= ma->max_inode; ino++) {
- if (ma->ref_entries[(unsigned) ino].refs)
- ext2fs_free_mem(&ma->ref_entries[(unsigned) ino].refs);
+ ext2fs_free_mem(&ma->ref_entries[(unsigned) ino].refs);
}
ext2fs_free_mem(&ma->ref_entries);
}
ext2fs_free_mem(&ma);
}
- if (irel->name)
- ext2fs_free_mem(&irel->name);
+ ext2fs_free_mem(&irel->name);
ext2fs_free_mem(&irel);
return 0;
}
diff --git a/e2fsprogs/ext2fs/mkdir.c b/e2fsprogs/ext2fs/mkdir.c
index bf46e50..c3c0371 100644
--- a/e2fsprogs/ext2fs/mkdir.c
+++ b/e2fsprogs/ext2fs/mkdir.c
@@ -133,8 +133,7 @@ errcode_t ext2fs_mkdir(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t inum,
ext2fs_inode_alloc_stats2(fs, ino, +1, 1);
cleanup:
- if (block)
- ext2fs_free_mem(&block);
+ ext2fs_free_mem(&block);
return retval;
}
diff --git a/e2fsprogs/ext2fs/namei.c b/e2fsprogs/ext2fs/namei.c
index 6ce4bb3..2c372f4 100644
--- a/e2fsprogs/ext2fs/namei.c
+++ b/e2fsprogs/ext2fs/namei.c
@@ -61,8 +61,7 @@ static errcode_t follow_link(ext2_filsys fs, ext2_ino_t root, ext2_ino_t dir,
pathname = (char *)&(ei.i_block[0]);
retval = open_namei(fs, root, dir, pathname, ei.i_size, 1,
link_count, buf, res_inode);
- if (buffer)
- ext2fs_free_mem(&buffer);
+ ext2fs_free_mem(&buffer);
return retval;
}
diff --git a/e2fsprogs/ext2fs/rw_bitmaps.c b/e2fsprogs/ext2fs/rw_bitmaps.c
index ae7b6e0..d5698a2 100644
--- a/e2fsprogs/ext2fs/rw_bitmaps.c
+++ b/e2fsprogs/ext2fs/rw_bitmaps.c
@@ -163,8 +163,7 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
if (retval)
return retval;
if (do_block) {
- if (fs->block_map)
- ext2fs_free_block_bitmap(fs->block_map);
+ ext2fs_free_block_bitmap(fs->block_map);
sprintf(buf, "block bitmap for %s", fs->device_name);
retval = ext2fs_allocate_block_bitmap(fs, buf, &fs->block_map);
if (retval)
@@ -172,8 +171,7 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
block_bitmap = fs->block_map->bitmap;
}
if (do_inode) {
- if (fs->inode_map)
- ext2fs_free_inode_bitmap(fs->inode_map);
+ ext2fs_free_inode_bitmap(fs->inode_map);
sprintf(buf, "inode bitmap for %s", fs->device_name);
retval = ext2fs_allocate_inode_bitmap(fs, buf, &fs->inode_map);
if (retval)
@@ -247,14 +245,11 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block)
cleanup:
if (do_block) {
ext2fs_free_mem(&fs->block_map);
- fs->block_map = 0;
}
if (do_inode) {
ext2fs_free_mem(&fs->inode_map);
- fs->inode_map = 0;
}
- if (buf)
- ext2fs_free_mem(&buf);
+ ext2fs_free_mem(&buf);
return retval;
}
diff --git a/e2fsprogs/ext2fs/test_io.c b/e2fsprogs/ext2fs/test_io.c
index d4b3653..45f9090 100644
--- a/e2fsprogs/ext2fs/test_io.c
+++ b/e2fsprogs/ext2fs/test_io.c
@@ -203,10 +203,8 @@ static errcode_t test_open(const char *name, int flags, io_channel *channel)
return 0;
cleanup:
- if (io)
- ext2fs_free_mem(&io);
- if (data)
- ext2fs_free_mem(&data);
+ ext2fs_free_mem(&io);
+ ext2fs_free_mem(&data);
return retval;
}
@@ -229,8 +227,7 @@ static errcode_t test_close(io_channel channel)
fclose(data->outfile);
ext2fs_free_mem(&channel->private_data);
- if (channel->name)
- ext2fs_free_mem(&channel->name);
+ ext2fs_free_mem(&channel->name);
ext2fs_free_mem(&channel);
return retval;
}
diff --git a/e2fsprogs/ext2fs/unix_io.c b/e2fsprogs/ext2fs/unix_io.c
index 36b2225..7f57afd 100644
--- a/e2fsprogs/ext2fs/unix_io.c
+++ b/e2fsprogs/ext2fs/unix_io.c
@@ -280,8 +280,7 @@ static void free_cache(struct unix_private_data *data)
cache->access_time = 0;
cache->dirty = 0;
cache->in_use = 0;
- if (cache->buf)
- ext2fs_free_mem(&cache->buf);
+ ext2fs_free_mem(&cache->buf);
cache->buf = 0;
}
}
@@ -461,8 +460,7 @@ cleanup:
free_cache(data);
ext2fs_free_mem(&data);
}
- if (io)
- ext2fs_free_mem(&io);
+ ext2fs_free_mem(&io);
return retval;
}
@@ -487,8 +485,7 @@ static errcode_t unix_close(io_channel channel)
free_cache(data);
ext2fs_free_mem(&channel->private_data);
- if (channel->name)
- ext2fs_free_mem(&channel->name);
+ ext2fs_free_mem(&channel->name);
ext2fs_free_mem(&channel);
return retval;
}