refactor: Use && in boolean context to avoid compiler warning #1006

pull maflcko wants to merge 1 commits into bitcoin-core:master from maflcko:2111-amp changing 1 files +1 −1
  1. maflcko commented at 3:10 PM on November 8, 2021: contributor

    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);
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                               &&
    
  2. refactor: Use && 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);
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                               &&
    e24b9ac353
  3. maflcko commented at 3:12 PM on November 8, 2021: contributor

    I didn't try to reproduce this, but I randomly saw it in logs on a 32-bit compilation with clang-14 (trunk) and some odd compiler flags like -O0.

  4. maflcko commented at 3:23 PM on November 8, 2021: contributor

    Ah, I see.

    Good thing there are tests.

  5. maflcko closed this on Nov 8, 2021

  6. maflcko deleted the branch on Nov 8, 2021
  7. sipa commented at 3:24 PM on November 8, 2021: contributor

    :)

  8. maflcko commented at 4:42 PM on November 8, 2021: contributor
  9. sipa commented at 5:26 PM on November 8, 2021: contributor

    If there is a need to silence anything, I think the correct approach is suggested there: cast one of the inputs to & to int.

  10. real-or-random referenced this in commit 74c34e727b on Nov 9, 2021

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-05-19 06:52 UTC