-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix unitialized variable in zstream redup
command
#10244
Conversation
Fix uninitialized variable in `zstream redup` command. The compiler may determine the 'stream_offset' variable can be uninitialized because not all rdt_lookup() exit paths set it. This should never happen in practice as documented by the assert, but initialize it regardless to resolve the warning. Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Issue openzfs#10241
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about that, thanks for fixing. Is this check part of the automated builds? If so, maybe we can turn these warnings into errors, so that we'll notice them when the PR is still open.
I was wondering myself why the CI didn't catch it. We do convert all warnings to fatal errors when building in the CI. It looks like this might have been missed because none of the bot were running a new enough version of |
Following up on why the CI missed this. It turns out the reason we didn't catch this is precisely because we mainly build with debugging enabled. When |
That's a detailed analysis. I think it might be worth noting that the more optimizations enabled, the more likely compiler to produce various warnings. It is irrelevant to debug-codepaths vs release-codepaths stuff, like the one you stumbled upon here. Rather it's just how code analyzer works. IIRC it is the same for both Clang and GCC. I think it might be less visible with C code though (I've seen the most of such discrepancy with C++). Offhand I can't find reports on this in my browser history, but I can try to find examples if anybody wants. That is just something to bear in mind, so not to spend time trying to figure out why release build produce a warning that is missing in debug one. Perhaps you may want to enable a |
Fix uninitialized variable in `zstream redup` command. The compiler may determine the 'stream_offset' variable can be uninitialized because not all rdt_lookup() exit paths set it. This should never happen in practice as documented by the assert, but initialize it regardless to resolve the warning. Reviewed-by: Matthew Ahrens <mahrens@delphix.com> Reviewed-by: George Melikov <mail@gmelikov.ru> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes openzfs#10241 Closes openzfs#10244 (cherry picked from commit 6de3e59)
Fix uninitialized variable in `zstream redup` command. The compiler may determine the 'stream_offset' variable can be uninitialized because not all rdt_lookup() exit paths set it. This should never happen in practice as documented by the assert, but initialize it regardless to resolve the warning. Reviewed-by: Matthew Ahrens <mahrens@delphix.com> Reviewed-by: George Melikov <mail@gmelikov.ru> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes openzfs#10241 Closes openzfs#10244
Motivation and Context
Issue #10241 .
Description
Fix uninitialized variable in
zstream redup
command. The compilermay determine the 'stream_offset' variable can be uninitialized
because not all rdt_lookup() exit paths set it. This should never
happen in practice as documented by the assert, but initialize it
regardless to resolve the warning.
How Has This Been Tested?
Locally compiled.
Types of changes
Checklist:
Signed-off-by
.