2014-11-03 14:17:26 +01:00
|
|
|
From 5a44a4939129de6edb249c03133e5db347739643 Mon Sep 17 00:00:00 2001
|
2014-05-02 16:21:40 +02:00
|
|
|
From: David Sterba <dsterba@suse.cz>
|
|
|
|
Date: Thu, 24 Apr 2014 18:37:50 +0200
|
2014-11-03 14:17:26 +01:00
|
|
|
Subject: [PATCH 12/42] btrfs-progs: zero out structures before calling ioctl
|
2014-05-02 16:21:40 +02:00
|
|
|
|
|
|
|
Signed-off-by: David Sterba <dsterba@suse.cz>
|
|
|
|
---
|
|
|
|
cmds-fi-disk_usage.c | 6 +++---
|
|
|
|
1 file changed, 3 insertions(+), 3 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
|
2014-11-03 14:17:26 +01:00
|
|
|
index 8bc4f58fee0b..f984be838e3b 100644
|
2014-05-02 16:21:40 +02:00
|
|
|
--- a/cmds-fi-disk_usage.c
|
|
|
|
+++ b/cmds-fi-disk_usage.c
|
|
|
|
@@ -248,7 +248,7 @@ static struct btrfs_ioctl_space_args *load_space_info(int fd, char *path)
|
|
|
|
struct btrfs_ioctl_space_args *sargs = 0, *sargs_orig = 0;
|
|
|
|
int e, ret, count;
|
|
|
|
|
|
|
|
- sargs_orig = sargs = malloc(sizeof(struct btrfs_ioctl_space_args));
|
|
|
|
+ sargs_orig = sargs = calloc(1, sizeof(struct btrfs_ioctl_space_args));
|
|
|
|
if (!sargs) {
|
|
|
|
fprintf(stderr, "ERROR: not enough memory\n");
|
|
|
|
return NULL;
|
|
|
|
@@ -476,15 +476,15 @@ int load_device_info(int fd, struct device_info **device_info_ptr,
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
- info = malloc(sizeof(struct device_info) * fi_args.num_devices);
|
|
|
|
+ info = calloc(fi_args.num_devices, sizeof(struct device_info));
|
|
|
|
if (!info) {
|
|
|
|
fprintf(stderr, "ERROR: not enough memory\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0, ndevs = 0 ; i <= fi_args.max_id ; i++) {
|
|
|
|
-
|
|
|
|
BUG_ON(ndevs >= fi_args.num_devices);
|
|
|
|
+ memset(&dev_info, 0, sizeof(dev_info));
|
|
|
|
ret = get_device_info(fd, i, &dev_info);
|
|
|
|
|
|
|
|
if (ret == -ENODEV)
|
|
|
|
--
|
2014-11-03 14:17:26 +01:00
|
|
|
2.1.1
|
2014-05-02 16:21:40 +02:00
|
|
|
|