explicit condition (part C)

This commit is contained in:
Francois Perrad 2015-10-25 16:49:26 +01:00 committed by Steffen Jaeckel
parent e25f1701e4
commit 38f90d1b17
9 changed files with 21 additions and 21 deletions

View File

@ -20,7 +20,7 @@ static int s_is_power_of_two(mp_digit b, int *p)
int x;
/* fast return if no power of two */
if ((b==0) || (b & (b-1))) {
if ((b == 0) || ((b & (b-1)) != 0)) {
return 0;
}

View File

@ -48,7 +48,7 @@ int mp_export(void* rop, size_t* countp, int order, size_t size,
nail_bytes = nails / 8;
bits = mp_count_bits(&t);
count = bits / (size * 8 - nails) + (bits % (size * 8 - nails) ? 1 : 0);
count = bits / (size * 8 - nails) + ((bits % (size * 8 - nails) != 0) ? 1 : 0);
for (i = 0; i < count; ++i) {
for (j = 0; j < size; ++j) {
@ -74,7 +74,7 @@ int mp_export(void* rop, size_t* countp, int order, size_t size,
mp_clear(&t);
if (countp) {
if (countp != NULL) {
*countp = count;
}

View File

@ -30,10 +30,10 @@ int mp_expt_d_ex (mp_int * a, mp_digit b, mp_int * c, int fast)
/* set initial result */
mp_set (c, 1);
if (fast) {
if (fast != 0) {
while (b > 0) {
/* if the bit is set multiply */
if (b & 1) {
if ((b & 1) != 0) {
if ((res = mp_mul (c, &g, c)) != MP_OKAY) {
mp_clear (&g);
return res;

View File

@ -37,7 +37,7 @@ int mp_init_multi(mp_int *mp, ...)
/* now start cleaning up */
cur_arg = mp;
va_start(clean_args, mp);
while (n--) {
while (n-- != 0) {
mp_clear(cur_arg);
cur_arg = va_arg(clean_args, mp_int*);
}

View File

@ -82,13 +82,13 @@ int mp_is_square(mp_int *arg,int *ret)
* free "t" so the easiest way is to goto ERR. We know that res
* is already equal to MP_OKAY from the mp_mod call
*/
if ( (1L<<(r%11)) & 0x5C4L ) goto ERR;
if ( (1L<<(r%13)) & 0x9E4L ) goto ERR;
if ( (1L<<(r%17)) & 0x5CE8L ) goto ERR;
if ( (1L<<(r%19)) & 0x4F50CL ) goto ERR;
if ( (1L<<(r%23)) & 0x7ACCA0L ) goto ERR;
if ( (1L<<(r%29)) & 0xC2EDD0CL ) goto ERR;
if ( (1L<<(r%31)) & 0x6DE2B848L ) goto ERR;
if (((1L<<(r%11)) & 0x5C4L) != 0L) goto ERR;
if (((1L<<(r%13)) & 0x9E4L) != 0L) goto ERR;
if (((1L<<(r%17)) & 0x5CE8L) != 0L) goto ERR;
if (((1L<<(r%19)) & 0x4F50CL) != 0L) goto ERR;
if (((1L<<(r%23)) & 0x7ACCA0L) != 0L) goto ERR;
if (((1L<<(r%29)) & 0xC2EDD0CL) != 0L) goto ERR;
if (((1L<<(r%31)) & 0x6DE2B848L) != 0L) goto ERR;
/* Final check - is sqr(sqrt(arg)) == arg ? */
if ((res = mp_sqrt(arg,&t)) != MP_OKAY) {

View File

@ -31,7 +31,7 @@ mp_mod (mp_int * a, mp_int * b, mp_int * c)
return res;
}
if (mp_iszero(&t) || t.sign == b->sign) {
if (mp_iszero(&t) != MP_NO || t.sign == b->sign) {
res = MP_OKAY;
mp_exch (&t, c);
} else {

View File

@ -85,7 +85,7 @@ mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho)
/* propagate carries upwards as required*/
while (u) {
while (u != 0) {
*tmpx += u;
u = *tmpx >> DIGIT_BIT;
*tmpx++ &= MP_MASK;

View File

@ -41,7 +41,7 @@ int mp_prime_random_ex(mp_int *a, int t, int size, int flags, ltm_prime_callback
}
/* LTM_PRIME_SAFE implies LTM_PRIME_BBS */
if (flags & LTM_PRIME_SAFE) {
if ((flags & LTM_PRIME_SAFE) != 0) {
flags |= LTM_PRIME_BBS;
}
@ -60,13 +60,13 @@ int mp_prime_random_ex(mp_int *a, int t, int size, int flags, ltm_prime_callback
/* calc the maskOR_msb */
maskOR_msb = 0;
maskOR_msb_offset = ((size & 7) == 1) ? 1 : 0;
if (flags & LTM_PRIME_2MSB_ON) {
if ((flags & LTM_PRIME_2MSB_ON) != 0) {
maskOR_msb |= 0x80 >> ((9 - size) & 7);
}
/* get the maskOR_lsb */
maskOR_lsb = 1;
if (flags & LTM_PRIME_BBS) {
if ((flags & LTM_PRIME_BBS) != 0) {
maskOR_lsb |= 3;
}
@ -94,7 +94,7 @@ int mp_prime_random_ex(mp_int *a, int t, int size, int flags, ltm_prime_callback
continue;
}
if (flags & LTM_PRIME_SAFE) {
if ((flags & LTM_PRIME_SAFE) != 0) {
/* see if (a-1)/2 is prime */
if ((err = mp_sub_d(a, 1, a)) != MP_OKAY) { goto error; }
if ((err = mp_div_2(a, a)) != MP_OKAY) { goto error; }
@ -104,7 +104,7 @@ int mp_prime_random_ex(mp_int *a, int t, int size, int flags, ltm_prime_callback
}
} while (res == MP_NO);
if (flags & LTM_PRIME_SAFE) {
if ((flags & LTM_PRIME_SAFE) != 0) {
/* restore a to the original value */
if ((err = mp_mul_2(a, a)) != MP_OKAY) { goto error; }
if ((err = mp_add_d(a, 1, a)) != MP_OKAY) { goto error; }

View File

@ -43,7 +43,7 @@ int mp_read_radix (mp_int * a, const char *str, int radix)
mp_zero (a);
/* process each digit of the string */
while (*str) {
while (*str != '\0') {
/* if the radix <= 36 the conversion is case insensitive
* this allows numbers like 1AB and 1ab to represent the same value
* [e.g. in hex]