Commit 25ff85d2bf0e1c090814ea52b3fcf461b98e17b2

Francois Perrad 2019-05-23T18:00:21

move cast inside macro

diff --git a/bn_mp_montgomery_reduce.c b/bn_mp_montgomery_reduce.c
index 52de86e..ffe8341 100644
--- a/bn_mp_montgomery_reduce.c
+++ b/bn_mp_montgomery_reduce.c
@@ -17,8 +17,8 @@ mp_err mp_montgomery_reduce(mp_int *x, const mp_int *n, mp_digit rho)
     * are fixed up in the inner loop.
     */
    digs = (n->used * 2) + 1;
-   if ((digs < (int)MP_WARRAY) &&
-       (x->used <= (int)MP_WARRAY) &&
+   if ((digs < MP_WARRAY) &&
+       (x->used <= MP_WARRAY) &&
        (n->used < MP_MAXFAST)) {
       return s_mp_montgomery_reduce_fast(x, n, rho);
    }
diff --git a/bn_mp_mul.c b/bn_mp_mul.c
index e6f46bf..f0ca04a 100644
--- a/bn_mp_mul.c
+++ b/bn_mp_mul.c
@@ -66,7 +66,7 @@ GO_ON:
          int     digs = a->used + b->used + 1;
 
 #ifdef BN_S_MP_MUL_DIGS_FAST_C
-         if ((digs < (int)MP_WARRAY) &&
+         if ((digs < MP_WARRAY) &&
              (MP_MIN(a->used, b->used) <= MP_MAXFAST)) {
             err = s_mp_mul_digs_fast(a, b, c, digs);
          } else
diff --git a/bn_mp_sqr.c b/bn_mp_sqr.c
index 7bb4c0b..d4c7d17 100644
--- a/bn_mp_sqr.c
+++ b/bn_mp_sqr.c
@@ -23,7 +23,7 @@ mp_err mp_sqr(const mp_int *a, mp_int *b)
       {
 #ifdef BN_S_MP_SQR_FAST_C
          /* can we use the fast comba multiplier? */
-         if ((((a->used * 2) + 1) < (int)MP_WARRAY) &&
+         if ((((a->used * 2) + 1) < MP_WARRAY) &&
              (a->used < (MP_MAXFAST / 2))) {
             err = s_mp_sqr_fast(a, b);
          } else
diff --git a/bn_s_mp_exptmod_fast.c b/bn_s_mp_exptmod_fast.c
index 3045e97..43a2ba1 100644
--- a/bn_s_mp_exptmod_fast.c
+++ b/bn_s_mp_exptmod_fast.c
@@ -85,7 +85,7 @@ mp_err s_mp_exptmod_fast(const mp_int *G, const mp_int *X, const mp_int *P, mp_i
 
       /* automatically pick the comba one if available (saves quite a few calls/ifs) */
 #ifdef BN_S_MP_MONTGOMERY_REDUCE_FAST_C
-      if ((((P->used * 2) + 1) < (int)MP_WARRAY) &&
+      if ((((P->used * 2) + 1) < MP_WARRAY) &&
           (P->used < MP_MAXFAST)) {
          redux = s_mp_montgomery_reduce_fast;
       } else
diff --git a/bn_s_mp_montgomery_reduce_fast.c b/bn_s_mp_montgomery_reduce_fast.c
index 59a16e3..843ad12 100644
--- a/bn_s_mp_montgomery_reduce_fast.c
+++ b/bn_s_mp_montgomery_reduce_fast.c
@@ -17,7 +17,7 @@ mp_err s_mp_montgomery_reduce_fast(mp_int *x, const mp_int *n, mp_digit rho)
    mp_err  err;
    mp_word W[MP_WARRAY];
 
-   if (x->used > (int)MP_WARRAY) {
+   if (x->used > MP_WARRAY) {
       return MP_VAL;
    }
 
diff --git a/bn_s_mp_mul_digs.c b/bn_s_mp_mul_digs.c
index 2f37e02..64509d4 100644
--- a/bn_s_mp_mul_digs.c
+++ b/bn_s_mp_mul_digs.c
@@ -17,7 +17,7 @@ mp_err s_mp_mul_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs)
    mp_digit tmpx, *tmpt, *tmpy;
 
    /* can we use the fast multiplier? */
-   if ((digs < (int)MP_WARRAY) &&
+   if ((digs < MP_WARRAY) &&
        (MP_MIN(a->used, b->used) < MP_MAXFAST)) {
       return s_mp_mul_digs_fast(a, b, c, digs);
    }
diff --git a/bn_s_mp_mul_high_digs.c b/bn_s_mp_mul_high_digs.c
index e83fa04..e5e1ba4 100644
--- a/bn_s_mp_mul_high_digs.c
+++ b/bn_s_mp_mul_high_digs.c
@@ -17,7 +17,7 @@ mp_err s_mp_mul_high_digs(const mp_int *a, const mp_int *b, mp_int *c, int digs)
 
    /* can we use the fast multiplier? */
 #ifdef BN_S_MP_MUL_HIGH_DIGS_FAST_C
-   if (((a->used + b->used + 1) < (int)MP_WARRAY)
+   if (((a->used + b->used + 1) < MP_WARRAY)
        && (MP_MIN(a->used, b->used) < MP_MAXFAST)) {
       return s_mp_mul_high_digs_fast(a, b, c, digs);
    }
diff --git a/tommath.h b/tommath.h
index 8e68c4e..9334eff 100644
--- a/tommath.h
+++ b/tommath.h
@@ -171,7 +171,7 @@ TOOM_SQR_CUTOFF;
 #endif
 
 /* size of comba arrays, should be at least 2 * 2**(BITS_PER_WORD - BITS_PER_DIGIT*2) */
-#define PRIVATE_MP_WARRAY (1uLL << (((CHAR_BIT * sizeof(private_mp_word)) - (2 * MP_DIGIT_BIT)) + 1))
+#define PRIVATE_MP_WARRAY (int)(1uLL << (((CHAR_BIT * sizeof(private_mp_word)) - (2 * MP_DIGIT_BIT)) + 1))
 #define MP_WARRAY (MP_DEPRECATED_PRAGMA("MP_WARRAY is an internal macro") PRIVATE_MP_WARRAY)
 
 #if defined(__GNUC__) && __GNUC__ >= 4