Merge pull request #292 from fperrad/20190523_lint some linting
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
diff --git a/bn_mp_ilogb.c b/bn_mp_ilogb.c
index 6669eb8..ff237dd 100644
--- a/bn_mp_ilogb.c
+++ b/bn_mp_ilogb.c
@@ -42,7 +42,7 @@ static mp_digit s_digit_ilogb(mp_digit base, mp_digit n)
while (((mp_digit)(high - low)) > 1uL) {
mid = (low + high) >> 1;
- bracket_mid = bracket_low * s_pow(base, mid - low) ;
+ bracket_mid = bracket_low * s_pow(base, (mp_word)(mid - low));
if (N < bracket_mid) {
high = mid ;
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_prime_rand.c b/bn_mp_prime_rand.c
index dbf3975..1cfe514 100644
--- a/bn_mp_prime_rand.c
+++ b/bn_mp_prime_rand.c
@@ -45,7 +45,7 @@ mp_err s_mp_prime_random_ex(mp_int *a, int t, int size, int flags, private_mp_pr
}
/* calc the maskAND value for the MSbyte*/
- maskAND = ((size&7) == 0) ? 0xFF : (unsigned char)(0xFF >> (8 - (size & 7)));
+ maskAND = ((size&7) == 0) ? 0xFFu : (unsigned char)(0xFFu >> (8 - (size & 7)));
/* calc the maskOR_msb */
maskOR_msb = 0;
@@ -55,9 +55,9 @@ mp_err s_mp_prime_random_ex(mp_int *a, int t, int size, int flags, private_mp_pr
}
/* get the maskOR_lsb */
- maskOR_lsb = 1;
+ maskOR_lsb = 1u;
if ((flags & MP_PRIME_BBS) != 0) {
- maskOR_lsb |= 3;
+ maskOR_lsb |= 3u;
}
do {
diff --git a/bn_mp_rand.c b/bn_mp_rand.c
index 1818dd0..7e9052c 100644
--- a/bn_mp_rand.c
+++ b/bn_mp_rand.c
@@ -30,7 +30,7 @@ mp_err mp_rand(mp_int *a, int digits)
}
/* TODO: We ensure that the highest digit is nonzero. Should this be removed? */
- while ((a->dp[digits - 1] & MP_MASK) == 0) {
+ while ((a->dp[digits - 1] & MP_MASK) == 0u) {
if ((err = s_mp_rand_source(a->dp + digits - 1, sizeof(mp_digit))) != MP_OKAY) {
return err;
}
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.c b/bn_s_mp_exptmod.c
index b1cc0e9..5d5510f 100644
--- a/bn_s_mp_exptmod.c
+++ b/bn_s_mp_exptmod.c
@@ -146,7 +146,7 @@ mp_err s_mp_exptmod(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y
}
/* grab the next msb from the exponent */
- y = (buf >> (mp_digit)(MP_DIGIT_BIT - 1)) & 1;
+ y = (buf >> (mp_digit)(MP_DIGIT_BIT - 1)) & 1uL;
buf <<= (mp_digit)1;
/* if the bit is zero and mode == 0 then we ignore it
diff --git a/bn_s_mp_exptmod_fast.c b/bn_s_mp_exptmod_fast.c
index 6b4483c..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
@@ -200,7 +200,7 @@ mp_err s_mp_exptmod_fast(const mp_int *G, const mp_int *X, const mp_int *P, mp_i
}
/* grab the next msb from the exponent */
- y = (mp_digit)(buf >> (MP_DIGIT_BIT - 1)) & 1;
+ y = (mp_digit)(buf >> (MP_DIGIT_BIT - 1)) & 1uL;
buf <<= (mp_digit)1;
/* if the bit is zero and mode == 0 then we ignore it
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