refactor: Avoid unary minus on unsigned integers #1293

pull hebasto wants to merge 2 commits into bitcoin-core:master from hebasto:230430-minus changing 9 files +17 −18
  1. hebasto commented at 4:59 pm on April 30, 2023: member

    The assembly code remains unchanged.

    In addition, this PR enables MSVC warning C4146 for the entire codebase.

  2. ci: Treat all compiler warnings as errors in "Windows (VS 2022)" task b2e29e43d0
  3. hebasto renamed this:
    ci: Treat all compiler warnings as errors in "Windows (VS 2022)" task
    refactor: Avoid unary minus on unsigned integers
    on Apr 30, 2023
  4. hebasto marked this as a draft on Apr 30, 2023
  5. hebasto force-pushed on Apr 30, 2023
  6. hebasto marked this as ready for review on Apr 30, 2023
  7. real-or-random cross-referenced this on May 2, 2023 from issue refactor: Make 64-bit shift explicit by hebasto
  8. real-or-random commented at 8:45 am on May 2, 2023: contributor

    I think rewriting -x to (0 - x) is a bit nicer than `(~x + 1).

    With that change applied, I think I’m literally ~0 on that PR: On the one hand, changing the code to make the compiler happy is not great… But perhaps having a clean build with just /W2 is good.

  9. refactor: Avoid unary minus on unsigned integers
    The assembly code remains unchanged.
    
    In addition, this change enables MSVC warning C4146 for the entire
    codebase.
    See: https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-2-c4146
    e0e3874c8d
  10. hebasto force-pushed on May 2, 2023
  11. hebasto commented at 12:30 pm on May 2, 2023: member

    I think rewriting -x to (0 - x) is a bit nicer than `(~x + 1).

    Done.

    On the one hand, changing the code to make the compiler happy is not great…

    I agree with you.

    But perhaps having a clean build with just /W2 is good.

    That is my point.

  12. real-or-random cross-referenced this on May 10, 2023 from issue ct: Use more volatile by real-or-random
  13. jonasnick commented at 3:14 pm on May 11, 2023: contributor
    Having to change perfectly fine -x to 0-x seems a bit annoying. I can imagine that this will confuse potential future reviewers. I don’t think that’s worth it.
  14. sipa commented at 3:20 pm on May 11, 2023: contributor

    Concept NACK, I think the resulting code is harder to read.

    The warning in my opinion is silly (at least for our codebase), so the proper action is the disable the warning, not work around it.

  15. hebasto closed this on May 11, 2023

  16. hebasto deleted the branch on Jun 6, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-10-30 01:15 UTC

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