Skip to content

Commit

Permalink
Merge pull request #292 from fperrad/20190523_lint
Browse files Browse the repository at this point in the history
some linting
  • Loading branch information
sjaeckel authored May 31, 2019
2 parents 431ea33 + 25ff85d commit 2b41c95
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion bn_mp_ilogb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;
Expand Down
4 changes: 2 additions & 2 deletions bn_mp_montgomery_reduce.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_mul.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ mp_err mp_mul(const mp_int *a, const mp_int *b, mp_int *c)
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
Expand Down
6 changes: 3 additions & 3 deletions bn_mp_prime_rand.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_rand.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion bn_mp_sqr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bn_s_mp_exptmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions bn_s_mp_exptmod_fast.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bn_s_mp_montgomery_reduce_fast.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion bn_s_mp_mul_digs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion bn_s_mp_mul_high_digs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion tommath.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2b41c95

Please sign in to comment.