public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH-V3] fs/btrfs: Fix uninitialized variable
@ 2021-05-01  1:11 Khaled ROMDHANI
  2021-05-01  4:51 ` kernel test robot
  0 siblings, 1 reply; 2+ messages in thread
From: Khaled ROMDHANI @ 2021-05-01  1:11 UTC (permalink / raw)
  To: clm, josef, dsterba
  Cc: Khaled ROMDHANI, linux-btrfs, linux-kernel, kernel-janitors

The variable 'zone' is uninitialized which
introduce some build warning when introduced
within the switch.

Fix that by changing the passed condition:
Catch explicitly any invalid 'mirror' value
as an assertion failure.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Khaled ROMDHANI <khaledromdhani216@gmail.com>
---
V3: catch explicitly invalid mirror value
V2: force assertion failure by zeroing the zone variable
V1: initialize the zone variable
---
 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 432509f4b3ac..8250ab3f0868 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -144,7 +144,7 @@ static inline u32 sb_zone_number(int shift, int mirror)
 	case 1: zone = 1ULL << (BTRFS_SB_LOG_FIRST_SHIFT - shift); break;
 	case 2: zone = 1ULL << (BTRFS_SB_LOG_SECOND_SHIFT - shift); break;
 	default:
-		ASSERT(zone);
+		ASSERT((u32)mirror < 3);
 		break;
 	}
 

base-commit: c05b2a58c9ed11bd753f1e64695bd89da715fbaa
-- 
2.17.1


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

end of thread, other threads:[~2021-05-01  4:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-01  1:11 [PATCH-V3] fs/btrfs: Fix uninitialized variable Khaled ROMDHANI
2021-05-01  4:51 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox