validation: Document where we are intentionally ignoring bool return values from validation related functions #13864

pull practicalswift wants to merge 5 commits into bitcoin:master from practicalswift:nodiscard-for-bool-returning-funcs-mutating-arguments changing 11 files +88 −71
  1. 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.

  2. 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());
        }
    }
    
  3. DrahtBot commented at 4:38 PM on August 3, 2018: contributor

    <!--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)
    • #14605 (Return of the Banman by dongcarl)
    • #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.

  4. DrahtBot cross-referenced this on Aug 3, 2018 from issue WIP: Transaction Pool Layer by MarcoFalke
  5. DrahtBot cross-referenced this on Aug 3, 2018 from issue Test for Windows encoding issue by ken2812221
  6. DrahtBot cross-referenced this on Aug 3, 2018 from issue validation: Pass tx pool reference into CheckSequenceLocks by MarcoFalke
  7. DrahtBot cross-referenced this on Aug 3, 2018 from issue [bugfix] Fix encoding issue for Windows by ken2812221
  8. DrahtBot cross-referenced this on Aug 3, 2018 from issue rpc: Add testblocktemplatevalidity by MarcoFalke
  9. DrahtBot cross-referenced this on Aug 3, 2018 from issue Remove unused fScriptChecks parameter from CheckInputs by Empact
  10. laanwj added the label Docs on Aug 7, 2018
  11. laanwj added the label Refactoring on Aug 7, 2018
  12. DrahtBot cross-referenced this on Aug 8, 2018 from issue validation: Pass chainparams in AcceptToMemoryPoolWorker(...) by practicalswift
  13. DrahtBot cross-referenced this on Aug 9, 2018 from issue Drop support for getrawtransaction for confirmed tx without txindex by sipa
  14. DrahtBot cross-referenced this on Aug 10, 2018 from issue Track best-possible-headers (TheBlueMatt) by Sjors
  15. DrahtBot cross-referenced this on Aug 11, 2018 from issue refactor: Removal of circular dependency between index/txindex, validation and index/base by mgrychow
  16. DrahtBot cross-referenced this on Aug 23, 2018 from issue Utxoscriptindex by mgrychow
  17. DrahtBot added the label Needs rebase on Aug 25, 2018
  18. practicalswift force-pushed on Aug 25, 2018
  19. 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 :-)

  20. practicalswift commented at 11:05 PM on August 25, 2018: contributor

    Rebased! Please review :-)

  21. practicalswift force-pushed on Aug 25, 2018
  22. DrahtBot removed the label Needs rebase on Aug 26, 2018
  23. DrahtBot cross-referenced this on Aug 26, 2018 from issue Add tests and error handling to DecodeExtPubKey/DecodeExtKey. Add [[nodiscard]]. by practicalswift
  24. practicalswift force-pushed on Aug 27, 2018
  25. practicalswift commented at 5:14 PM on August 27, 2018: contributor

    Updated NODISCARD to work also with Visual C++ :-)

  26. practicalswift cross-referenced this on Aug 31, 2018 from issue wallet: Remove unused local variable old_label by practicalswift
  27. DrahtBot cross-referenced this on Aug 31, 2018 from issue Index for BIP 157 block filters by jimpo
  28. DrahtBot cross-referenced this on Aug 31, 2018 from issue Minor style enhancement in documentation by fedsten
  29. DrahtBot cross-referenced this on Sep 10, 2018 from issue Annotate unused parameters with [[maybe_unused]] by practicalswift
  30. DrahtBot cross-referenced this on Sep 10, 2018 from issue validation: Add missing mempool locks by MarcoFalke
  31. DrahtBot cross-referenced this on Sep 13, 2018 from issue convert C-style (void) parameter lists to C++ style () by arvidn
  32. DrahtBot cross-referenced this on Sep 15, 2018 from issue Document intentional and unintentional unsigned integer overflows (wraparounds) using annotations by practicalswift
  33. DrahtBot cross-referenced this on Sep 20, 2018 from issue Skip tx-rehashing on historic blocks by MarcoFalke
  34. DrahtBot added the label Needs rebase on Sep 20, 2018
  35. practicalswift force-pushed on Sep 21, 2018
  36. practicalswift commented at 9:13 AM on September 21, 2018: contributor

    Rebased! :-)

  37. DrahtBot removed the label Needs rebase on Sep 21, 2018
  38. DrahtBot cross-referenced this on Sep 21, 2018 from issue Add missing locks: validation.cpp + related by practicalswift
  39. practicalswift force-pushed on Sep 21, 2018
  40. DrahtBot cross-referenced this on Oct 9, 2018 from issue Add compile time checking for cs_main locks which we assert at run time by practicalswift
  41. DrahtBot cross-referenced this on Oct 20, 2018 from issue util: Add [[nodiscard]] to all {Decode,Parse}[...](...) functions returning bool by practicalswift
  42. DrahtBot added the label Needs rebase on Oct 24, 2018
  43. practicalswift force-pushed on Oct 24, 2018
  44. practicalswift commented at 8:44 AM on October 24, 2018: contributor

    Rebased! :-)

  45. DrahtBot removed the label Needs rebase on Oct 24, 2018
  46. DrahtBot added the label Needs rebase on Oct 27, 2018
  47. Remove unused return value from LoadExternalBlockFile(...) d47f0b1faf
  48. Remove unused return value from LoadMempool(...) 4e8b3a19dc
  49. Document where we are intentionally ignoring the return value from bool returning functions from validation.{cpp,h} that modify state da395b9500
  50. Add #define NODISCARD b272348d80
  51. Mark functions whose bool return value should not be discarded with NODISCARD 71e5ce54a9
  52. practicalswift commented at 4:33 PM on October 28, 2018: contributor

    Rebased! :-)

  53. practicalswift force-pushed on Oct 28, 2018
  54. DrahtBot removed the label Needs rebase on Oct 28, 2018
  55. DrahtBot cross-referenced this on Oct 30, 2018 from issue Return of the Banman by dongcarl
  56. DrahtBot cross-referenced this on Oct 31, 2018 from issue Some simple improvements to the RNG code by sipa
  57. practicalswift closed this on Nov 12, 2018

  58. practicalswift deleted the branch on Apr 10, 2021
  59. bitcoin locked this on Aug 16, 2022

github-metadata-mirror

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-05-20 06:55 UTC