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 /btrfs-list.c | |
parent | 9c89f637a3d754ac401b7b6dabe5c7b8c336f848 (diff) | |
download | btrfs-progs-c47a831cd653fa4ef4979ae7007e60037eddcb37.tar.gz |
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 'btrfs-list.c')
-rw-r--r-- | btrfs-list.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/btrfs-list.c b/btrfs-list.c index d54de61..7529e11 100644 --- a/btrfs-list.c +++ b/btrfs-list.c @@ -226,13 +226,12 @@ struct btrfs_list_comparer_set *btrfs_list_alloc_comparer_set(void) size = sizeof(struct btrfs_list_comparer_set) + BTRFS_LIST_NCOMPS_INCREASE * sizeof(struct btrfs_list_comparer); - set = malloc(size); + set = calloc(1, size); if (!set) { fprintf(stderr, "memory allocation failed\n"); exit(1); } - memset(set, 0, size); set->total = BTRFS_LIST_NCOMPS_INCREASE; return set; @@ -474,12 +473,11 @@ static int add_root(struct root_lookup *root_lookup, if (!ret) return 0; - ri = malloc(sizeof(*ri)); + ri = calloc(1, sizeof(*ri)); if (!ri) { printf("memory allocation failed\n"); exit(1); } - memset(ri, 0, sizeof(*ri)); ri->root_id = root_id; if (name && name_len > 0) { @@ -1208,13 +1206,12 @@ struct btrfs_list_filter_set *btrfs_list_alloc_filter_set(void) size = sizeof(struct btrfs_list_filter_set) + BTRFS_LIST_NFILTERS_INCREASE * sizeof(struct btrfs_list_filter); - set = malloc(size); + set = calloc(1, size); if (!set) { fprintf(stderr, "memory allocation failed\n"); exit(1); } - memset(set, 0, size); set->total = BTRFS_LIST_NFILTERS_INCREASE; return set; |