diff mbox series

[6/9] xfs_mdrestore: fix uninitialized variables in mdrestore main

Message ID 170069444236.1865809.11643710907133041679.stgit@frogsfrogsfrogs (mailing list archive)
State Superseded
Headers show
Series xfsprogs: minor fixes for 6.6 | expand

Commit Message

Darrick J. Wong Nov. 22, 2023, 11:07 p.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

Coverity complained about the "is fd a file?" flags being uninitialized.
Clean this up.

Coverity-id: 1554270
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 mdrestore/xfs_mdrestore.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Comments

Christoph Hellwig Nov. 23, 2023, 6:41 a.m. UTC | #1
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Chandan Babu R Nov. 24, 2023, 9:11 a.m. UTC | #2
On Wed, Nov 22, 2023 at 03:07:22 PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
>
> Coverity complained about the "is fd a file?" flags being uninitialized.
> Clean this up.
>

Looks good to me.

Reviewed-by: Chandan Babu R <chandanbabu@kernel.org>

> Coverity-id: 1554270
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> ---
>  mdrestore/xfs_mdrestore.c |    9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
>
>
> diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c
> index 2de177c6e3f..5dfc423493e 100644
> --- a/mdrestore/xfs_mdrestore.c
> +++ b/mdrestore/xfs_mdrestore.c
> @@ -472,11 +472,11 @@ main(
>  	union mdrestore_headers	headers;
>  	FILE			*src_f;
>  	char			*logdev = NULL;
> -	int			data_dev_fd;
> -	int			log_dev_fd;
> +	int			data_dev_fd = -1;
> +	int			log_dev_fd = -1;
>  	int			c;
> -	bool			is_data_dev_file;
> -	bool			is_log_dev_file;
> +	bool			is_data_dev_file = false;
> +	bool			is_log_dev_file = false;
>  
>  	mdrestore.show_progress = false;
>  	mdrestore.show_info = false;
> @@ -561,7 +561,6 @@ main(
>  	/* check and open data device */
>  	data_dev_fd = open_device(argv[optind], &is_data_dev_file);
>  
> -	log_dev_fd = -1;
>  	if (mdrestore.external_log)
>  		/* check and open log device */
>  		log_dev_fd = open_device(logdev, &is_log_dev_file);
diff mbox series

Patch

diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c
index 2de177c6e3f..5dfc423493e 100644
--- a/mdrestore/xfs_mdrestore.c
+++ b/mdrestore/xfs_mdrestore.c
@@ -472,11 +472,11 @@  main(
 	union mdrestore_headers	headers;
 	FILE			*src_f;
 	char			*logdev = NULL;
-	int			data_dev_fd;
-	int			log_dev_fd;
+	int			data_dev_fd = -1;
+	int			log_dev_fd = -1;
 	int			c;
-	bool			is_data_dev_file;
-	bool			is_log_dev_file;
+	bool			is_data_dev_file = false;
+	bool			is_log_dev_file = false;
 
 	mdrestore.show_progress = false;
 	mdrestore.show_info = false;
@@ -561,7 +561,6 @@  main(
 	/* check and open data device */
 	data_dev_fd = open_device(argv[optind], &is_data_dev_file);
 
-	log_dev_fd = -1;
 	if (mdrestore.external_log)
 		/* check and open log device */
 		log_dev_fd = open_device(logdev, &is_log_dev_file);