diff mbox

[v2] xfs: scrub: avoid uninitialized return code

Message ID 20171102195306.GA4911@magnolia (mailing list archive)
State Accepted
Headers show

Commit Message

Darrick J. Wong Nov. 2, 2017, 7:53 p.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

The newly added xfs_scrub_da_btree_block() function has one code path
that returns the 'error' variable without initializing it first, as
shown by this compiler warning:

fs/xfs/scrub/dabtree.c: In function 'xfs_scrub_da_btree_block':
fs/xfs/scrub/dabtree.c:462:9: error: 'error' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Return zero since the caller will exit the scrub code if we don't produce a
buffer pointer.

Fixes: 7c4a07a424c1 ("xfs: scrub directory/attribute btrees")
Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/scrub/dabtree.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Brian Foster Nov. 2, 2017, 7:57 p.m. UTC | #1
On Thu, Nov 02, 2017 at 12:53:06PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> The newly added xfs_scrub_da_btree_block() function has one code path
> that returns the 'error' variable without initializing it first, as
> shown by this compiler warning:
> 
> fs/xfs/scrub/dabtree.c: In function 'xfs_scrub_da_btree_block':
> fs/xfs/scrub/dabtree.c:462:9: error: 'error' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 
> Return zero since the caller will exit the scrub code if we don't produce a
> buffer pointer.
> 
> Fixes: 7c4a07a424c1 ("xfs: scrub directory/attribute btrees")
> Reported-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  fs/xfs/scrub/dabtree.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/scrub/dabtree.c b/fs/xfs/scrub/dabtree.c
> index c21c528..4c9839c 100644
> --- a/fs/xfs/scrub/dabtree.c
> +++ b/fs/xfs/scrub/dabtree.c
> @@ -336,7 +336,7 @@ xfs_scrub_da_btree_block(
>  	xfs_ino_t			owner;
>  	int				*pmaxrecs;
>  	struct xfs_da3_icnode_hdr	nodehdr;
> -	int				error;
> +	int				error = 0;
>  
>  	blk = &ds->state->path.blk[level];
>  	ds->state->path.active = level + 1;
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/xfs/scrub/dabtree.c b/fs/xfs/scrub/dabtree.c
index c21c528..4c9839c 100644
--- a/fs/xfs/scrub/dabtree.c
+++ b/fs/xfs/scrub/dabtree.c
@@ -336,7 +336,7 @@  xfs_scrub_da_btree_block(
 	xfs_ino_t			owner;
 	int				*pmaxrecs;
 	struct xfs_da3_icnode_hdr	nodehdr;
-	int				error;
+	int				error = 0;
 
 	blk = &ds->state->path.blk[level];
 	ds->state->path.active = level + 1;