* [PATCH-V2] fs/btrfs: Fix uninitialized variable
@ 2021-04-27 17:16 Khaled ROMDHANI
2021-04-29 14:12 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: Khaled ROMDHANI @ 2021-04-27 17:16 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.
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Khaled ROMDHANI <khaledromdhani216@gmail.com>
---
v2: catch the init as an assertion
---
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..70c0b1b2ff04 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(zone = 0);
break;
}
base-commit: c05b2a58c9ed11bd753f1e64695bd89da715fbaa
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH-V2] fs/btrfs: Fix uninitialized variable
2021-04-27 17:16 [PATCH-V2] fs/btrfs: Fix uninitialized variable Khaled ROMDHANI
@ 2021-04-29 14:12 ` Dan Carpenter
2021-04-30 14:01 ` Khaled Romdhani
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2021-04-29 14:12 UTC (permalink / raw)
To: Khaled ROMDHANI
Cc: clm, josef, dsterba, linux-btrfs, linux-kernel, kernel-janitors
On Tue, Apr 27, 2021 at 06:16:27PM +0100, Khaled ROMDHANI wrote:
> The variable 'zone' is uninitialized which
> introduce some build warning.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Khaled ROMDHANI <khaledromdhani216@gmail.com>
> ---
> v2: catch the init as an assertion
> ---
> 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..70c0b1b2ff04 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(zone = 0);
I'm sorry but this doesn't make any kind of sense.
> break;
> }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH-V2] fs/btrfs: Fix uninitialized variable
2021-04-29 14:12 ` Dan Carpenter
@ 2021-04-30 14:01 ` Khaled Romdhani
0 siblings, 0 replies; 3+ messages in thread
From: Khaled Romdhani @ 2021-04-30 14:01 UTC (permalink / raw)
To: Dan Carpenter
Cc: clm, josef, dsterba, linux-btrfs, linux-kernel, kernel-janitors
On Thu, Apr 29, 2021 at 05:12:00PM +0300, Dan Carpenter wrote:
> On Tue, Apr 27, 2021 at 06:16:27PM +0100, Khaled ROMDHANI wrote:
> > The variable 'zone' is uninitialized which
> > introduce some build warning.
> >
> > Reported-by: kernel test robot <lkp@intel.com>
> > Signed-off-by: Khaled ROMDHANI <khaledromdhani216@gmail.com>
> > ---
> > v2: catch the init as an assertion
> > ---
> > 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..70c0b1b2ff04 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(zone = 0);
>
> I'm sorry but this doesn't make any kind of sense.
>
> > break;
> > }
>
> 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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-04-30 14:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-27 17:16 [PATCH-V2] fs/btrfs: Fix uninitialized variable Khaled ROMDHANI
2021-04-29 14:12 ` Dan Carpenter
2021-04-30 14:01 ` Khaled Romdhani
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.