aboutsummaryrefslogtreecommitdiffstats
path: root/disk-io.c
diff options
context:
space:
mode:
authorOmar Sandoval <osandov@fb.com>2015-09-13 23:08:22 -0700
committerDavid Sterba <dsterba@suse.com>2015-09-14 22:04:02 +0200
commitf18085fd88f05ae8b608c5bd307007e6623696aa (patch)
treed4d44b03ace1732cbd637c29244bb5d38787cd14 /disk-io.c
parentd17313dd4bc57a536256bc05841b00f3ad05c21b (diff)
downloadbtrfs-progs-f18085fd88f05ae8b608c5bd307007e6623696aa.tar.gz
btrfs-progs-f18085fd88f05ae8b608c5bd307007e6623696aa.tar.xz
btrfs-progs-f18085fd88f05ae8b608c5bd307007e6623696aa.zip
btrfs-progs: use calloc instead of malloc+memset for tree roots
Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'disk-io.c')
-rw-r--r--disk-io.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/disk-io.c b/disk-io.c
index 1d48893..8496ade 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -833,13 +833,13 @@ struct btrfs_fs_info *btrfs_new_fs_info(int writable, u64 sb_bytenr)
memset(fs_info, 0, sizeof(struct btrfs_fs_info));
- fs_info->tree_root = malloc(sizeof(struct btrfs_root));
- fs_info->extent_root = malloc(sizeof(struct btrfs_root));
- fs_info->chunk_root = malloc(sizeof(struct btrfs_root));
- fs_info->dev_root = malloc(sizeof(struct btrfs_root));
- fs_info->csum_root = malloc(sizeof(struct btrfs_root));
- fs_info->quota_root = malloc(sizeof(struct btrfs_root));
- fs_info->super_copy = malloc(BTRFS_SUPER_INFO_SIZE);
+ fs_info->tree_root = calloc(1, sizeof(struct btrfs_root));
+ fs_info->extent_root = calloc(1, sizeof(struct btrfs_root));
+ fs_info->chunk_root = calloc(1, sizeof(struct btrfs_root));
+ fs_info->dev_root = calloc(1, sizeof(struct btrfs_root));
+ fs_info->csum_root = calloc(1, sizeof(struct btrfs_root));
+ fs_info->quota_root = calloc(1, sizeof(struct btrfs_root));
+ fs_info->super_copy = calloc(1, BTRFS_SUPER_INFO_SIZE);
if (!fs_info->tree_root || !fs_info->extent_root ||
!fs_info->chunk_root || !fs_info->dev_root ||
@@ -847,14 +847,6 @@ struct btrfs_fs_info *btrfs_new_fs_info(int writable, u64 sb_bytenr)
!fs_info->super_copy)
goto free_all;
- memset(fs_info->super_copy, 0, BTRFS_SUPER_INFO_SIZE);
- memset(fs_info->tree_root, 0, sizeof(struct btrfs_root));
- memset(fs_info->extent_root, 0, sizeof(struct btrfs_root));
- memset(fs_info->chunk_root, 0, sizeof(struct btrfs_root));
- memset(fs_info->dev_root, 0, sizeof(struct btrfs_root));
- memset(fs_info->csum_root, 0, sizeof(struct btrfs_root));
- memset(fs_info->quota_root, 0, sizeof(struct btrfs_root));
-
extent_io_tree_init(&fs_info->extent_cache);
extent_io_tree_init(&fs_info->free_space_cache);
extent_io_tree_init(&fs_info->block_group_cache);