Messages in this thread Patch in this message | | | From | Khaled ROMDHANI <> | Subject | [PATCH] fs/btrfs: Fix uninitialized variable | Date | Sat, 1 May 2021 23:50:46 +0100 |
| |
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
| |