All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] xfs: scrub: avoid uninitialized return code
@ 2017-11-02 11:11 Arnd Bergmann
  2017-11-02 11:11 ` [PATCH 2/2] xfs: fix unused variable warnings Arnd Bergmann
  2017-11-02 12:44 ` [PATCH 1/2] xfs: scrub: avoid uninitialized return code Brian Foster
  0 siblings, 2 replies; 6+ messages in thread
From: Arnd Bergmann @ 2017-11-02 11:11 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Arnd Bergmann, linux-xfs, Dave Chinner, linux-kernel

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]

Returning -EINVAL might be an appropriate return code in this case.

Fixes: 7c4a07a424c1 ("xfs: scrub directory/attribute btrees")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 fs/xfs/scrub/dabtree.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/xfs/scrub/dabtree.c b/fs/xfs/scrub/dabtree.c
index 4a93cf1753d3..971566388c9a 100644
--- a/fs/xfs/scrub/dabtree.c
+++ b/fs/xfs/scrub/dabtree.c
@@ -349,8 +349,10 @@ xfs_scrub_da_btree_block(
 
 	/* Check the pointer. */
 	blk->blkno = blkno;
-	if (!xfs_scrub_da_btree_ptr_ok(ds, level, blkno))
+	if (!xfs_scrub_da_btree_ptr_ok(ds, level, blkno)) {
+		error = -EINVAL;
 		goto out_nobuf;
+	}
 
 	/* Read the buffer. */
 	error = xfs_da_read_buf(dargs->trans, dargs->dp, blk->blkno, -2,
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-11-02 16:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-02 11:11 [PATCH 1/2] xfs: scrub: avoid uninitialized return code Arnd Bergmann
2017-11-02 11:11 ` [PATCH 2/2] xfs: fix unused variable warnings Arnd Bergmann
2017-11-02 12:44   ` Brian Foster
2017-11-02 16:52     ` Darrick J. Wong
2017-11-02 12:44 ` [PATCH 1/2] xfs: scrub: avoid uninitialized return code Brian Foster
2017-11-02 16:49   ` Darrick J. Wong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.