Commit 38f90d1b1777048798f3881c61896b34f7dc4261

Francois Perrad 2015-10-25T16:49:26

explicit condition (part C)

diff --git a/bn_mp_div_d.c b/bn_mp_div_d.c
index 579221d..55f3831 100644
--- a/bn_mp_div_d.c
+++ b/bn_mp_div_d.c
@@ -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;
    }
 
diff --git a/bn_mp_export.c b/bn_mp_export.c
index 3712fc7..7829315 100644
--- a/bn_mp_export.c
+++ b/bn_mp_export.c
@@ -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;
 	}
 
diff --git a/bn_mp_expt_d_ex.c b/bn_mp_expt_d_ex.c
index ab840b8..bc15878 100644
--- a/bn_mp_expt_d_ex.c
+++ b/bn_mp_expt_d_ex.c
@@ -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;
diff --git a/bn_mp_init_multi.c b/bn_mp_init_multi.c
index 830068c..388b813 100644
--- a/bn_mp_init_multi.c
+++ b/bn_mp_init_multi.c
@@ -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*);
             }
diff --git a/bn_mp_is_square.c b/bn_mp_is_square.c
index 5348ca9..8c2f221 100644
--- a/bn_mp_is_square.c
+++ b/bn_mp_is_square.c
@@ -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) {
diff --git a/bn_mp_mod.c b/bn_mp_mod.c
index 589972d..f7eb1c4 100644
--- a/bn_mp_mod.c
+++ b/bn_mp_mod.c
@@ -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 {
diff --git a/bn_mp_montgomery_reduce.c b/bn_mp_montgomery_reduce.c
index ffdd127..e92a988 100644
--- a/bn_mp_montgomery_reduce.c
+++ b/bn_mp_montgomery_reduce.c
@@ -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;
diff --git a/bn_mp_prime_random_ex.c b/bn_mp_prime_random_ex.c
index 981a8fe..3dfc425 100644
--- a/bn_mp_prime_random_ex.c
+++ b/bn_mp_prime_random_ex.c
@@ -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; }
diff --git a/bn_mp_read_radix.c b/bn_mp_read_radix.c
index 178339e..31b12ac 100644
--- a/bn_mp_read_radix.c
+++ b/bn_mp_read_radix.c
@@ -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]