From 2628471a1991b619b9f34b515ffab43781b7f25b Mon Sep 17 00:00:00 2001 From: Loup Vaillant Date: Thu, 16 Apr 2020 19:52:50 +0200 Subject: [PATCH] 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. --- src/monocypher.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; -- 2.47.3