btrfs-progs: remove NULL-ptr judge before free for btrfs-progs

free(3) already checks the pointer for NULL, no need to do it
on your own. This patch make the change globally.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
master
Gui Hecheng 2013-12-12 18:41:07 +08:00 committed by Chris Mason
parent e3c9596d3f
commit 3cae13ee93
6 changed files with 17 additions and 37 deletions

View File

@ -547,8 +547,7 @@ static int create_file_extents(struct btrfs_trans_handle *trans,
data.first_block, data.checksum);
}
fail:
if (buffer)
free(buffer);
free(buffer);
return ret;
error:
fprintf(stderr, "ext2fs_block_iterate2: %s\n", error_message(err));
@ -785,8 +784,7 @@ static int copy_single_xattr(struct btrfs_trans_handle *trans,
ret = btrfs_insert_xattr_item(trans, root, namebuf, name_len,
data, datalen, objectid);
out:
if (databuf)
free(databuf);
free(databuf);
return ret;
}
@ -892,8 +890,7 @@ static int copy_extended_attrs(struct btrfs_trans_handle *trans,
entry = EXT2_EXT_ATTR_NEXT(entry);
}
out:
if (buffer != NULL)
free(buffer);
free(buffer);
if ((void *)ext2_inode != inode_buf)
free(ext2_inode);
return ret;

View File

@ -399,8 +399,7 @@ static int update_root(struct root_lookup *root_lookup,
if (!ri || ri->root_id != root_id)
return -ENOENT;
if (name && name_len > 0) {
if (ri->name)
free(ri->name);
free(ri->name);
ri->name = malloc(name_len + 1);
if (!ri->name) {
@ -515,15 +514,9 @@ static void __free_root_info(struct rb_node *node)
struct root_info *ri;
ri = rb_entry(node, struct root_info, rb_node);
if (ri->name)
free(ri->name);
if (ri->path)
free(ri->path);
if (ri->full_path)
free(ri->full_path);
free(ri->name);
free(ri->path);
free(ri->full_path);
free(ri);
}

View File

@ -949,22 +949,16 @@ static int cmd_subvol_show(int argc, char **argv)
1, raw_prefix);
/* clean up */
if (get_ri.path)
free(get_ri.path);
if (get_ri.name)
free(get_ri.name);
if (get_ri.full_path)
free(get_ri.full_path);
if (filter_set)
btrfs_list_free_filter_set(filter_set);
free(get_ri.path);
free(get_ri.name);
free(get_ri.full_path);
btrfs_list_free_filter_set(filter_set);
out:
close_file_or_dir(fd, dirstream1);
close_file_or_dir(mntfd, dirstream2);
if (mnt)
free(mnt);
if (fullpath)
free(fullpath);
free(mnt);
free(fullpath);
return !!ret;
}

View File

@ -781,8 +781,7 @@ void __btrfs_remove_free_space_cache(struct btrfs_free_space_ctl *ctl)
while ((node = rb_last(&ctl->free_space_offset)) != NULL) {
info = rb_entry(node, struct btrfs_free_space, offset_index);
unlink_free_space(ctl, info);
if (info->bitmap)
free(info->bitmap);
free(info->bitmap);
free(info);
}
}

3
mkfs.c
View File

@ -721,8 +721,7 @@ again:
goto again;
end:
if (eb)
free(eb);
free(eb);
close(fd);
return ret;
}

View File

@ -1267,13 +1267,11 @@ int __btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw,
again:
ce = search_cache_extent(&map_tree->cache_tree, logical);
if (!ce) {
if (multi)
kfree(multi);
kfree(multi);
return -ENOENT;
}
if (ce->start > logical || ce->start + ce->size < logical) {
if (multi)
kfree(multi);
kfree(multi);
return -ENOENT;
}