All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fs/btrfs: Fix uninitialized variable
@ 2021-05-01 22:50 Khaled ROMDHANI
  2021-05-02 10:17 ` Christophe JAILLET
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Khaled ROMDHANI @ 2021-05-01 22:50 UTC (permalink / raw)
  To: clm, josef, dsterba
  Cc: Khaled ROMDHANI, linux-btrfs, linux-kernel, kernel-janitors

Fix the warning: variable 'zone' is used
uninitialized whenever '?:' condition is true.

Fix that by preventing the code to reach
the last assertion. If the variable 'mirror'
is invalid, the assertion fails and we return
immediately.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Khaled ROMDHANI <khaledromdhani216@gmail.com>
---
 fs/btrfs/zoned.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index 8250ab3f0868..23da9d8dc184 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -145,7 +145,7 @@ static inline u32 sb_zone_number(int shift, int mirror)
 	case 2: zone = 1ULL << (BTRFS_SB_LOG_SECOND_SHIFT - shift); break;
 	default:
 		ASSERT((u32)mirror < 3);
-		break;
+		return 0;
 	}
 
 	ASSERT(zone <= U32_MAX);

base-commit: b5c294aac8a6164ddf38bfbdd1776091b4a1eeba
-- 
2.17.1


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

end of thread, other threads:[~2021-05-17 10:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-01 22:50 [PATCH] fs/btrfs: Fix uninitialized variable Khaled ROMDHANI
2021-05-02 10:17 ` Christophe JAILLET
2021-05-03  8:49   ` Khaled Romdhani
2021-05-03  7:23 ` Dan Carpenter
2021-05-03 10:13   ` Khaled Romdhani
2021-05-03 11:55     ` Dan Carpenter
2021-05-03 11:58       ` Colin Ian King
2021-05-17 10:51 ` David Sterba

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.