aboutsummaryrefslogtreecommitdiffstats
path: root/volumes.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2015-11-06 17:09:17 +0100
committerDavid Sterba <dsterba@suse.com>2015-11-13 18:24:30 +0100
commit7ae478d8af38d065c6435fda4c3e833aea05631b (patch)
tree7f09ea18a7aa5c204e24efe5674cdb173295ebff /volumes.c
parentb13197d68f659e9f52fff0506a0fd5b1e557f7d7 (diff)
downloadbtrfs-progs-7ae478d8af38d065c6435fda4c3e833aea05631b.tar.gz
btrfs-progs-7ae478d8af38d065c6435fda4c3e833aea05631b.tar.xz
btrfs-progs-7ae478d8af38d065c6435fda4c3e833aea05631b.zip
btrfs-progs: use on-stack buffer for btrfs_scan_one_device
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'volumes.c')
-rw-r--r--volumes.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/volumes.c b/volumes.c
index 83ddd16..00f3edf 100644
--- a/volumes.c
+++ b/volumes.c
@@ -252,21 +252,14 @@ int btrfs_scan_one_device(int fd, const char *path,
u64 *total_devs, u64 super_offset, int super_recover)
{
struct btrfs_super_block *disk_super;
- char *buf;
+ char buf[BTRFS_SUPER_INFO_SIZE];
int ret;
u64 devid;
- buf = malloc(4096);
- if (!buf) {
- ret = -ENOMEM;
- goto error;
- }
disk_super = (struct btrfs_super_block *)buf;
ret = btrfs_read_dev_super(fd, disk_super, super_offset, super_recover);
- if (ret < 0) {
- ret = -EIO;
- goto error_brelse;
- }
+ if (ret < 0)
+ return -EIO;
devid = btrfs_stack_device_id(&disk_super->dev_item);
if (btrfs_super_flags(disk_super) & BTRFS_SUPER_FLAG_METADUMP)
*total_devs = 1;
@@ -275,9 +268,6 @@ int btrfs_scan_one_device(int fd, const char *path,
ret = device_list_add(path, disk_super, devid, fs_devices_ret);
-error_brelse:
- free(buf);
-error:
return ret;
}