diff --git a/bn_conversion.c b/bn_conversion.c index 39bdf7a4c..19e55325a 100644 --- a/bn_conversion.c +++ b/bn_conversion.c @@ -20,7 +20,7 @@ #define MP_SET_SIGNED(name, uname, w) \ void name(mp_int * a, int##w##_t b) \ { \ - uname(a, b < 0 ? -(uint##w##_t)b : (uint##w##_t)b); \ + uname(a, (b < 0) ? -(uint##w##_t)b : (uint##w##_t)b); \ if (b < 0) { a->sign = MP_NEG; } \ } #define MP_INIT_INT(name , set, type) \ @@ -37,8 +37,8 @@ uint##w##_t name(const mp_int* a) \ { \ unsigned i = MP_MIN((unsigned)a->used, (unsigned)((w + MP_DIGIT_BIT - 1) / MP_DIGIT_BIT)); \ - uint##w##_t res = 0; \ - while (i --> 0) { \ + uint##w##_t res = 0u; \ + while (i --> 0u) { \ res <<= ((w <= MP_DIGIT_BIT) ? 0 : MP_DIGIT_BIT); \ res |= (uint##w##_t)a->dp[i]; \ if (w <= MP_DIGIT_BIT) { break; } \ @@ -49,7 +49,7 @@ int##w##_t name(const mp_int* a) \ { \ uint64_t res = mag(a); \ - return a->sign == MP_NEG ? (int##w##_t)-res : (int##w##_t)res; \ + return (a->sign == MP_NEG) ? (int##w##_t)-res : (int##w##_t)res;\ } #ifdef BN_MP_SET_U32_C diff --git a/bn_deprecated.c b/bn_deprecated.c index 71fa645cf..101cdfaa5 100644 --- a/bn_deprecated.c +++ b/bn_deprecated.c @@ -176,7 +176,7 @@ unsigned long mp_get_int(const mp_int *a) #ifdef BN_MP_GET_LONG_C unsigned long mp_get_long(const mp_int *a) { - return sizeof(long) > sizeof(int32_t) ? (unsigned long)mp_get_mag64(a) : (unsigned long)mp_get_mag32(a); + return (sizeof(long) > sizeof(int32_t)) ? (unsigned long)mp_get_mag64(a) : (unsigned long)mp_get_mag32(a); } #endif #ifdef BN_MP_GET_LONG_LONG_C diff --git a/bn_mp_ilogb.c b/bn_mp_ilogb.c index ff237dd35..b584c4311 100644 --- a/bn_mp_ilogb.c +++ b/bn_mp_ilogb.c @@ -104,7 +104,7 @@ mp_err mp_ilogb(const mp_int *a, mp_digit base, mp_int *c) return err; } if (cmp == MP_EQ) { - mp_set(c, 1u); + mp_set(c, 1uL); return err; } diff --git a/bn_mp_is_square.c b/bn_mp_is_square.c index 5c191dcff..69e77a21a 100644 --- a/bn_mp_is_square.c +++ b/bn_mp_is_square.c @@ -58,7 +58,7 @@ mp_err mp_is_square(const mp_int *arg, mp_bool *ret) } - if ((err = mp_init_u32(&t, 11L*13L*17L*19L*23L*29L*31L)) != MP_OKAY) { + if ((err = mp_init_u32(&t, 11u*13u*17u*19u*23u*29u*31u)) != MP_OKAY) { return err; } if ((err = mp_mod(arg, &t, &t)) != MP_OKAY) { diff --git a/bn_mp_prime_strong_lucas_selfridge.c b/bn_mp_prime_strong_lucas_selfridge.c index e58b64afa..34b073c26 100644 --- a/bn_mp_prime_strong_lucas_selfridge.c +++ b/bn_mp_prime_strong_lucas_selfridge.c @@ -172,9 +172,9 @@ mp_err mp_prime_strong_lucas_selfridge(const mp_int *a, mp_bool *result) combined with the previous totals for U and V, using the composition formulas for addition of indices. */ - mp_set(&Uz, 1u); /* U=U_1 */ + mp_set(&Uz, 1uL); /* U=U_1 */ mp_set(&Vz, (mp_digit)P); /* V=V_1 */ - mp_set(&U2mz, 1u); /* U_1 */ + mp_set(&U2mz, 1uL); /* U_1 */ mp_set(&V2mz, (mp_digit)P); /* V_1 */ if (Q < 0) { diff --git a/bn_mp_sqrtmod_prime.c b/bn_mp_sqrtmod_prime.c index 0ce83bdf3..f80376059 100644 --- a/bn_mp_sqrtmod_prime.c +++ b/bn_mp_sqrtmod_prime.c @@ -59,7 +59,7 @@ mp_err mp_sqrtmod_prime(const mp_int *n, const mp_int *prime, mp_int *ret) } /* find a Z such that the Legendre symbol (Z|prime) == -1 */ - mp_set_u32(&Z, 2uL); + mp_set_u32(&Z, 2u); /* Z = 2 */ while (1) { if ((err = mp_kronecker(&Z, prime, &legendre)) != MP_OKAY) goto cleanup; @@ -79,7 +79,7 @@ mp_err mp_sqrtmod_prime(const mp_int *n, const mp_int *prime, mp_int *ret) /* T = n ^ Q mod prime */ if ((err = mp_copy(&S, &M)) != MP_OKAY) goto cleanup; /* M = S */ - mp_set_u32(&two, 2uL); + mp_set_u32(&two, 2u); while (1) { if ((err = mp_copy(&T, &t1)) != MP_OKAY) goto cleanup;