-
Notifications
You must be signed in to change notification settings - Fork 37.7k
refactor: Compile unreachable walletdb code #29315
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
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. |
Can be tested by adding a compile failure to the unreachable code. On master compilation passes, here it fails. |
fa945a7
to
fa4ceef
Compare
When unreachable code isn't compiled, compile failures are not detected. Fix this by leaving it unreachable, but compiling it. Fixes bitcoin#28999 (comment) Can be reviewed with --ignore-all-space
fa4ceef
to
fa3373d
Compare
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.
Code review ACK fa3373d. This looks good, and should prevent code in the else blocks from accidentally breaking.
Maybe a way to make it a little clearer would be to define use_bdb
and use_sqlite
c++ constants like:
constexpr bool use_bdb{
#ifdef USE_BDB
true
#endif
};
Then the actual code could use if constexpr(use_bsb)
like a normal conditional. This might be more verbose than the current approach, though, and the current approach does seem fine.
This wouldn't work, because the |
Good point. There could be a number of ways to fix this (rearranging headers, using forward declarations), but probably not worth it |
ACK fa3373d |
Another approach to this is to run CI with both
This produces compiler warnings about unreachable code. I guess that if we are to have deliberately unreachable code, then some pragma is needed to tell compilers not to warn about it in those particular places where it is intended. |
This is already done, but generally it is better to notify devs of compile failures immediately, instead of going through the lengthy CI pipeline.
Yes, the reported issue is known and is already linked. Anyone can revert the commit, if they think that reverting it solves a problem. |
When unreachable code isn't compiled, compile failures are not detected.
Fix this by leaving it unreachable, but compiling it.
Fixes #28999 (comment)