Use explicit casting in cuckoocache's compute_hashes(...) to clarify integer conversion #12770

pull practicalswift wants to merge 1 commits into bitcoin:master from practicalswift:cuckoocache changing 1 files +8 −8
  1. practicalswift commented at 3:17 PM on March 23, 2018: contributor

    Use explicit casting in cuckoocache's compute_hashes(...) to clarify integer conversion.

    I discussed this code with the code's author @JeremyRubin who suggested patching it to avoid any confusion.

    At least one static analyzer incorrectly warns about a shift past bitwidth (UB) here, so this patch will help avoid confusion for human reviewers and static analyzers alike :-)

  2. fanquake added the label Refactoring on Mar 23, 2018
  3. donaloconnor approved
  4. MarcoFalke commented at 8:55 PM on March 23, 2018: member

    b46d077 looks fine, but shouldn't the static analyser be fixed if this is an incorrect warning?

  5. fanquake commented at 4:06 AM on March 24, 2018: member

    @JeremyRubin do you want to ACK this?

  6. practicalswift commented at 5:14 PM on March 25, 2018: contributor

    @MarcoFalke Thanks for the utACK. Yes, I'll report this to the static analyser authors.

  7. MarcoFalke commented at 5:19 PM on March 25, 2018: member

    Thanks. Looks like this can be closed then.

  8. promag commented at 9:08 PM on March 25, 2018: member

    utACK b46d077.

  9. dcousens approved
  10. JeremyRubin commented at 10:31 PM on March 26, 2018: contributor

    I don't think this changes any behavior, but I think it might be more clear to apply the cast as such:

                 (uint32_t)(((uint64_t)hash_function.template operator()<2>(e) * (uint64_t)size) >> 32),

    @MarcoFalke I think it's fine to do this even if it is technically a linter bug. It took me a few minutes to read specs of operators, integer conversion hierarchies, and such to be sure that the behavior was correct.

  11. Use explicit casting in cuckoocache's compute_hashes(...) to clarify integer conversion 9142dfea81
  12. practicalswift force-pushed on Mar 26, 2018
  13. practicalswift commented at 10:38 PM on March 26, 2018: contributor

    Updated: Now applying the cast as @JeremyRubin suggested.

    Please re-review :-)

  14. MarcoFalke commented at 10:38 PM on April 1, 2018: member

    utACK 9142dfea8181c6649c8d6a8775d53bc3e14de847

  15. practicalswift commented at 8:22 PM on April 2, 2018: contributor

    @JeremyRubin @dcousens @promag @donaloconnor Would you mind re-reviewing? :-)

  16. JeremyRubin commented at 9:49 PM on April 2, 2018: contributor

    If you check the blame, you actually want @sipa to sign off on this one (he wrote that specific section).

    utack otherwise

  17. MarcoFalke merged this on Apr 9, 2018
  18. MarcoFalke closed this on Apr 9, 2018

  19. MarcoFalke referenced this in commit 603975b96a on Apr 9, 2018
  20. Fabcien referenced this in commit 3311745cc9 on Aug 30, 2019
  21. jonspock referenced this in commit 5e2ae03e9c on Dec 8, 2019
  22. jonspock referenced this in commit 83b75f3c53 on Dec 8, 2019
  23. jonspock referenced this in commit a017a02c05 on Dec 8, 2019
  24. proteanx referenced this in commit b6bb87c9d2 on Dec 12, 2019
  25. PastaPastaPasta referenced this in commit fc00189e5a on Nov 1, 2020
  26. practicalswift deleted the branch on Apr 10, 2021
  27. zkbot referenced this in commit bb6e5fad4c on Apr 20, 2021
  28. gades referenced this in commit 8395d66b5a on Feb 5, 2022
  29. 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:15 UTC

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