fs/btrfs: Fix uninitialized variable
Subsystems (2)
PATCH v2 1/1 fs/btrfs: Fix uninitialized variable
The variable 'zone' is uninitialized which
introduce some build warning.
---
v2: catch the init as an assertion
--- fs/btrfs/zoned.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/zoned.c +1 -1
@@ -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 (zone =0 );break ; }
base-commit: c05b2a58c9ed11bd753f1e64695bd89da715fbaa
Signature · 1 line
2.17.1
Quoted 16 lines · Khaled ROMDHANI
The variable 'zone' is uninitialized which
introduce some build warning.Reported-by kernel test robot <[email protected]>Signed-off-by Khaled ROMDHANI <[email protected]>---
v2: catch the init as an assertion--- fs/btrfs/zoned.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/btrfs/zoned.c +0
-0
fs/btrfs/zoned.c static inline u32 sb_zone_number(int shift, int mirror) · line 147
Quoted 5 lines
fs/btrfs/zoned.c +1
-1@@ -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 (zone =0 );
I'm sorry but this doesn't make any kind of sense.
fs/btrfs/zoned.c static inline u32 sb_zone_number(int shift, int mirror) · line 149
Quoted 2 lines
fs/btrfs/zoned.c +0
-0break ; }
regards,
dan carpenter
Quoted 25 lines · Dan Carpenter
Quoted 16 lines · Khaled ROMDHANI
The variable 'zone' is uninitialized which
introduce some build warning.Reported-by kernel test robot <[email protected]>Signed-off-by Khaled ROMDHANI <[email protected]>---
v2: catch the init as an assertion--- fs/btrfs/zoned.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/btrfs/zoned.c +0
-0fs/btrfs/zoned.c static inline u32 sb_zone_number(int shift, int mirror) · line 147
Quoted 5 lines
fs/btrfs/zoned.c +1
-1@@ -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 (zone =0 );I'm sorry but this doesn't make any kind of sense.
Quoted 6 lines
fs/btrfs/zoned.c static inline u32 sb_zone_number(int shift, int mirror) · line 149
Quoted 2 lines
fs/btrfs/zoned.c +0
-0break ; }regards,
dan carpenter
The idea behind this is to force the assertion failure in default when no valid 'mirror' value was entered. But as all caller pass valid mirror values, this case will not happen. So, I just fix the warning of the uninitialized variable 'zone' as reported by the kernel test robot. Thus I guarantee the failure when 'mirror' was invalid.
If I am wrong, please clarify.
Thanks.