diff mbox series

[1/3] btrfs: image: remove the dead stat() call

Message ID 20210326125047.123694-2-wqu@suse.com (mailing list archive)
State New
Headers show
Series btrfs-progs: image: make restored image file to be properly enlarged | expand

Commit Message

Qu Wenruo March 26, 2021, 12:50 p.m. UTC
In restore_metadump(), we call stat() but never uses the result get.

This call site is left by some code refactor, as the stat() call is now
moved into fixup_device_size().

So we can safely remove the call.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 image/main.c | 8 --------
 1 file changed, 8 deletions(-)

Comments

Su Yue March 26, 2021, 2:08 p.m. UTC | #1
On Fri 26 Mar 2021 at 20:50, Qu Wenruo <wqu@suse.com> wrote:

> In restore_metadump(), we call stat() but never uses the result 
> get.
>
> This call site is left by some code refactor, as the stat() call 
> is now
> moved into fixup_device_size().
>
fixup_device_size() already calls fstat() on out_fd.

Reviewed-by: Su Yue <l@damenly.su>


> So we can safely remove the call.
>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
>  image/main.c | 8 --------
>  1 file changed, 8 deletions(-)
>
> diff --git a/image/main.c b/image/main.c
> index 48070e52c21f..24393188e5e3 100644
> --- a/image/main.c
> +++ b/image/main.c
> @@ -2690,7 +2690,6 @@ static int restore_metadump(const char 
> *input, FILE *out, int old_restore,
>  	if (!ret && !multi_devices && !old_restore &&
>  	    btrfs_super_num_devices(mdrestore.original_super) != 1) {
>  		struct btrfs_root *root;
> -		struct stat st;
>
>  		root = open_ctree_fd(fileno(out), target, 0,
>  					  OPEN_CTREE_PARTIAL |
> @@ -2703,13 +2702,6 @@ static int restore_metadump(const char 
> *input, FILE *out, int old_restore,
>  		}
>  		info = root->fs_info;
>
> -		if (stat(target, &st)) {
> -			error("stat %s failed: %m", target);
> -			close_ctree(info->chunk_root);
> -			free(cluster);
> -			return 1;
> -		}
> -
>  		ret = fixup_chunks_and_devices(info, &mdrestore, 
>  fileno(out));
>  		close_ctree(info->chunk_root);
>  		if (ret)
diff mbox series

Patch

diff --git a/image/main.c b/image/main.c
index 48070e52c21f..24393188e5e3 100644
--- a/image/main.c
+++ b/image/main.c
@@ -2690,7 +2690,6 @@  static int restore_metadump(const char *input, FILE *out, int old_restore,
 	if (!ret && !multi_devices && !old_restore &&
 	    btrfs_super_num_devices(mdrestore.original_super) != 1) {
 		struct btrfs_root *root;
-		struct stat st;
 
 		root = open_ctree_fd(fileno(out), target, 0,
 					  OPEN_CTREE_PARTIAL |
@@ -2703,13 +2702,6 @@  static int restore_metadump(const char *input, FILE *out, int old_restore,
 		}
 		info = root->fs_info;
 
-		if (stat(target, &st)) {
-			error("stat %s failed: %m", target);
-			close_ctree(info->chunk_root);
-			free(cluster);
-			return 1;
-		}
-
 		ret = fixup_chunks_and_devices(info, &mdrestore, fileno(out));
 		close_ctree(info->chunk_root);
 		if (ret)