Merge pull request #319 from libtom/fix/clang-tidy fix clang-tidy warnings
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
diff --git a/bn_mp_reduce.c b/bn_mp_reduce.c
index d5d3fb1..5748550 100644
--- a/bn_mp_reduce.c
+++ b/bn_mp_reduce.c
@@ -64,10 +64,12 @@ mp_err mp_reduce(mp_int *x, const mp_int *m, const mp_int *mu)
/* If x < 0, add b**(k+1) to it */
if (mp_cmp_d(x, 0uL) == MP_LT) {
mp_set(&q, 1uL);
- if ((err = mp_lshd(&q, um + 1)) != MP_OKAY)
+ if ((err = mp_lshd(&q, um + 1)) != MP_OKAY) {
goto CLEANUP;
- if ((err = mp_add(x, &q, x)) != MP_OKAY)
+ }
+ if ((err = mp_add(x, &q, x)) != MP_OKAY) {
goto CLEANUP;
+ }
}
/* Back off if it's too big */
diff --git a/bn_s_mp_invmod_slow.c b/bn_s_mp_invmod_slow.c
index faf6221..c03a3d7 100644
--- a/bn_s_mp_invmod_slow.c
+++ b/bn_s_mp_invmod_slow.c
@@ -125,8 +125,9 @@ top:
}
/* if not zero goto step 4 */
- if (!MP_IS_ZERO(&u))
+ if (!MP_IS_ZERO(&u)) {
goto top;
+ }
/* now a = C, b = D, gcd == g*v */
diff --git a/bn_s_mp_karatsuba_mul.c b/bn_s_mp_karatsuba_mul.c
index 6ef96c7..85899fb 100644
--- a/bn_s_mp_karatsuba_mul.c
+++ b/bn_s_mp_karatsuba_mul.c
@@ -45,22 +45,29 @@ mp_err s_mp_karatsuba_mul(const mp_int *a, const mp_int *b, mp_int *c)
B = B >> 1;
/* init copy all the temps */
- if (mp_init_size(&x0, B) != MP_OKAY)
+ if (mp_init_size(&x0, B) != MP_OKAY) {
goto LBL_ERR;
- if (mp_init_size(&x1, a->used - B) != MP_OKAY)
+ }
+ if (mp_init_size(&x1, a->used - B) != MP_OKAY) {
goto X0;
- if (mp_init_size(&y0, B) != MP_OKAY)
+ }
+ if (mp_init_size(&y0, B) != MP_OKAY) {
goto X1;
- if (mp_init_size(&y1, b->used - B) != MP_OKAY)
+ }
+ if (mp_init_size(&y1, b->used - B) != MP_OKAY) {
goto Y0;
+ }
/* init temps */
- if (mp_init_size(&t1, B * 2) != MP_OKAY)
+ if (mp_init_size(&t1, B * 2) != MP_OKAY) {
goto Y1;
- if (mp_init_size(&x0y0, B * 2) != MP_OKAY)
+ }
+ if (mp_init_size(&x0y0, B * 2) != MP_OKAY) {
goto T1;
- if (mp_init_size(&x1y1, B * 2) != MP_OKAY)
+ }
+ if (mp_init_size(&x1y1, B * 2) != MP_OKAY) {
goto X0Y0;
+ }
/* now shift the digits */
x0.used = y0.used = B;
@@ -103,35 +110,46 @@ mp_err s_mp_karatsuba_mul(const mp_int *a, const mp_int *b, mp_int *c)
/* now calc the products x0y0 and x1y1 */
/* after this x0 is no longer required, free temp [x0==t2]! */
- if (mp_mul(&x0, &y0, &x0y0) != MP_OKAY)
+ if (mp_mul(&x0, &y0, &x0y0) != MP_OKAY) {
goto X1Y1; /* x0y0 = x0*y0 */
- if (mp_mul(&x1, &y1, &x1y1) != MP_OKAY)
+ }
+ if (mp_mul(&x1, &y1, &x1y1) != MP_OKAY) {
goto X1Y1; /* x1y1 = x1*y1 */
+ }
/* now calc x1+x0 and y1+y0 */
- if (s_mp_add(&x1, &x0, &t1) != MP_OKAY)
+ if (s_mp_add(&x1, &x0, &t1) != MP_OKAY) {
goto X1Y1; /* t1 = x1 - x0 */
- if (s_mp_add(&y1, &y0, &x0) != MP_OKAY)
+ }
+ if (s_mp_add(&y1, &y0, &x0) != MP_OKAY) {
goto X1Y1; /* t2 = y1 - y0 */
- if (mp_mul(&t1, &x0, &t1) != MP_OKAY)
+ }
+ if (mp_mul(&t1, &x0, &t1) != MP_OKAY) {
goto X1Y1; /* t1 = (x1 + x0) * (y1 + y0) */
+ }
/* add x0y0 */
- if (mp_add(&x0y0, &x1y1, &x0) != MP_OKAY)
+ if (mp_add(&x0y0, &x1y1, &x0) != MP_OKAY) {
goto X1Y1; /* t2 = x0y0 + x1y1 */
- if (s_mp_sub(&t1, &x0, &t1) != MP_OKAY)
+ }
+ if (s_mp_sub(&t1, &x0, &t1) != MP_OKAY) {
goto X1Y1; /* t1 = (x1+x0)*(y1+y0) - (x1y1 + x0y0) */
+ }
/* shift by B */
- if (mp_lshd(&t1, B) != MP_OKAY)
+ if (mp_lshd(&t1, B) != MP_OKAY) {
goto X1Y1; /* t1 = (x0y0 + x1y1 - (x1-x0)*(y1-y0))<<B */
- if (mp_lshd(&x1y1, B * 2) != MP_OKAY)
+ }
+ if (mp_lshd(&x1y1, B * 2) != MP_OKAY) {
goto X1Y1; /* x1y1 = x1y1 << 2*B */
+ }
- if (mp_add(&x0y0, &t1, &t1) != MP_OKAY)
+ if (mp_add(&x0y0, &t1, &t1) != MP_OKAY) {
goto X1Y1; /* t1 = x0y0 + t1 */
- if (mp_add(&t1, &x1y1, c) != MP_OKAY)
+ }
+ if (mp_add(&t1, &x1y1, c) != MP_OKAY) {
goto X1Y1; /* t1 = x0y0 + t1 + x1y1 */
+ }
/* Algorithm succeeded set the return code to MP_OKAY */
err = MP_OKAY;