Declare de facto const reference variables/member functions as const #20584

pull practicalswift wants to merge 2 commits into bitcoin:master from practicalswift:const-member-fn-and-const-ref-var changing 18 files +28 −28
  1. practicalswift commented at 7:18 PM on December 6, 2020: contributor

    Meta: This is the second and final part of the const refactoring series (part one: #20581). I promise: no more refactoring PRs from me in a while! :) I'll now go back to focusing on fuzzing/hardening!

    Changes in this PR:

    • Don't declare de facto const member functions as non-const
    • Don't declare de facto const reference variables as non-const

    Awards for finding candidates for the above changes go to:

    See #18920 for instructions on how to analyse Bitcoin Core using Clang Static Analysis, clang-tidy and cppcheck.

  2. Don't declare de facto const member functions as non-const 1c65c075ee
  3. Don't declare de facto const reference variables as non-const 31b136e580
  4. DrahtBot added the label Consensus on Dec 6, 2020
  5. DrahtBot added the label Mining on Dec 6, 2020
  6. DrahtBot added the label P2P on Dec 6, 2020
  7. DrahtBot added the label RPC/REST/ZMQ on Dec 6, 2020
  8. DrahtBot added the label Validation on Dec 6, 2020
  9. DrahtBot added the label Wallet on Dec 6, 2020
  10. MarcoFalke removed the label Consensus on Dec 7, 2020
  11. MarcoFalke removed the label Mining on Dec 7, 2020
  12. MarcoFalke removed the label P2P on Dec 7, 2020
  13. MarcoFalke removed the label RPC/REST/ZMQ on Dec 7, 2020
  14. MarcoFalke removed the label Validation on Dec 7, 2020
  15. MarcoFalke removed the label Wallet on Dec 7, 2020
  16. MarcoFalke added the label Refactoring on Dec 7, 2020
  17. in src/net.cpp:1219 in 31b136e580
    1215 | @@ -1216,7 +1216,7 @@ void CConnman::NotifyNumConnectionsChanged()
    1216 |      }
    1217 |  }
    1218 |  
    1219 | -void CConnman::InactivityCheck(CNode *pnode)
    1220 | +void CConnman::InactivityCheck(CNode *pnode) const
    


    jonatack commented at 11:53 AM on December 7, 2020:

    1c65c075 not saying it's wrong, but this change to const member function for net.{h,cpp}::CConnman::InactivityCheck, in which pnode->fDisconnect can be mutated, I find somewhat odd in terms of communicated intent


    practicalswift commented at 10:04 AM on December 8, 2020:

    Given c of type CConnman do we agree that the observable state of c is unaffected by c.InactivityCheck(p)? :)

    That p can be mutated by c.InactivityCheck(p) shouldn't be odd since that follows from the signature, no? :)

  18. jonatack commented at 11:56 AM on December 7, 2020: member

    ACK 31b136e5802e1b1e5f9a9589736afe0652f34da2

  19. DrahtBot commented at 4:09 PM on December 9, 2020: member

    <!--4a62be1de6b64f3ed646cdc7932c8cf5-->

    🕵️ @sipa has been requested to review this pull request as specified in the REVIEWERS file.

  20. DrahtBot commented at 9:02 PM on December 17, 2020: 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:

    • #20864 (net: Move SocketSendData lock annotation to header by MarcoFalke)
    • #20833 (rpc/validation: enable packages through testmempoolaccept by glozow)
    • #20750 ([Bundle 2/n] Prune g_chainman usage in mempool-related validation functions by dongcarl)

    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.

  21. theStack approved
  22. theStack commented at 12:54 PM on December 28, 2020: member

    ACK 31b136e5802e1b1e5f9a9589736afe0652f34da2 :snowflake:

  23. ajtowns commented at 1:35 AM on January 7, 2021: member

    ACK 31b136e5802e1b1e5f9a9589736afe0652f34da2

    Don't double negatives? ("Declare de facto const reference variables/member functions as const" -- might be worth updating the PR title at least if you don't need to invalidate acks for some other reason)

  24. MarcoFalke renamed this:
    Don't declare de facto const member functions as non-const. Don't declare de facto const reference variables as non-const.
    Declare de facto const reference variables/member functions as const
    on Jan 7, 2021
  25. MarcoFalke merged this on Jan 7, 2021
  26. MarcoFalke closed this on Jan 7, 2021

  27. sidhujag referenced this in commit bdac8f2acb on Jan 7, 2021
  28. practicalswift deleted the branch on Apr 10, 2021
  29. Fabcien referenced this in commit 6576374b2a on Feb 24, 2022
  30. DrahtBot 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-04-16 15:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me