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 833322e89bac145efda755566a75856734522965..e0bcd6e502031ecf27c8828f19b42f6f78f01782 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 e86e4c72c7ce498e222cd16d7f5680d45a021410..c2844713cf1e3d0582925bfe23ad3d66294c9496 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 a46d8b160a9a97fad96bd31a08183708b65dfd34..e91ab6de229525f3141b9b4d2b8200df2543e69a 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)