Re: [PATCH 6.5 211/285] btrfs: scrub: fix grouping of read IO

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2023-10-26 23:01, Qu Wenruo wrote:


On 2023/10/27 00:30, Holger Hoffstätte wrote:
On 2023-10-26 15:31, Sam James wrote:
'btrfs: scrub: fix grouping of read IO' seems to intorduce a
-Wmaybe-uninitialized warning (which becomes fatal with the kernel's
passed -Werror=...) with 6.5.9:

```
/var/tmp/portage/sys-kernel/gentoo-kernel-6.5.9/work/linux-6.5/fs/btrfs/scrub.c: In function ‘scrub_simple_mirror.isra’:
/var/tmp/portage/sys-kernel/gentoo-kernel-6.5.9/work/linux-6.5/fs/btrfs/scrub.c:2075:29: error: ‘found_logical’ may be used uninitialized [-Werror=maybe-uninitialized[https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmaybe-uninitialized]]
  2075 |                 cur_logical = found_logical + BTRFS_STRIPE_LEN;
/var/tmp/portage/sys-kernel/gentoo-kernel-6.5.9/work/linux-6.5/fs/btrfs/scrub.c:2040:21: note: ‘found_logical’ was declared here
  2040 |                 u64 found_logical;
       |                     ^~~~~~~~~~~~~
```

Good find! found_logical is passed by reference to queue_scrub_stripe(..) (inlined)
where it is used without ever being set:

...
     /* Either >0 as no more extents or <0 for error. */
     if (ret)
         return ret;
     if (found_logical_ret)
         *found_logical_ret = stripe->logical;
     sctx->cur_stripe++;
...

Something is missing here, and somehow I don't think it's just the top-level
initialisation of found_logical.

This looks like a false alert for me.

@found_logical is intentionally uninitialized to catch any uninitialized usage by compiler.

It would be set by queue_scrub_stripe() when there is any stripe found.

Can you show me where the reference is set before the quoted if block?
The warning happens because according to the compiler this is exactly not what's
happening, and I did not see any initializing write either.

thanks,
Holger



[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux