diff mbox series

crypto: ecc - Silence sparse warning

Message ID Y+CH0i0AHpXrw0KX@gondor.apana.org.au (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show
Series crypto: ecc - Silence sparse warning | expand

Commit Message

Herbert Xu Feb. 6, 2023, 4:53 a.m. UTC
Rewrite the bitwise operations to silence the sparse warnings:

  CHECK   ../crypto/ecc.c
../crypto/ecc.c:1387:39: warning: dubious: !x | y
../crypto/ecc.c:1397:47: warning: dubious: !x | y

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Comments

Vitaly Chikunov Feb. 6, 2023, 6:04 a.m. UTC | #1
On Mon, Feb 06, 2023 at 12:53:38PM +0800, Herbert Xu wrote:
> Rewrite the bitwise operations to silence the sparse warnings:
> 
>   CHECK   ../crypto/ecc.c
> ../crypto/ecc.c:1387:39: warning: dubious: !x | y
> ../crypto/ecc.c:1397:47: warning: dubious: !x | y
> 
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
> 
> diff --git a/crypto/ecc.c b/crypto/ecc.c
> index 7315217c8f73..f53fb4d6af99 100644
> --- a/crypto/ecc.c
> +++ b/crypto/ecc.c
> @@ -1384,7 +1384,8 @@ void ecc_point_mult_shamir(const struct ecc_point *result,
>  
>  	num_bits = max(vli_num_bits(u1, ndigits), vli_num_bits(u2, ndigits));
>  	i = num_bits - 1;
> -	idx = (!!vli_test_bit(u1, i)) | ((!!vli_test_bit(u2, i)) << 1);
> +	idx = !!vli_test_bit(u1, i);
> +	idx |= (!!vli_test_bit(u2, i)) << 1;
>  	point = points[idx];
>  
>  	vli_set(rx, point->x, ndigits);
> @@ -1394,7 +1395,8 @@ void ecc_point_mult_shamir(const struct ecc_point *result,
>  
>  	for (--i; i >= 0; i--) {
>  		ecc_point_double_jacobian(rx, ry, z, curve);
> -		idx = (!!vli_test_bit(u1, i)) | ((!!vli_test_bit(u2, i)) << 1);
> +		idx = !!vli_test_bit(u1, i);
> +		idx |= (!!vli_test_bit(u2, i)) << 1;

Reviewed-by: Vitaly Chikunov <vt@altlinux.org>

Thanks,

>  		point = points[idx];
>  		if (point) {
>  			u64 tx[ECC_MAX_DIGITS];
> -- 
> Email: Herbert Xu <herbert@gondor.apana.org.au>
> Home Page: http://gondor.apana.org.au/~herbert/
> PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
diff mbox series

Patch

diff --git a/crypto/ecc.c b/crypto/ecc.c
index 7315217c8f73..f53fb4d6af99 100644
--- a/crypto/ecc.c
+++ b/crypto/ecc.c
@@ -1384,7 +1384,8 @@  void ecc_point_mult_shamir(const struct ecc_point *result,
 
 	num_bits = max(vli_num_bits(u1, ndigits), vli_num_bits(u2, ndigits));
 	i = num_bits - 1;
-	idx = (!!vli_test_bit(u1, i)) | ((!!vli_test_bit(u2, i)) << 1);
+	idx = !!vli_test_bit(u1, i);
+	idx |= (!!vli_test_bit(u2, i)) << 1;
 	point = points[idx];
 
 	vli_set(rx, point->x, ndigits);
@@ -1394,7 +1395,8 @@  void ecc_point_mult_shamir(const struct ecc_point *result,
 
 	for (--i; i >= 0; i--) {
 		ecc_point_double_jacobian(rx, ry, z, curve);
-		idx = (!!vli_test_bit(u1, i)) | ((!!vli_test_bit(u2, i)) << 1);
+		idx = !!vli_test_bit(u1, i);
+		idx |= (!!vli_test_bit(u2, i)) << 1;
 		point = points[idx];
 		if (point) {
 			u64 tx[ECC_MAX_DIGITS];