Commit 0dbea3b69ff9340dbec0c76c9553929a7cc58775

Francois Perrad 2017-12-10T10:19:11

explicit precedence operator with parenthesis

diff --git a/demo/demo.c b/demo/demo.c
index d60d559..57afbaf 100644
--- a/demo/demo.c
+++ b/demo/demo.c
@@ -746,7 +746,7 @@ printf("compare no compare!\n"); return EXIT_FAILURE;
 
          mp_div_2d(&a, rr, &a, &e);
          a.sign = b.sign;
-         if (a.used == b.used && a.used == 0) {
+         if ((a.used == b.used) && (a.used == 0)) {
             a.sign = b.sign = MP_ZPOS;
          }
          if (mp_cmp(&a, &b) != MP_EQ) {
@@ -847,7 +847,7 @@ printf("compare no compare!\n"); return EXIT_FAILURE;
          mp_read_radix(&d, buf, 64);
 
          mp_div(&a, &b, &e, &f);
-         if (mp_cmp(&c, &e) != MP_EQ || mp_cmp(&d, &f) != MP_EQ) {
+         if ((mp_cmp(&c, &e) != MP_EQ) || (mp_cmp(&d, &f) != MP_EQ)) {
             printf("div %lu %d, %d, failure!\n", div_n, mp_cmp(&c, &e),
                    mp_cmp(&d, &f));
             draw(&a);
diff --git a/demo/timing.c b/demo/timing.c
index e7959f7..9080723 100644
--- a/demo/timing.c
+++ b/demo/timing.c
@@ -179,7 +179,7 @@ int main(void)
       TOOM_SQR_CUTOFF = (ix == 2) ? old_toom_s : 9999;
 
       log = FOPEN((ix == 0) ? "logs/mult.log" : (ix == 1) ? "logs/mult_kara.log" : "logs/mult_toom.log", "w");
-      for (cnt = 4; cnt <= 10240 / DIGIT_BIT; cnt += 2) {
+      for (cnt = 4; cnt <= (10240 / DIGIT_BIT); cnt += 2) {
          SLEEP;
          mp_rand(&a, cnt);
          mp_rand(&b, cnt);
@@ -200,7 +200,7 @@ int main(void)
       FCLOSE(log);
 
       log = FOPEN((ix == 0) ? "logs/sqr.log" : (ix == 1) ? "logs/sqr_kara.log" : "logs/sqr_toom.log", "w");
-      for (cnt = 4; cnt <= 10240 / DIGIT_BIT; cnt += 2) {
+      for (cnt = 4; cnt <= (10240 / DIGIT_BIT); cnt += 2) {
          SLEEP;
          mp_rand(&a, cnt);
          rr = 0;
@@ -290,7 +290,7 @@ int main(void)
          }
          printf("Exponentiating\t%4d-bit => %9" PRIu64 "/sec, %9" PRIu64 " cycles\n",
                 mp_count_bits(&a), CLK_PER_SEC / tt, tt);
-         FPRINTF(n < 4 ? logd : (n < 9) ? logc : (n < 16) ? logb : log,
+         FPRINTF((n < 4) ? logd : (n < 9) ? logc : (n < 16) ? logb : log,
                  "%d %9" PRIu64 "\n", mp_count_bits(&a), tt);
       }
    }
diff --git a/etc/2kprime.c b/etc/2kprime.c
index 47c3b88..e84d499 100644
--- a/etc/2kprime.c
+++ b/etc/2kprime.c
@@ -32,7 +32,7 @@ top:
             break;
          }
 
-         if (clock() - t1 > CLOCKS_PER_SEC) {
+         if ((clock() - t1) > CLOCKS_PER_SEC) {
             printf(".");
             fflush(stdout);
 //            sleep((clock() - t1 + CLOCKS_PER_SEC/2)/CLOCKS_PER_SEC);
diff --git a/etc/mersenne.c b/etc/mersenne.c
index 99babb1..75dd9d9 100644
--- a/etc/mersenne.c
+++ b/etc/mersenne.c
@@ -32,7 +32,7 @@ static int is_mersenne(long s, int *pp)
    mp_set(&u, 4);
 
    /* for k=1 to s-2 do */
-   for (k = 1; k <= s - 2; k++) {
+   for (k = 1; k <= (s - 2); k++) {
       /* u = u^2 - 2 mod n */
       if ((res = mp_sqr(&u, &u)) != MP_OKAY) {
          goto LBL_MU;
@@ -79,7 +79,7 @@ static long i_sqrt(long x)
       x2 = x1 - ((x1 * x1) - x) / (2 * x1);
    } while (x1 != x2);
 
-   if (x1 * x1 > x) {
+   if ((x1 * x1) > x) {
       --x1;
    }
 
diff --git a/etc/pprime.c b/etc/pprime.c
index ea77181..b4058c2 100644
--- a/etc/pprime.c
+++ b/etc/pprime.c
@@ -21,7 +21,7 @@ static mp_digit i_sqrt(mp_word x)
       x2 = x1 - ((x1 * x1) - x) / (2 * x1);
    } while (x1 != x2);
 
-   if (x1 * x1 > x) {
+   if ((x1 * x1) > x) {
       --x1;
    }