From 31ec1d7319ffb891bda09af34480006d08e16303 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Thu, 10 Jun 2021 09:36:41 +0200 Subject: [PATCH] Simplify sign selection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Manuel Pégourié-Gonnard --- library/bignum.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/library/bignum.c b/library/bignum.c index 641049ba7..b1f9063d3 100644 --- a/library/bignum.c +++ b/library/bignum.c @@ -257,17 +257,8 @@ static int mpi_safe_cond_select_sign( int a, int b, unsigned char second ) unsigned ua = a + 1; unsigned ub = b + 1; - /* MSVC has a warning about unary minus on unsigned integer types, - * but this is well-defined and precisely what we want to do here. */ -#if defined(_MSC_VER) -#pragma warning( push ) -#pragma warning( disable : 4146 ) -#endif - /* all-bits 1 if assign is 1, all-bits 0 if assign is 0 */ - const unsigned mask = -second; -#if defined(_MSC_VER) -#pragma warning( pop ) -#endif + /* second was 0 or 1, mask is 0 or 2 as are ua and ub */ + const unsigned mask = second << 1; /* select ua or ub */ unsigned ur = ( ua & ~mask ) | ( ub & mask );