From e7571cd4ee84fd99649bd929785ec91a2279b8d7 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Mon, 8 Nov 2021 16:07:31 +0100 Subject: [PATCH] [secp256k1]refactor: Use (int)&(int) in boolean context to avoid compiler warning Summary: 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); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` This is a backport of [[https://github.com/bitcoin-core/secp256k1/pull/1009 | secp256k1#1009]] Test Plan: With clang14: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D10735 --- src/secp256k1/src/ecdsa_impl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/secp256k1/src/ecdsa_impl.h b/src/secp256k1/src/ecdsa_impl.h index 156a33d112..8eadae2e7c 100644 --- a/src/secp256k1/src/ecdsa_impl.h +++ b/src/secp256k1/src/ecdsa_impl.h @@ -304,12 +304,12 @@ static int secp256k1_ecdsa_sig_sign(const secp256k1_ecmult_gen_context *ctx, sec high = secp256k1_scalar_is_high(sigs); secp256k1_scalar_cond_negate(sigs, high); if (recid) { - *recid ^= high; + *recid ^= high; } /* P.x = order is on the curve, so technically sig->r could end up being zero, which would be an invalid signature. * This is cryptographically unreachable as hitting it requires finding the discrete log of P.x = N. */ - return !secp256k1_scalar_is_zero(sigr) & !secp256k1_scalar_is_zero(sigs); + return (int)(!secp256k1_scalar_is_zero(sigr)) & (int)(!secp256k1_scalar_is_zero(sigs)); } #endif /* SECP256K1_ECDSA_IMPL_H */