Fix VC warnings about unary minus to an unsigned type.
authorKurt Roeckx <kurt@roeckx.be>
Sun, 15 Jan 2017 11:33:45 +0000 (12:33 +0100)
committerKurt Roeckx <kurt@roeckx.be>
Sun, 15 Jan 2017 21:21:07 +0000 (22:21 +0100)
Reviewed-by: Andy Polyakov <appro@openssl.org>
GH: #2230

crypto/asn1/a_int.c
crypto/asn1/x_long.c
crypto/bio/b_print.c

index 833322e..e0bcd6e 100644 (file)
@@ -289,7 +289,7 @@ static int asn1_get_int64(int64_t *pr, const unsigned char *b, size_t blen,
             ASN1err(ASN1_F_ASN1_GET_INT64, ASN1_R_TOO_SMALL);
             return 0;
         }
-        *pr = -(uint64_t)r;
+        *pr = 0 - (uint64_t)r;
     } else {
         if (r > INT64_MAX) {
             ASN1err(ASN1_F_ASN1_GET_INT64, ASN1_R_TOO_LARGE);
index e86e4c7..c284471 100644 (file)
@@ -76,7 +76,7 @@ static int long_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype,
      * set.
      */
     if (ltmp < 0)
-        utmp = -(unsigned long)ltmp - 1;
+        utmp = 0 - (unsigned long)ltmp - 1;
     else
         utmp = ltmp;
     clen = BN_num_bits_word(utmp);
index a46d8b1..e91ab6d 100644 (file)
@@ -451,7 +451,7 @@ fmtint(char **sbuffer,
     if (!(flags & DP_F_UNSIGNED)) {
         if (value < 0) {
             signvalue = '-';
-            uvalue = -(unsigned LLONG)value;
+            uvalue = 0 - (unsigned LLONG)value;
         } else if (flags & DP_F_PLUS)
             signvalue = '+';
         else if (flags & DP_F_SPACE)