diff options
author | Silvio Fricke <silvio.fricke@gmail.com> | 2015-09-29 19:10:36 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2015-10-21 14:29:26 +0200 |
commit | c47a831cd653fa4ef4979ae7007e60037eddcb37 (patch) | |
tree | 69d07646892cda8a71072e8b7920a6afac6ccaec /disk-io.c | |
parent | 9c89f637a3d754ac401b7b6dabe5c7b8c336f848 (diff) |
btrfs-progs: use calloc instead of malloc+memset
This patch is generated from a coccinelle semantic patch:
identifier t;
expression e;
statement s;
@@
-t = malloc(e);
+t = calloc(1, e);
(
if (!t) s
|
if (t == NULL) s
|
)
-memset(t, 0, e);
Signed-off-by: Silvio Fricke <silvio.fricke@gmail.com>
[squashed patches into one]
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'disk-io.c')
-rw-r--r-- | disk-io.c | 7 |
1 files changed, 2 insertions, 5 deletions
@@ -698,10 +698,9 @@ struct btrfs_root *btrfs_read_fs_root_no_cache(struct btrfs_fs_info *fs_info, u32 blocksize; int ret = 0; - root = malloc(sizeof(*root)); + root = calloc(1, sizeof(*root)); if (!root) return ERR_PTR(-ENOMEM); - memset(root, 0, sizeof(*root)); if (location->offset == (u64)-1) { ret = find_and_setup_root(tree_root, fs_info, location->objectid, root); @@ -829,12 +828,10 @@ struct btrfs_fs_info *btrfs_new_fs_info(int writable, u64 sb_bytenr) { struct btrfs_fs_info *fs_info; - fs_info = malloc(sizeof(struct btrfs_fs_info)); + fs_info = calloc(1, sizeof(struct btrfs_fs_info)); if (!fs_info) return NULL; - memset(fs_info, 0, sizeof(struct btrfs_fs_info)); - 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)); |