summaryrefslogtreecommitdiff
path: root/btrfs-image.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2015-09-01 15:10:48 +0200
committerDavid Sterba <dsterba@suse.com>2015-09-02 17:46:30 +0200
commitc4123e1848db8066e5fed55545a334d3377c369f (patch)
treee31e1ce5077482327418a22de0e2a22b5da59ca6 /btrfs-image.c
parent2bac679058678b64dae15cc4905603423604736e (diff)
downloadbtrfs-progs-c4123e1848db8066e5fed55545a334d3377c369f.tar.gz
btrfs-progs: use on-stack buffer for superblock
In update_disk_super_on_device,the buffer size is small, allocate it onstack and get rid of one error path. Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'btrfs-image.c')
-rw-r--r--btrfs-image.c10
1 files changed, 1 insertions, 9 deletions
diff --git a/btrfs-image.c b/btrfs-image.c
index 18ad398..630fdf8 100644
--- a/btrfs-image.c
+++ b/btrfs-image.c
@@ -2588,7 +2588,7 @@ static int update_disk_super_on_device(struct btrfs_fs_info *info,
char fs_uuid[BTRFS_UUID_SIZE];
u64 devid, type, io_align, io_width;
u64 sector_size, total_bytes, bytes_used;
- char *buf = NULL;
+ char buf[BTRFS_SUPER_INFO_SIZE];
int fp = -1;
int ret;
@@ -2636,13 +2636,6 @@ static int update_disk_super_on_device(struct btrfs_fs_info *info,
goto out;
}
- buf = malloc(BTRFS_SUPER_INFO_SIZE);
- if (!buf) {
- ret = -ENOMEM;
- close(fp);
- return ret;
- }
-
memcpy(buf, info->super_copy, BTRFS_SUPER_INFO_SIZE);
disk_super = (struct btrfs_super_block *)buf;
@@ -2672,7 +2665,6 @@ static int update_disk_super_on_device(struct btrfs_fs_info *info,
write_backup_supers(fp, (u8 *)buf);
out:
- free(buf);
if (fp != -1)
close(fp);
return ret;