From 36ac098aaea8026dd7fd5f48ffa97b444556a305 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Tue, 16 Jun 2015 15:15:51 +0200 Subject: btrfs-progs: receive: use static buffer for root_subvol_path Signed-off-by: David Sterba --- cmds-receive.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'cmds-receive.c') diff --git a/cmds-receive.c b/cmds-receive.c index 4148be2c..eaccc8c3 100644 --- a/cmds-receive.c +++ b/cmds-receive.c @@ -1038,7 +1038,7 @@ static int do_receive(struct btrfs_receive *r, const char *tomnt, u64 subvol_id; int ret; char *dest_dir_full_path; - char *root_subvol_path; + char root_subvol_path[PATH_MAX]; int end = 0; dest_dir_full_path = realpath(tomnt, NULL); @@ -1096,14 +1096,7 @@ static int do_receive(struct btrfs_receive *r, const char *tomnt, goto out; } - root_subvol_path = malloc(PATH_MAX); - if (!root_subvol_path) { - ret = -ENOMEM; - fprintf(stderr, "ERROR: couldn't allocate buffer for the root " - "subvol path\n"); - goto out; - } - + root_subvol_path[0] = 0; ret = btrfs_subvolid_resolve(r->mnt_fd, root_subvol_path, PATH_MAX, subvol_id); if (ret) { @@ -1117,8 +1110,6 @@ static int do_receive(struct btrfs_receive *r, const char *tomnt, */ if (strlen(root_subvol_path)) r->full_root_path = root_subvol_path; - else - free(root_subvol_path); if (r->dest_dir_chroot) { if (chroot(dest_dir_full_path)) { @@ -1204,10 +1195,7 @@ out: close(r->dest_dir_fd); r->dest_dir_fd = -1; } - if (r->full_root_path) { - free(r->full_root_path); - r->full_root_path = NULL; - } + return ret; } -- cgit v1.2.3