diff options
author | David Sterba <dsterba@suse.com> | 2017-01-30 14:20:30 +0100 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2017-03-08 13:00:46 +0100 |
commit | 4927a9b268710e219bb1bd62ae74340f5ee3891c (patch) | |
tree | c48fe60f5a357a10d0f5166b15b2e387cb1e35e6 /convert | |
parent | 6b74f2fbe308cc2c57fc1199395e06e1932ed9af (diff) |
btrfs-progs: convert: use on-stack buffer for subvol name dir
Get rid of dynamic allocation.
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'convert')
-rw-r--r-- | convert/main.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/convert/main.c b/convert/main.c index b0d72d3e..5edb297e 100644 --- a/convert/main.c +++ b/convert/main.c @@ -1184,7 +1184,7 @@ static int do_convert(const char *devname, int datacsum, int packing, struct btrfs_root *image_root; struct btrfs_convert_context cctx; struct btrfs_key key; - char *subvol_name = NULL; + char subvol_name[SOURCE_FS_NAME_LEN + 8]; struct task_ctx ctx; char features_buf[64]; struct btrfs_mkfs_config mkfs_cfg; @@ -1252,12 +1252,8 @@ static int do_convert(const char *devname, int datacsum, int packing, } printf("creating %s image file\n", cctx.convert_ops->name); - ret = asprintf(&subvol_name, "%s_saved", cctx.convert_ops->name); - if (ret < 0) { - error("memory allocation failure for subvolume name: %s_saved", + snprintf(subvol_name, sizeof(subvol_name), "%s_saved", cctx.convert_ops->name); - goto fail; - } key.objectid = CONV_IMAGE_SUBVOL_OBJECTID; key.offset = (u64)-1; key.type = BTRFS_ROOT_ITEM_KEY; @@ -1298,8 +1294,6 @@ static int do_convert(const char *devname, int datacsum, int packing, goto fail; } - free(subvol_name); - memset(root->fs_info->super_copy->label, 0, BTRFS_LABEL_SIZE); if (copylabel == 1) { __strncpy_null(root->fs_info->super_copy->label, |