]> git.codecow.com Git - Monocypher.git/commitdiff
Worked around Microsoft compiler warning
authorLoup Vaillant <loup@loup-vaillant.fr>
Thu, 16 Apr 2020 17:52:50 +0000 (19:52 +0200)
committerLoup Vaillant <loup@loup-vaillant.fr>
Thu, 16 Apr 2020 17:52:50 +0000 (19:52 +0200)
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

index 253643ed514ffc5b7a8be58bd5e397fc751f0501..a89193ccc30c0cfcfa63000d571cda7dd3c6c67e 100644 (file)
@@ -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;