validation: Document where we are intentionally ignoring bool return values from validation related functions#13864
pullpracticalswift
wants to merge
5
commits into
bitcoin:master
from
practicalswift:nodiscard-for-bool-returning-funcs-mutating-arguments
changing
11
files
+88−71
practicalswift
commented at 2:25 PM on August 3, 2018:
contributor
Document where we are intentionally ignoring the return value from bool returning functions from validation.{cpp,h} that modify state
Mark validation functions whose bool return value should not be discarded in the general case with NODISCARD (expands to [[nodiscard]] or __attribute__((warn_unused_result)) depending on availability)
This will help us identify code where we're we incorrectly assume that a certain function always succeeds in performing its state modification.
Empact
commented at 3:50 PM on August 3, 2018:
member
Should we not update the callers to react and log warnings on failures?
E.g. this seems like a meaningful case:
if (!file) {
LogPrintf("Warning: Could not open blocks file %s\n", path.string());
} else {
LogPrintf("Importing blocks file %s...\n", path.string());
if (!LoadExternalBlockFile(chainparams, file)) {
LogPrintf("Warning: No blocks loaded from %s\n", path.string());
}
}
DrahtBot
commented at 4:38 PM on August 3, 2018:
member
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
Conflicts
Reviewers, this pull request conflicts with the following ones:
#14624 (Some simple improvements to the RNG code by sipa)
#14224 (Document intentional and unintentional unsigned integer overflows (wraparounds) using annotations by practicalswift)
#14194 (Annotate unused parameters with [[maybe_unused]] by practicalswift)
#14193 (validation: Add missing mempool locks by MarcoFalke)
#13937 (Track best-possible-headers (TheBlueMatt) by Sjors)
#13868 (Remove unused fScriptChecks parameter from CheckInputs by Empact)
#13815 (util: Add [[nodiscard]] to all {Decode,Parse}... functions returning bool by practicalswift)
#13804 (WIP: Transaction Pool Layer by MarcoFalke)
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
laanwj added the label Docs on Aug 7, 2018
laanwj added the label Refactoring on Aug 7, 2018
DrahtBot added the label Needs rebase on Aug 25, 2018
practicalswift force-pushed on Aug 25, 2018
practicalswift
commented at 11:05 PM on August 25, 2018:
contributor
@Empact Increased logging should perhaps be a subject for another PR. Personally I’m not convinced that these cases are worth logging for – nobody seems to have been missing these log messages so far and we should be careful to decrease the signal to noise in our logging. It is already very verbose :-)
practicalswift
commented at 11:05 PM on August 25, 2018:
contributor
Rebased! Please review :-)
practicalswift force-pushed on Aug 25, 2018
DrahtBot removed the label Needs rebase on Aug 26, 2018
practicalswift force-pushed on Aug 27, 2018
practicalswift
commented at 5:14 PM on August 27, 2018:
contributor
Updated NODISCARD to work also with Visual C++ :-)
DrahtBot added the label Needs rebase on Sep 20, 2018
practicalswift force-pushed on Sep 21, 2018
practicalswift
commented at 9:13 AM on September 21, 2018:
contributor
Rebased! :-)
DrahtBot removed the label Needs rebase on Sep 21, 2018
practicalswift force-pushed on Sep 21, 2018
DrahtBot added the label Needs rebase on Oct 24, 2018
practicalswift force-pushed on Oct 24, 2018
practicalswift
commented at 8:44 AM on October 24, 2018:
contributor
Rebased! :-)
DrahtBot removed the label Needs rebase on Oct 24, 2018
DrahtBot added the label Needs rebase on Oct 27, 2018
Remove unused return value from LoadExternalBlockFile(...)d47f0b1faf
Remove unused return value from LoadMempool(...)4e8b3a19dc
Document where we are intentionally ignoring the return value from bool returning functions from validation.{cpp,h} that modify stateda395b9500
Add #define NODISCARDb272348d80
Mark functions whose bool return value should not be discarded with NODISCARD71e5ce54a9
practicalswift
commented at 4:33 PM on October 28, 2018:
contributor
Rebased! :-)
practicalswift force-pushed on Oct 28, 2018
DrahtBot removed the label Needs rebase on Oct 28, 2018
This is a metadata mirror of the GitHub repository
bitcoin/bitcoin.
This site is not affiliated with GitHub.
Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:15 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me