Skip to contentSkip to conversation

xfs_scrub: fix complaint about uninitialized ret

PATCH In review Darrick J. Wong 2 participants 2 messages Nov 7, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs_scrub: fix complaint about uninitialized ret

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

Coverity complained about the uninitialized ret in run_scrub_phases. It's not sophisticated enough to realize that phase 1 and 7 are both marked mustrun and are never the repair or datascan dummies and that therefore ret is always initialized by the end of the for loop, but OTOH there's no reason not to fix a trivial logic bomb if that ever changes.

Coverity-id: 1455255

---
 scrub/xfs_scrub.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scrub/xfs_scrub.c +1 -1
index a792768c..014c54dd 100644
@@ -422,7 +422,7 @@ run_scrub_phases(
 	unsigned int		debug_phase = 0;
 	unsigned int		phase;
 	int			rshift;
-	int			ret;
+	int			ret = 0;
 
 	if (debug_tweak_on("XFS_SCRUB_PHASE"))
 		debug_phase = atoi(getenv("XFS_SCRUB_PHASE"));
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Darrick J. Wong

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

Coverity complained about the uninitialized ret in run_scrub_phases. It's not sophisticated enough to realize that phase 1 and 7 are both marked mustrun and are never the repair or datascan dummies and that therefore ret is always initialized by the end of the for loop, but OTOH there's no reason not to fix a trivial logic bomb if that ever changes.

Coverity-id: 1455255

Quoted 18 lines
---
 scrub/xfs_scrub.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scrub/xfs_scrub.c +1 -1
index a792768c..014c54dd 100644
@@ -422,7 +422,7 @@ run_scrub_phases(
 	unsigned int		debug_phase = 0;
 	unsigned int		phase;
 	int			rshift;
-	int			ret;
+	int			ret = 0;
 
 	if (debug_tweak_on("XFS_SCRUB_PHASE"))
 		debug_phase = atoi(getenv("XFS_SCRUB_PHASE"));