Skip to contentSkip to conversation

xfs: scrub: avoid uninitialized return code

PATCH In review Darrick J. Wong 2 participants 2 messages Nov 2, 2017 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 xfs: scrub: avoid uninitialized return code

From: Darrick J. Wong <[email protected]>

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")
---
 fs/xfs/scrub/dabtree.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/scrub/dabtree.c +1 -1
index c21c528..4c9839c 100644
@@ -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;
Reviewed-by on v2 1/1
#1 lore raw
Quoted 9 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

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]

Quoted 7 lines

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")

---

Quoted 16 lines
 fs/xfs/scrub/dabtree.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/scrub/dabtree.c +1 -1
index c21c528..4c9839c 100644
@@ -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;