diff mbox series

[1/2] xfs_db: Fix uninicialized error variable

Message ID 20240530223819.135697-2-preichl@redhat.com (mailing list archive)
State Accepted, archived
Headers show
Series xfsprogs: Fix some issues found by checker | expand

Commit Message

Pavel Reichl May 30, 2024, 10:38 p.m. UTC
To silence redhat's covscan checker:

Error: UNINIT (CWE-457): [#def1] [important]
xfsprogs-6.4.0/db/hash.c:308:2: var_decl: Declaring variable "error" without initializer.
xfsprogs-6.4.0/db/hash.c:353:2: uninit_use: Using uninitialized value "error".

Signed-off-by: Pavel Reichl <preichl@redhat.com>
---
 db/hash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Darrick J. Wong May 30, 2024, 10:50 p.m. UTC | #1
On Fri, May 31, 2024 at 12:38:18AM +0200, Pavel Reichl wrote:
> To silence redhat's covscan checker:
> 
> Error: UNINIT (CWE-457): [#def1] [important]
> xfsprogs-6.4.0/db/hash.c:308:2: var_decl: Declaring variable "error" without initializer.
> xfsprogs-6.4.0/db/hash.c:353:2: uninit_use: Using uninitialized value "error".
> 
> Signed-off-by: Pavel Reichl <preichl@redhat.com>

Looks good,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  db/hash.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/db/hash.c b/db/hash.c
> index 05a94f24..9b3fdea6 100644
> --- a/db/hash.c
> +++ b/db/hash.c
> @@ -304,7 +304,7 @@ collide_xattrs(
>  	struct dup_table	*tab = NULL;
>  	xfs_dahash_t		old_hash;
>  	unsigned long		i;
> -	int			error;
> +	int			error = 0;
>  
>  	old_hash = libxfs_da_hashname((uint8_t *)name, namelen);
>  
> -- 
> 2.45.1
> 
>
Christoph Hellwig May 31, 2024, 7:49 a.m. UTC | #2
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/db/hash.c b/db/hash.c
index 05a94f24..9b3fdea6 100644
--- a/db/hash.c
+++ b/db/hash.c
@@ -304,7 +304,7 @@  collide_xattrs(
 	struct dup_table	*tab = NULL;
 	xfs_dahash_t		old_hash;
 	unsigned long		i;
-	int			error;
+	int			error = 0;
 
 	old_hash = libxfs_da_hashname((uint8_t *)name, namelen);