refactor: Use (int)&(int) in boolean context to avoid compiler warning #1009

pull MarcoFalke wants to merge 1 commits into bitcoin-core:master from MarcoFalke:2111-amp changing 1 files +2 −2
  1. MarcoFalke commented at 10:54 AM on November 9, 2021: none

    This one should really be only a refactor with the goal to silence static analysis warnings. clang-14 (trunk) recently added one in commit https://github.com/llvm/llvm-project/commit/f62d18ff140f67a8776a7a3c62a75645d8d540b5 and I expect other tools will offer similar warnings.

    Follow up to #1006, which was not a refactor.

  2. refactor: Use (int)&(int) in boolean context to avoid compiler warning
    This fixes a compiler warning:
    
    ./src/ecdsa_impl.h:312:12: warning: use of bitwise '&' with boolean operands [-Wbitwise-instead-of-logical]
        return !secp256k1_scalar_is_zero(sigr) & !secp256k1_scalar_is_zero(sigs);
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    16d132215c
  3. MarcoFalke commented at 11:02 AM on November 9, 2021: none

    I checked that this patch doesn't change the objdump, but 1006 did

  4. real-or-random commented at 12:20 PM on November 9, 2021: contributor

    ACK 16d132215cab68e57798927301268518bc1c3bf8

  5. jonasnick commented at 2:01 PM on November 9, 2021: contributor

    ACK 16d132215cab68e57798927301268518bc1c3bf8

    This is a should be a no-op also because ! already results in type int. Quite a bit weird to have to add this cast, but apparently it can catch bugs in the real world (TM).

  6. MarcoFalke commented at 2:17 PM on November 9, 2021: none

    This is a should be a no-op also because ! already results in type int

    Are you sure that operator! results in type int? At least in C++, it results in type bool: https://docs.microsoft.com/en-us/cpp/cpp/logical-negation-operator-exclpt

  7. jonasnick commented at 2:30 PM on November 9, 2021: contributor

    See C89 standard. Also, there is no bool type in C89.

  8. real-or-random merged this on Nov 9, 2021
  9. real-or-random closed this on Nov 9, 2021

  10. sipa referenced this in commit d057eae556 on Dec 2, 2021
  11. sipa cross-referenced this on Dec 2, 2021 from issue Update libsecp256k1 subtree to current master by sipa
  12. fanquake referenced this in commit c4a1e09a8c on Dec 3, 2021
  13. sipa referenced this in commit 86dbc4d075 on Dec 15, 2021
  14. deadalnix referenced this in commit e7571cd4ee on Dec 23, 2021
  15. deadalnix referenced this in commit 5292d2d95a on Dec 24, 2021
  16. jonasnick cross-referenced this on Jan 2, 2022 from issue Sync Upstream by jonasnick
  17. real-or-random referenced this in commit 21e2d65b79 on Jan 5, 2022
  18. PiRK cross-referenced this on Jan 12, 2022 from issue Clang 14 fails to compile trezor-crypto by PiRK
  19. gwillen referenced this in commit 35d6112a72 on May 25, 2022
  20. janus referenced this in commit 879a9a27b9 on Jul 10, 2022
  21. patricklodder referenced this in commit 21badcf9d2 on Jul 25, 2022
  22. patricklodder referenced this in commit 03002a9013 on Jul 28, 2022
  23. backpacker69 referenced this in commit 77186f4a04 on Jan 18, 2023
  24. str4d referenced this in commit 6de4698bf9 on Apr 21, 2023
  25. vmta referenced this in commit e1120c94a1 on Jun 4, 2023
  26. vmta referenced this in commit 8f03457eed on Jul 1, 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: 2026-04-19 07:15 UTC

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