From: Loup Vaillant Date: Thu, 16 Apr 2020 17:52:50 +0000 (+0200) Subject: Worked around Microsoft compiler warning X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=2628471a1991b619b9f34b515ffab43781b7f25b;p=Monocypher.git Worked around Microsoft compiler warning Fixes #169 MSVC issues a warning when we try to negate an unsigned number. The goal however was to perform bit twiddling, so I used bitwise negation. Hopefully the compiler will not complain about overflow, which is perfectly well defined on unsigned numbers. --- diff --git a/src/monocypher.c b/src/monocypher.c index 253643e..a89193c 100644 --- a/src/monocypher.c +++ b/src/monocypher.c @@ -2667,7 +2667,7 @@ static void redc(u32 u[8], u32 x[16]) carry += (u64)t[i+8] + ~l[i]; carry >>= 32; } - u32 mask = (u32)-carry; // carry == 0 or 1 + u32 mask = ~(u32)carry + 1; // carry == 0 or 1 FOR (i, 0, 8) { carry += (u64)t[i+8] + (~l[i] & mask); u[i] = (u32)carry;