Commit 6927a91
btrfs: make found_logical_ret parameter mandatory for function queue_scrub_stripe()
[ Upstream commit 47e2b06 ]
[BUG]
There is a compilation warning reported on commit ae76d8e ("btrfs:
scrub: fix grouping of read IO"), where gcc (14.0.0 20231022 experimental)
is reporting the following uninitialized variable:
fs/btrfs/scrub.c: In function ‘scrub_simple_mirror.isra’:
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;
fs/btrfs/scrub.c:2040:21: note: ‘found_logical’ was declared here
2040 | u64 found_logical;
| ^~~~~~~~~~~~~
[CAUSE]
This is a false alert, as @found_logical is passed as parameter
@found_logical_ret of function queue_scrub_stripe().
As long as queue_scrub_stripe() returned 0, we would update
@found_logical_ret. And if queue_scrub_stripe() returned >0 or <0, the
caller would not utilized @found_logical, thus there should be nothing
wrong.
Although the triggering gcc is still experimental, it looks like the
extra check on "if (found_logical_ret)" can sometimes confuse the
compiler.
Meanwhile the only caller of queue_scrub_stripe() is always passing a
valid pointer, there is no need for such check at all.
[FIX]
Although the report itself is a false alert, we can still make it more
explicit by:
- Replace the check for @found_logical_ret with ASSERT()
- Initialize @found_logical to U64_MAX
- Add one extra ASSERT() to make sure @found_logical got updated
Link: https://lore.kernel.org/linux-btrfs/[email protected]/
Fixes: ae76d8e ("btrfs: scrub: fix grouping of read IO")
Reviewed-by: Anand Jain <[email protected]>
Signed-off-by: Qu Wenruo <[email protected]>
Reviewed-by: David Sterba <[email protected]>
Signed-off-by: David Sterba <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>1 parent 9ac639d commit 6927a91
1 file changed
Lines changed: 7 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1798 | 1798 | | |
1799 | 1799 | | |
1800 | 1800 | | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
1801 | 1804 | | |
1802 | 1805 | | |
1803 | 1806 | | |
| |||
1806 | 1809 | | |
1807 | 1810 | | |
1808 | 1811 | | |
1809 | | - | |
1810 | | - | |
| 1812 | + | |
1811 | 1813 | | |
1812 | 1814 | | |
1813 | 1815 | | |
| |||
2010 | 2012 | | |
2011 | 2013 | | |
2012 | 2014 | | |
2013 | | - | |
| 2015 | + | |
2014 | 2016 | | |
2015 | 2017 | | |
2016 | 2018 | | |
| |||
2045 | 2047 | | |
2046 | 2048 | | |
2047 | 2049 | | |
| 2050 | + | |
| 2051 | + | |
2048 | 2052 | | |
2049 | 2053 | | |
2050 | 2054 | | |
| |||
0 commit comments