Cleanup patch from Denis Vlasenko. Mostly variants of removing the if(x)
from before "if(x) free(x)".
This commit is contained in:
parent
93f2286e6e
commit
e7c43b66d7
@ -544,7 +544,6 @@ static void free_package(common_node_t *node)
|
||||
for (i = 0; i < node->num_of_edges; i++) {
|
||||
free(node->edge[i]);
|
||||
}
|
||||
if ( node->edge )
|
||||
free(node->edge);
|
||||
free(node);
|
||||
}
|
||||
|
@ -714,7 +714,7 @@ extern int uncompressStream(int src_fd, int dst_fd)
|
||||
} else {
|
||||
bb_error_msg("Decompression failed");
|
||||
}
|
||||
if(bd->dbuf) free(bd->dbuf);
|
||||
free(bd->dbuf);
|
||||
free(bd);
|
||||
free(outbuf);
|
||||
|
||||
|
@ -405,8 +405,8 @@ extern int unzip_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (verbosity == v_list) {
|
||||
printf(" -------- -------\n");
|
||||
printf("%9d %d files\n", total_size, total_entries);
|
||||
printf(" -------- -------\n"
|
||||
"%9d %d files\n", total_size, total_entries);
|
||||
}
|
||||
|
||||
return(EXIT_SUCCESS);
|
||||
|
@ -88,7 +88,6 @@ void blkid_put_cache(blkid_cache cache)
|
||||
}
|
||||
blkid_free_tag(tag);
|
||||
}
|
||||
if (cache->bic_filename)
|
||||
free(cache->bic_filename);
|
||||
|
||||
free(cache);
|
||||
|
@ -218,7 +218,6 @@ int main(int argc, char** argv)
|
||||
}
|
||||
printf("Looking for device 0x%04Lx\n", devno);
|
||||
devname = blkid_devno_to_devname(devno);
|
||||
if (devname)
|
||||
free(devname);
|
||||
return 0;
|
||||
}
|
||||
|
@ -96,9 +96,7 @@ 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);
|
||||
if (!cache) {
|
||||
blkid_put_cache(c);
|
||||
|
@ -148,7 +148,6 @@ int blkid_flush_cache(blkid_cache cache)
|
||||
}
|
||||
|
||||
errout:
|
||||
if (tmp)
|
||||
free(tmp);
|
||||
return ret;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
@ -112,7 +109,6 @@ 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);
|
||||
} else if (t) {
|
||||
if (!strcmp(t->bit_val, val)) {
|
||||
@ -165,11 +161,9 @@ int blkid_set_tag(blkid_dev dev, const char *name,
|
||||
return 0;
|
||||
|
||||
errout:
|
||||
if (t)
|
||||
blkid_free_tag(t);
|
||||
else if (val)
|
||||
if (!t)
|
||||
free(val);
|
||||
if (head)
|
||||
blkid_free_tag(head);
|
||||
return -BLKID_ERR_MEM;
|
||||
}
|
||||
|
@ -2036,10 +2036,7 @@ static struct dir_info *e2fsck_get_dir_info(e2fsck_t ctx, ext2_ino_t ino)
|
||||
*/
|
||||
static void e2fsck_free_dir_info(e2fsck_t ctx)
|
||||
{
|
||||
if (ctx->dir_info) {
|
||||
ext2fs_free_mem(&ctx->dir_info);
|
||||
ctx->dir_info = 0;
|
||||
}
|
||||
ctx->dir_info_size = 0;
|
||||
ctx->dir_info_count = 0;
|
||||
}
|
||||
@ -2178,13 +2175,9 @@ static void e2fsck_free_dx_dir_info(e2fsck_t ctx)
|
||||
if (ctx->dx_dir_info) {
|
||||
dir = ctx->dx_dir_info;
|
||||
for (i=0; i < ctx->dx_dir_info_count; i++) {
|
||||
if (dir->dx_block) {
|
||||
ext2fs_free_mem(&dir->dx_block);
|
||||
dir->dx_block = 0;
|
||||
}
|
||||
}
|
||||
ext2fs_free_mem(&ctx->dx_dir_info);
|
||||
ctx->dx_dir_info = 0;
|
||||
}
|
||||
ctx->dx_dir_info_size = 0;
|
||||
ctx->dx_dir_info_count = 0;
|
||||
@ -2245,7 +2238,6 @@ static void ea_refcount_free(ext2_refcount_t refcount)
|
||||
if (!refcount)
|
||||
return;
|
||||
|
||||
if (refcount->list)
|
||||
ext2fs_free_mem(&refcount->list);
|
||||
ext2fs_free_mem(&refcount);
|
||||
}
|
||||
@ -2259,32 +2251,22 @@ static errcode_t e2fsck_reset_context(e2fsck_t ctx)
|
||||
ctx->flags = 0;
|
||||
ctx->lost_and_found = 0;
|
||||
ctx->bad_lost_and_found = 0;
|
||||
if (ctx->inode_used_map) {
|
||||
ext2fs_free_inode_bitmap(ctx->inode_used_map);
|
||||
ctx->inode_used_map = 0;
|
||||
}
|
||||
if (ctx->inode_dir_map) {
|
||||
ext2fs_free_inode_bitmap(ctx->inode_dir_map);
|
||||
ctx->inode_dir_map = 0;
|
||||
}
|
||||
if (ctx->inode_reg_map) {
|
||||
ext2fs_free_inode_bitmap(ctx->inode_reg_map);
|
||||
ctx->inode_reg_map = 0;
|
||||
}
|
||||
if (ctx->block_found_map) {
|
||||
ext2fs_free_block_bitmap(ctx->block_found_map);
|
||||
ctx->block_found_map = 0;
|
||||
}
|
||||
if (ctx->inode_link_info) {
|
||||
ext2fs_free_icount(ctx->inode_link_info);
|
||||
ctx->inode_link_info = 0;
|
||||
}
|
||||
if (ctx->journal_io) {
|
||||
if (ctx->fs && ctx->fs->io != ctx->journal_io)
|
||||
io_channel_close(ctx->journal_io);
|
||||
ctx->journal_io = 0;
|
||||
}
|
||||
if (ctx->fs && ctx->fs->dblist) {
|
||||
if (ctx->fs) {
|
||||
ext2fs_free_dblist(ctx->fs->dblist);
|
||||
ctx->fs->dblist = 0;
|
||||
}
|
||||
@ -2292,54 +2274,29 @@ static errcode_t e2fsck_reset_context(e2fsck_t ctx)
|
||||
#ifdef ENABLE_HTREE
|
||||
e2fsck_free_dx_dir_info(ctx);
|
||||
#endif
|
||||
if (ctx->refcount) {
|
||||
ea_refcount_free(ctx->refcount);
|
||||
ctx->refcount = 0;
|
||||
}
|
||||
if (ctx->refcount_extra) {
|
||||
ea_refcount_free(ctx->refcount_extra);
|
||||
ctx->refcount_extra = 0;
|
||||
}
|
||||
if (ctx->block_dup_map) {
|
||||
ext2fs_free_block_bitmap(ctx->block_dup_map);
|
||||
ctx->block_dup_map = 0;
|
||||
}
|
||||
if (ctx->block_ea_map) {
|
||||
ext2fs_free_block_bitmap(ctx->block_ea_map);
|
||||
ctx->block_ea_map = 0;
|
||||
}
|
||||
if (ctx->inode_bb_map) {
|
||||
ext2fs_free_inode_bitmap(ctx->inode_bb_map);
|
||||
ctx->inode_bb_map = 0;
|
||||
}
|
||||
if (ctx->inode_bad_map) {
|
||||
ext2fs_free_inode_bitmap(ctx->inode_bad_map);
|
||||
ctx->inode_bad_map = 0;
|
||||
}
|
||||
if (ctx->inode_imagic_map) {
|
||||
ext2fs_free_inode_bitmap(ctx->inode_imagic_map);
|
||||
ctx->inode_imagic_map = 0;
|
||||
}
|
||||
if (ctx->dirs_to_hash) {
|
||||
ext2fs_u32_list_free(ctx->dirs_to_hash);
|
||||
ctx->dirs_to_hash = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Clear the array of invalid meta-data flags
|
||||
*/
|
||||
if (ctx->invalid_inode_bitmap_flag) {
|
||||
ext2fs_free_mem(&ctx->invalid_inode_bitmap_flag);
|
||||
ctx->invalid_inode_bitmap_flag = 0;
|
||||
}
|
||||
if (ctx->invalid_block_bitmap_flag) {
|
||||
ext2fs_free_mem(&ctx->invalid_block_bitmap_flag);
|
||||
ctx->invalid_block_bitmap_flag = 0;
|
||||
}
|
||||
if (ctx->invalid_inode_table_flag) {
|
||||
ext2fs_free_mem(&ctx->invalid_inode_table_flag);
|
||||
ctx->invalid_inode_table_flag = 0;
|
||||
}
|
||||
|
||||
/* Clear statistic counters */
|
||||
ctx->fs_directory_count = 0;
|
||||
@ -3118,7 +3075,6 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal)
|
||||
journal->j_superblock = (journal_superblock_t *)bh->b_data;
|
||||
|
||||
#ifdef USE_INODE_IO
|
||||
if (j_inode)
|
||||
ext2fs_free_mem(&j_inode);
|
||||
#endif
|
||||
|
||||
@ -3126,11 +3082,8 @@ static errcode_t e2fsck_get_journal(e2fsck_t ctx, journal_t **ret_journal)
|
||||
return 0;
|
||||
|
||||
errout:
|
||||
if (dev_fs)
|
||||
ext2fs_free_mem(&dev_fs);
|
||||
if (j_inode)
|
||||
ext2fs_free_mem(&j_inode);
|
||||
if (journal)
|
||||
ext2fs_free_mem(&journal);
|
||||
return retval;
|
||||
|
||||
@ -3368,10 +3321,8 @@ static void e2fsck_journal_release(e2fsck_t ctx, journal_t *journal,
|
||||
}
|
||||
|
||||
#ifndef USE_INODE_IO
|
||||
if (journal->j_inode)
|
||||
ext2fs_free_mem(&journal->j_inode);
|
||||
#endif
|
||||
if (journal->j_fs_dev)
|
||||
ext2fs_free_mem(&journal->j_fs_dev);
|
||||
ext2fs_free_mem(&journal);
|
||||
}
|
||||
@ -4346,7 +4297,6 @@ static __u64 ext2_max_sizes[EXT2_MAX_BLOCK_LOG_SIZE -
|
||||
static void unwind_pass1(void)
|
||||
{
|
||||
ext2fs_free_mem(&inodes_to_process);
|
||||
inodes_to_process = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -5086,10 +5036,8 @@ static void e2fsck_pass1(e2fsck_t ctx)
|
||||
handle_fs_bad_blocks(ctx);
|
||||
|
||||
/* We don't need the block_ea_map any more */
|
||||
if (ctx->block_ea_map) {
|
||||
ext2fs_free_block_bitmap(ctx->block_ea_map);
|
||||
ctx->block_ea_map = 0;
|
||||
}
|
||||
|
||||
if (ctx->flags & E2F_FLAG_RESIZE_INODE) {
|
||||
ext2fs_block_bitmap save_bmap;
|
||||
@ -7359,14 +7307,10 @@ static void e2fsck_pass2(e2fsck_t ctx)
|
||||
ext2fs_free_mem(&buf);
|
||||
ext2fs_free_dblist(fs->dblist);
|
||||
|
||||
if (ctx->inode_bad_map) {
|
||||
ext2fs_free_inode_bitmap(ctx->inode_bad_map);
|
||||
ctx->inode_bad_map = 0;
|
||||
}
|
||||
if (ctx->inode_reg_map) {
|
||||
ext2fs_free_inode_bitmap(ctx->inode_reg_map);
|
||||
ctx->inode_reg_map = 0;
|
||||
}
|
||||
|
||||
clear_problem_context(&pctx);
|
||||
if (ctx->large_files) {
|
||||
@ -8665,14 +8609,10 @@ static void e2fsck_pass3(e2fsck_t ctx)
|
||||
|
||||
abort_exit:
|
||||
e2fsck_free_dir_info(ctx);
|
||||
if (inode_loop_detect) {
|
||||
ext2fs_free_inode_bitmap(inode_loop_detect);
|
||||
inode_loop_detect = 0;
|
||||
}
|
||||
if (inode_done_map) {
|
||||
ext2fs_free_inode_bitmap(inode_done_map);
|
||||
inode_done_map = 0;
|
||||
}
|
||||
|
||||
#ifdef RESOURCE_TRACK
|
||||
if (ctx->options & E2F_OPT_TIME2) {
|
||||
@ -9497,7 +9437,6 @@ static void e2fsck_pass4(e2fsck_t ctx)
|
||||
ctx->inode_bb_map = 0;
|
||||
ext2fs_free_inode_bitmap(ctx->inode_imagic_map);
|
||||
ctx->inode_imagic_map = 0;
|
||||
if (buf)
|
||||
ext2fs_free_mem(&buf);
|
||||
#ifdef RESOURCE_TRACK
|
||||
if (ctx->options & E2F_OPT_TIME2) {
|
||||
@ -12360,9 +12299,7 @@ static errcode_t alloc_size_dir(ext2_filsys fs, struct out_dir *outdir,
|
||||
|
||||
static void free_out_dir(struct out_dir *outdir)
|
||||
{
|
||||
if (outdir->buf)
|
||||
free(outdir->buf);
|
||||
if (outdir->hashes)
|
||||
free(outdir->hashes);
|
||||
outdir->max = 0;
|
||||
outdir->num =0;
|
||||
@ -12872,13 +12809,9 @@ resort:
|
||||
}
|
||||
|
||||
retval = write_directory(ctx, fs, &outdir, ino, fd.compress);
|
||||
if (retval)
|
||||
goto errout;
|
||||
|
||||
errout:
|
||||
if (dir_buf)
|
||||
free(dir_buf);
|
||||
if (fd.harray)
|
||||
free(fd.harray);
|
||||
|
||||
free_out_dir(&outdir);
|
||||
@ -12957,7 +12890,6 @@ void e2fsck_rehash_directories(e2fsck_t ctx)
|
||||
if (!all_dirs)
|
||||
ext2fs_u32_list_iterate_end(iter);
|
||||
|
||||
if (ctx->dirs_to_hash)
|
||||
ext2fs_u32_list_free(ctx->dirs_to_hash);
|
||||
ctx->dirs_to_hash = 0;
|
||||
|
||||
@ -13676,7 +13608,6 @@ static void check_resize_inode(e2fsck_t ctx)
|
||||
}
|
||||
|
||||
cleanup:
|
||||
if (dind_buf)
|
||||
ext2fs_free_mem(&dind_buf);
|
||||
|
||||
}
|
||||
@ -14639,7 +14570,6 @@ blk_t get_backup_sb(e2fsck_t ctx, ext2_filsys fs, const char *name,
|
||||
cleanup:
|
||||
if (io)
|
||||
io_channel_close(io);
|
||||
if (buf)
|
||||
ext2fs_free_mem(&buf);
|
||||
return (ret_sb);
|
||||
}
|
||||
|
@ -257,7 +257,6 @@ 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);
|
||||
if ((retval == 0) && (blocks_alloc || inode_dirty)) {
|
||||
inode->i_blocks += (blocks_alloc * fs->blocksize) / 512;
|
||||
|
@ -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;
|
||||
}
|
||||
retval = ext2fs_init_dblist(fs, 0);
|
||||
if (retval)
|
||||
return retval;
|
||||
|
@ -186,11 +186,9 @@ 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);
|
||||
}
|
||||
if (brel->name)
|
||||
ext2fs_free_mem(&brel->name);
|
||||
ext2fs_free_mem(&brel);
|
||||
return 0;
|
||||
|
@ -99,7 +99,6 @@ 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);
|
||||
return retval;
|
||||
}
|
||||
|
@ -73,7 +73,6 @@ 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);
|
||||
return retval;
|
||||
@ -197,7 +196,6 @@ 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);
|
||||
|
||||
|
@ -30,24 +30,16 @@ 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);
|
||||
fs->badblocks = 0;
|
||||
|
||||
if (fs->dblist)
|
||||
ext2fs_free_dblist(fs->dblist);
|
||||
|
||||
if (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);
|
||||
}
|
||||
|
||||
@ -100,9 +86,7 @@ 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);
|
||||
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);
|
||||
}
|
||||
|
||||
@ -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;
|
||||
if (dblist->fs && dblist->fs->dblist == dblist)
|
||||
dblist->fs->dblist = 0;
|
||||
dblist->magic = 0;
|
||||
|
@ -132,7 +132,6 @@ 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);
|
||||
return retval;
|
||||
}
|
||||
|
@ -59,11 +59,8 @@ 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);
|
||||
}
|
||||
|
@ -371,7 +371,6 @@ errcode_t ext2fs_image_bitmap_read(ext2_filsys fs, int fd, int flags)
|
||||
|
||||
retval = 0;
|
||||
errout:
|
||||
if (buf)
|
||||
free(buf);
|
||||
return (retval);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -309,7 +309,6 @@ 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);
|
||||
ma->ref_entries[(unsigned) new] = ma->ref_entries[(unsigned) old];
|
||||
|
||||
@ -332,7 +331,6 @@ 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);
|
||||
ma->orig_map[ma->entries[(unsigned) old].orig] = 0;
|
||||
|
||||
@ -352,20 +350,16 @@ 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);
|
||||
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);
|
||||
}
|
||||
ext2fs_free_mem(&ma);
|
||||
}
|
||||
if (irel->name)
|
||||
ext2fs_free_mem(&irel->name);
|
||||
ext2fs_free_mem(&irel);
|
||||
return 0;
|
||||
|
@ -133,7 +133,6 @@ 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);
|
||||
return retval;
|
||||
|
||||
|
@ -61,7 +61,6 @@ 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);
|
||||
return retval;
|
||||
}
|
||||
|
@ -163,7 +163,6 @@ 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);
|
||||
sprintf(buf, "block bitmap for %s", fs->device_name);
|
||||
retval = ext2fs_allocate_block_bitmap(fs, buf, &fs->block_map);
|
||||
@ -172,7 +171,6 @@ 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);
|
||||
sprintf(buf, "inode bitmap for %s", fs->device_name);
|
||||
retval = ext2fs_allocate_inode_bitmap(fs, buf, &fs->inode_map);
|
||||
@ -247,13 +245,10 @@ 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);
|
||||
return retval;
|
||||
}
|
||||
|
@ -203,9 +203,7 @@ 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);
|
||||
return retval;
|
||||
}
|
||||
@ -229,7 +227,6 @@ 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);
|
||||
return retval;
|
||||
|
@ -280,7 +280,6 @@ 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);
|
||||
cache->buf = 0;
|
||||
}
|
||||
@ -461,7 +460,6 @@ cleanup:
|
||||
free_cache(data);
|
||||
ext2fs_free_mem(&data);
|
||||
}
|
||||
if (io)
|
||||
ext2fs_free_mem(&io);
|
||||
return retval;
|
||||
}
|
||||
@ -487,7 +485,6 @@ 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);
|
||||
return retval;
|
||||
|
@ -556,11 +556,9 @@ static void add_cmd(char *cmdstr)
|
||||
}
|
||||
|
||||
/* If we glued multiple lines together, free the memory. */
|
||||
if(add_cmd_line) {
|
||||
free(add_cmd_line);
|
||||
add_cmd_line=NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Append to a string, reallocating memory as necessary. */
|
||||
|
||||
|
@ -4231,9 +4231,8 @@ out:
|
||||
#ifdef CONFIG_FEATURE_CLEAN_UP
|
||||
if(fp)
|
||||
fclose(fp);
|
||||
if(tmp1) {
|
||||
free(tmp1);
|
||||
} else {
|
||||
if(!tmp1) {
|
||||
free(m_name);
|
||||
}
|
||||
free(m_filename);
|
||||
|
@ -1356,16 +1356,15 @@ extern int ifupdown_main(int argc, char **argv)
|
||||
} else {
|
||||
/* Remove an interface from the linked list */
|
||||
if (iface_state) {
|
||||
/* This needs to be done better */
|
||||
const llist_t *link = iface_state->link;
|
||||
free(iface_state->data);
|
||||
free(iface_state->link);
|
||||
if (iface_state->link) {
|
||||
iface_state->data = iface_state->link->data;
|
||||
iface_state->link = iface_state->link->link;
|
||||
} else {
|
||||
iface_state->data = NULL;
|
||||
iface_state->link = NULL;
|
||||
if (link) {
|
||||
iface_state->data = link->data;
|
||||
iface_state->link = link->link;
|
||||
}
|
||||
free(link);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -413,7 +413,6 @@ static void freeconfig (servtab_t *cp)
|
||||
free (cp->se_group);
|
||||
free (cp->se_server);
|
||||
for (i = 0; i < MAXARGV; i++)
|
||||
if (cp->se_argv[i])
|
||||
free (cp->se_argv[i]);
|
||||
}
|
||||
|
||||
|
@ -902,10 +902,8 @@ gethostinfo(const char *host)
|
||||
static void
|
||||
freehostinfo(struct hostinfo *hi)
|
||||
{
|
||||
if (hi->name != NULL) {
|
||||
free(hi->name);
|
||||
hi->name = NULL;
|
||||
}
|
||||
free((char *)hi->addrs);
|
||||
free((char *)hi);
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ int main(int argc, char *argv[])
|
||||
case 'c':
|
||||
if (no_clientid) show_usage();
|
||||
len = strlen(optarg) > 255 ? 255 : strlen(optarg);
|
||||
if (client_config.clientid) free(client_config.clientid);
|
||||
free(client_config.clientid);
|
||||
client_config.clientid = xmalloc(len + 2);
|
||||
client_config.clientid[OPT_CODE] = DHCP_CLIENT_ID;
|
||||
client_config.clientid[OPT_LEN] = len;
|
||||
@ -230,7 +230,7 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
case 'V':
|
||||
len = strlen(optarg) > 255 ? 255 : strlen(optarg);
|
||||
if (client_config.vendorclass) free(client_config.vendorclass);
|
||||
free(client_config.vendorclass);
|
||||
client_config.vendorclass = xmalloc(len + 2);
|
||||
client_config.vendorclass[OPT_CODE] = DHCP_VENDOR;
|
||||
client_config.vendorclass[OPT_LEN] = len;
|
||||
@ -245,7 +245,7 @@ int main(int argc, char *argv[])
|
||||
case 'h':
|
||||
case 'H':
|
||||
len = strlen(optarg) > 255 ? 255 : strlen(optarg);
|
||||
if (client_config.hostname) free(client_config.hostname);
|
||||
free(client_config.hostname);
|
||||
client_config.hostname = xmalloc(len + 2);
|
||||
client_config.hostname[OPT_CODE] = DHCP_HOST_NAME;
|
||||
client_config.hostname[OPT_LEN] = len;
|
||||
@ -253,7 +253,7 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
case 'F':
|
||||
len = strlen(optarg) > 255 ? 255 : strlen(optarg);
|
||||
if (client_config.fqdn) free(client_config.fqdn);
|
||||
free(client_config.fqdn);
|
||||
client_config.fqdn = xmalloc(len + 5);
|
||||
client_config.fqdn[OPT_CODE] = DHCP_FQDN;
|
||||
client_config.fqdn[OPT_LEN] = len + 3;
|
||||
|
@ -62,7 +62,7 @@ static int read_str(const char *line, void *arg)
|
||||
{
|
||||
char **dest = arg;
|
||||
|
||||
if (*dest) free(*dest);
|
||||
free(*dest);
|
||||
*dest = strdup(line);
|
||||
|
||||
return 1;
|
||||
|
@ -102,7 +102,6 @@ int conf_read(const char *name)
|
||||
case S_INT:
|
||||
case S_HEX:
|
||||
case S_STRING:
|
||||
if (sym->user.val)
|
||||
free(sym->user.val);
|
||||
default:
|
||||
sym->user.val = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user