summaryrefslogtreecommitdiff
path: root/qgroup.c
diff options
context:
space:
mode:
authorSilvio Fricke <silvio.fricke@gmail.com>2015-09-29 19:10:36 +0200
committerDavid Sterba <dsterba@suse.com>2015-10-21 14:29:26 +0200
commitc47a831cd653fa4ef4979ae7007e60037eddcb37 (patch)
tree69d07646892cda8a71072e8b7920a6afac6ccaec /qgroup.c
parent9c89f637a3d754ac401b7b6dabe5c7b8c336f848 (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 'qgroup.c')
-rw-r--r--qgroup.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/qgroup.c b/qgroup.c
index ec9a3ac2..99fddead 100644
--- a/qgroup.c
+++ b/qgroup.c
@@ -436,13 +436,12 @@ struct btrfs_qgroup_comparer_set *btrfs_qgroup_alloc_comparer_set(void)
size = sizeof(struct btrfs_qgroup_comparer_set) +
BTRFS_QGROUP_NCOMPS_INCREASE *
sizeof(struct btrfs_qgroup_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_QGROUP_NCOMPS_INCREASE;
return set;
@@ -644,12 +643,11 @@ static int add_qgroup(struct qgroup_lookup *qgroup_lookup, u64 qgroupid,
if (!ret)
return 0;
- bq = malloc(sizeof(*bq));
+ bq = calloc(1, sizeof(*bq));
if (!bq) {
printf("memory allocation failed\n");
exit(1);
}
- memset(bq, 0, sizeof(*bq));
if (qgroupid) {
bq->qgroupid = qgroupid;
INIT_LIST_HEAD(&bq->qgroups);
@@ -813,12 +811,11 @@ struct btrfs_qgroup_filter_set *btrfs_qgroup_alloc_filter_set(void)
size = sizeof(struct btrfs_qgroup_filter_set) +
BTRFS_QGROUP_NFILTERS_INCREASE *
sizeof(struct btrfs_qgroup_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_QGROUP_NFILTERS_INCREASE;
return set;