btrfs: Initialize ret to 0 in scrub_simple_mirror()
PATCH 1/1 btrfs: Initialize ret to 0 in scrub_simple_mirror()
From: "Souptick Joarder (HPE)" <[email protected]>
Kernel test robot reported below warning -> fs/btrfs/scrub.c:3439:2: warning: Undefined or garbage value returned to caller [clang-analyzer-core.uninitialized.UndefReturn]
Initialize ret to 0.
--- fs/btrfs/scrub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/scrub.c +1 -1
@@ -3325,7 +3325,7 @@ static int scrub_simple_mirror(struct scrub_ctx *sctx,const u32 max_length =SZ_64K ;struct btrfs_path path = {};u64 cur_logical = logical_start; -int ret; +int ret =0 ;/* The range must be inside the bg */ ASSERT(logical_start >= bg->start &&
Signature · 1 line
2.25.1
Quoted 10 lines · Souptick Joarder
From: "Souptick Joarder (HPE)" <[email protected]>
Kernel test robot reported below warning ->
fs/btrfs/scrub.c:3439:2: warning: Undefined or garbage value returned to caller [clang-analyzer-core.uninitialized.UndefReturn]Initialize ret to 0.
Reported-by kernel test robot <[email protected]>Signed-off-by Souptick Joarder (HPE) <[email protected]>
Although the patch is not yet merged, but I have to say, it's a false alert.
Firstly, the while loop will always get at least one run.
Secondly, in that loop, we either set ret to some error value and break, or after at least one find_first_extent_item() and scrub_extent() call, we increase cur_logical and reached the limit of the while loop and exit.
So there is no possible routine to leave @ret uninitialized and returned to caller.
Thanks,
Qu
Quoted 17 lines
--- fs/btrfs/scrub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/btrfs/scrub.c +1
-1@@ -3325,7 +3325,7 @@ static int scrub_simple_mirror(struct scrub_ctx *sctx,const u32 max_length =SZ_64K ;struct btrfs_path path = {};u64 cur_logical = logical_start; -int ret; +int ret =0 ;/* The range must be inside the bg */ ASSERT(logical_start >= bg->start &&
Quoted 10 lines · Qu Wenruo
Quoted 6 lines · Souptick Joarder
From: "Souptick Joarder (HPE)" <[email protected]>
Kernel test robot reported below warning ->
fs/btrfs/scrub.c:3439:2: warning: Undefined or garbage value returned to caller [clang-analyzer-core.uninitialized.UndefReturn]
Quoted 6 lines
Quoted 4 lines
Initialize ret to 0.
Reported-by kernel test robot <[email protected]>Signed-off-by Souptick Joarder (HPE) <[email protected]>Although the patch is not yet merged, but I have to say, it's a false alert.
Yes, I agree it is a false positive but this patch will at least keep kernel test robot happy :)
Quoted 30 lines
Firstly, the while loop will always get at least one run.
Secondly, in that loop, we either set ret to some error value and break, or after at least one
find_first_extent_item()andscrub_extent()call, we increasecur_logicaland reached the limit of the while loop and exit.So there is no possible routine to leave @ret uninitialized and returned to caller.
Thanks,
QuQuoted 17 lines
--- fs/btrfs/scrub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/btrfs/scrub.c +1
-1@@ -3325,7 +3325,7 @@ static int scrub_simple_mirror(struct scrub_ctx *sctx,const u32 max_length =SZ_64K ;struct btrfs_path path = {};u64 cur_logical = logical_start; -int ret; +int ret =0 ;/* The range must be inside the bg */ ASSERT(logical_start >= bg->start &&
Quoted 13 lines · Souptick Joarder
Quoted 12 lines · Qu Wenruo
Quoted 8 lines · Souptick Joarder
From: "Souptick Joarder (HPE)" <[email protected]>
Kernel test robot reported below warning ->
fs/btrfs/scrub.c:3439:2: warning: Undefined or garbage value returned to caller [clang-analyzer-core.uninitialized.UndefReturn]Initialize ret to 0.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Reported-by kernel test robot <[email protected]>Signed-off-by Souptick Joarder (HPE) <[email protected]>Although the patch is not yet merged, but I have to say, it's a false alert.
Yes, I agree it is a false positive but this patch will at least keep kernel test robot happy :)
I'd say we should enhance the compiler to fix the false alert.
Thus adding LLVM list here is correct.
To me, the root problem is that, we lack the hint to allow clang to know that, @logical_length passed in would not cause u64 overflow.
Unfortunately the sanity check to prevent overflow is hidden far away inside tree-checker.c.
Maybe some ASSERT() for overflow check would help LLVM to know that?
Thanks,
Qu
Quoted 31 lines
Quoted 30 lines
Firstly, the while loop will always get at least one run.
Secondly, in that loop, we either set ret to some error value and break, or after at least one
find_first_extent_item()andscrub_extent()call, we increasecur_logicaland reached the limit of the while loop and exit.So there is no possible routine to leave @ret uninitialized and returned to caller.
Thanks,
QuQuoted 17 lines
--- fs/btrfs/scrub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/btrfs/scrub.c +1
-1@@ -3325,7 +3325,7 @@ static int scrub_simple_mirror(struct scrub_ctx *sctx,const u32 max_length =SZ_64K ;struct btrfs_path path = {};u64 cur_logical = logical_start; -int ret; +int ret =0 ;/* The range must be inside the bg */ ASSERT(logical_start >= bg->start &&
Quoted 20 lines · Qu Wenruo
Quoted 16 lines · Souptick Joarder
Quoted 15 lines · Qu Wenruo
Quoted 10 lines · Souptick Joarder
From: "Souptick Joarder (HPE)" <[email protected]>
Kernel test robot reported below warning ->
fs/btrfs/scrub.c:3439:2: warning: Undefined or garbage value returned to caller [clang-analyzer-core.uninitialized.UndefReturn]Initialize ret to 0.
Reported-by kernel test robot <[email protected]>Signed-off-by Souptick Joarder (HPE) <[email protected]>
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Although the patch is not yet merged, but I have to say, it's a false alert.
Yes, I agree it is a false positive but this patch will at least keep kernel test robot happy :)
I'd say we should enhance the compiler to fix the false alert.
Thus adding LLVM list here is correct.
Hmm, kernel test robot reported similar false alert in few other modules as well.
Quoted 45 lines
To me, the root problem is that, we lack the hint to allow clang to know that, @logical_length passed in would not cause u64 overflow.
Unfortunately the sanity check to prevent overflow is hidden far away inside
tree-checker.c.Maybe some
ASSERT()for overflow check would help LLVM to know that?Thanks,
QuQuoted 31 lines
Quoted 30 lines
Firstly, the while loop will always get at least one run.
Secondly, in that loop, we either set ret to some error value and break, or after at least one
find_first_extent_item()andscrub_extent()call, we increasecur_logicaland reached the limit of the while loop and exit.So there is no possible routine to leave @ret uninitialized and returned to caller.
Thanks,
QuQuoted 17 lines
--- fs/btrfs/scrub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/btrfs/scrub.c +1
-1@@ -3325,7 +3325,7 @@ static int scrub_simple_mirror(struct scrub_ctx *sctx,const u32 max_length =SZ_64K ;struct btrfs_path path = {};u64 cur_logical = logical_start; -int ret; +int ret =0 ;/* The range must be inside the bg */ ASSERT(logical_start >= bg->start &&
Hi,
Sorry for the noise of this false alert.
For clang analyzer reports, usually we do internal check firstly. We'll send out the report only when we think that it is highly possible to be a true alert.
We scanned our report history and found this report was produced on 1/26, but it was still in the internal check domain and was not likely to be sent to Qu or mailing lists, so we are kind of confusing about this consequence.
Souptick, could you help to provide the original report by link or attachment? Then we can do some check to figure out whether we have any flaw in our process.
Thanks,
Yujie
Quoted 70 lines · Qu Wenruo
Quoted 13 lines · Souptick Joarder
Quoted 12 lines · Qu Wenruo
Quoted 8 lines · Souptick Joarder
From: "Souptick Joarder (HPE)" <[email protected]>
Kernel test robot reported below warning ->
fs/btrfs/scrub.c:3439:2: warning: Undefined or garbage value returned to caller [clang-analyzer-core.uninitialized.UndefReturn]Initialize ret to 0.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Reported-by kernel test robot <[email protected]>Signed-off-by Souptick Joarder (HPE) <[email protected]>Although the patch is not yet merged, but I have to say, it's a false alert.
Yes, I agree it is a false positive but this patch will at least keep kernel test robot happy :)
I'd say we should enhance the compiler to fix the false alert.
Thus adding LLVM list here is correct.
To me, the root problem is that, we lack the hint to allow clang to know that, @logical_length passed in would not cause u64 overflow.
Unfortunately the sanity check to prevent overflow is hidden far away inside
tree-checker.c.Maybe some
ASSERT()for overflow check would help LLVM to know that?Thanks,
QuQuoted 31 lines
Quoted 30 lines
Firstly, the while loop will always get at least one run.
Secondly, in that loop, we either set ret to some error value and break, or after at least one
find_first_extent_item()andscrub_extent()call, we increasecur_logicaland reached the limit of the while loop and exit.So there is no possible routine to leave @ret uninitialized and returned to caller.
Thanks,
QuQuoted 17 lines
---
fs/btrfs/scrub.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)fs/btrfs/scrub.c +1
-1@@ -3325,7 +3325,7 @@ static int scrub_simple_mirror(struct scrub_ctx *sctx, const u32 max_length = SZ_64K; struct btrfs_path path = {}; u64 cur_logical = logical_start; - int ret; + int ret = 0; /* The range must be inside the bg */ASSERT(logical_start >=
bg->start&&
Quoted 3 lines · Yujie Liu
Hi,
Sorry for the noise of this false alert.
No problem at all, in fact your bots are awesome detecting real bugs like previously it detects some uninitialized values from my patches.
Kudos to your guys!
LKP bots really rocks.
Quoted 4 lines
For clang analyzer reports, usually we do internal check firstly. We'll send out the
report only when we think that it is highly possible to be a true alert.
BTW, do performance benchmarks also go through the same procedure?
Although your bots are awesome at detect compiling warning/errors, sometimes it's not that straightforward to reproduce the same performance regressions.
So it may be worthy some extra steps to verify certain performance regressions.
Thanks,
Qu
Quoted 94 lines
We scanned our report history and found this report was produced on 1/26, but it was
still in the internal check domain and was not likely to be sent to Qu or mailing lists,
so we are kind of confusing about this consequence.Souptick, could you help to provide the original report by link or attachment?
Then we can do some check to figure out whether we have any flaw in our process.Thanks,
YujieQuoted 78 lines · Qu Wenruo
Quoted 14 lines · Souptick Joarder
Quoted 12 lines · Qu Wenruo
Quoted 8 lines · Souptick Joarder
From: "Souptick Joarder (HPE)" <[email protected]>
Kernel test robot reported below warning ->
fs/btrfs/scrub.c:3439:2: warning: Undefined or garbage value returned to caller [clang-analyzer-core.uninitialized.UndefReturn]Initialize ret to 0.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Reported-by kernel test robot <[email protected]>Signed-off-by Souptick Joarder (HPE) <[email protected]>Although the patch is not yet merged, but I have to say, it's a false alert.
Yes, I agree it is a false positive but this patch will at least keep kernel test robot happy :)
I'd say we should enhance the compiler to fix the false alert.
Thus adding LLVM list here is correct.
To me, the root problem is that, we lack the hint to allow clang to know that, @logical_length passed in would not cause u64 overflow.
Unfortunately the sanity check to prevent overflow is hidden far away inside
tree-checker.c.Maybe some
ASSERT()for overflow check would help LLVM to know that?Thanks,
QuQuoted 35 lines
Quoted 34 lines
Firstly, the while loop will always get at least one run.
Secondly, in that loop, we either set ret to some error value and break,
or after at least onefind_first_extent_item()andscrub_extent()call, we increasecur_logicaland reached the limit of the while loop and exit.So there is no possible routine to leave @ret uninitialized and returned
to caller.Thanks,
QuQuoted 18 lines
---
fs/btrfs/scrub.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)fs/btrfs/scrub.c +1
-1@@ -3325,7 +3325,7 @@ static int scrub_simple_mirror(struct scrub_ctx *sctx, const u32 max_length = SZ_64K; struct btrfs_path path = {}; u64 cur_logical = logical_start; - int ret; + int ret = 0; /* The range must be inside the bg */ASSERT(logical_start >=
bg->start&&
Quoted 5 lines · Yujie Liu
Hi,
Sorry for the noise of this false alert.
Quoted 8 lines
For clang analyzer reports, usually we do internal check firstly. We'll send out the report only when we think that it is highly possible to be a true alert.
We scanned our report history and found this report was produced on 1/26, but it was still in the internal check domain and was not likely to be sent to Qu or mailing lists, so we are kind of confusing about this consequence.
Souptick, could you help to provide the original report by link or attachment?
https://marc.info/?l=linux-mm&m=164487037605771&w=2
Quoted 76 lines
Then we can do some check to figure out whether we have any flaw in our process.
Thanks,
YujieQuoted 70 lines · Qu Wenruo
Quoted 13 lines · Souptick Joarder
Quoted 12 lines · Qu Wenruo
Quoted 8 lines · Souptick Joarder
From: "Souptick Joarder (HPE)" <[email protected]>
Kernel test robot reported below warning ->
fs/btrfs/scrub.c:3439:2: warning: Undefined or garbage value returned to caller [clang-analyzer-core.uninitialized.UndefReturn]Initialize ret to 0.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Reported-by kernel test robot <[email protected]>Signed-off-by Souptick Joarder (HPE) <[email protected]>Although the patch is not yet merged, but I have to say, it's a false alert.
Yes, I agree it is a false positive but this patch will at least keep kernel test robot happy :)
I'd say we should enhance the compiler to fix the false alert.
Thus adding LLVM list here is correct.
To me, the root problem is that, we lack the hint to allow clang to know that, @logical_length passed in would not cause u64 overflow.
Unfortunately the sanity check to prevent overflow is hidden far away inside
tree-checker.c.Maybe some
ASSERT()for overflow check would help LLVM to know that?Thanks,
QuQuoted 31 lines
Quoted 30 lines
Firstly, the while loop will always get at least one run.
Secondly, in that loop, we either set ret to some error value and break, or after at least one
find_first_extent_item()andscrub_extent()call, we increasecur_logicaland reached the limit of the while loop and exit.So there is no possible routine to leave @ret uninitialized and returned to caller.
Thanks,
QuQuoted 17 lines
--- fs/btrfs/scrub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/btrfs/scrub.c +1
-1@@ -3325,7 +3325,7 @@ static int scrub_simple_mirror(struct scrub_ctx *sctx,const u32 max_length =SZ_64K ;struct btrfs_path path = {};u64 cur_logical = logical_start; -int ret; +int ret =0 ;/* The range must be inside the bg */ ASSERT(logical_start >= bg->start &&
Hi Qu,
Quoted 7 lines · Qu Wenruo
Quoted 4 lines
For clang analyzer reports, usually we do internal check firstly. We'll send out the
report only when we think that it is highly possible to be a true alert.BTW, do performance benchmarks also go through the same procedure? Yes, runtime reports(including boot test, performance benchmarks,
etc.) also go through internal check procedure, but compared with build issues, sometimes we are not that confident about performance regressions.
Quoted 7 lines
Although your bots are awesome at detect compiling warning/errors, sometimes it's not that straightforward to reproduce the same performance regressions.
So it may be worthy some extra steps to verify certain performance regressions.
Runtime issues are much complicated than build issues, the performance may fluctuate depending on different software and hardware environment, so not that straightforward to reproduce.
Please feel free to contact LKP folks if found any false reports of regressions or any issues in reproducing steps. We can learn more experience from user feedback and keep optimizing our work flow to improve the accuracy of catching real regressions.
Thanks,
Yujie
Hi Souptick,
Quoted 6 lines · Souptick Joarder
Quoted 2 lines · Yujie Liu
Souptick, could you help to provide the original report by link or attachment?
this link is a notification mail of build status, but not a formal report, so there may be many false alerts in this mail, please ignore them.
Thanks,
Yujie
Hi Souptick,
Quoted 5 lines · Yujie Liu
Hi Souptick,
Quoted 2 lines · Souptick Joarder
Quoted 1 line · Yujie Liu
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Souptick, could you help to provide the original report by link or attachment?
this link is a notification mail of build status, but not a formal report, so there may be many false alerts in this mail, please ignore them.
Sorry, previous info was not accurate, here are some updates:
In a build notification mail(such as above link https://marc.info/?l=linux-mm&m=164487037605771&w=2),
there is a hint line like:
possible Error/Warning in current branch (please contact us if interested):
the errors/warnings in this section are not fully verified like the ones generated by static analysis tools.
We will make this line clearer to mention that they could be false positives.
Thanks,
Yujie