Skip to content

Commit aa4864e

Browse files
authored
Merge pull request #319 from libtom/fix/clang-tidy
fix clang-tidy warnings
2 parents dc7c522 + e491b4d commit aa4864e

File tree

3 files changed

+42
-21
lines changed

3 files changed

+42
-21
lines changed

bn_mp_reduce.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,12 @@ mp_err mp_reduce(mp_int *x, const mp_int *m, const mp_int *mu)
6464
/* If x < 0, add b**(k+1) to it */
6565
if (mp_cmp_d(x, 0uL) == MP_LT) {
6666
mp_set(&q, 1uL);
67-
if ((err = mp_lshd(&q, um + 1)) != MP_OKAY)
67+
if ((err = mp_lshd(&q, um + 1)) != MP_OKAY) {
6868
goto CLEANUP;
69-
if ((err = mp_add(x, &q, x)) != MP_OKAY)
69+
}
70+
if ((err = mp_add(x, &q, x)) != MP_OKAY) {
7071
goto CLEANUP;
72+
}
7173
}
7274

7375
/* Back off if it's too big */

bn_s_mp_invmod_slow.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,9 @@ mp_err s_mp_invmod_slow(const mp_int *a, const mp_int *b, mp_int *c)
125125
}
126126

127127
/* if not zero goto step 4 */
128-
if (!MP_IS_ZERO(&u))
128+
if (!MP_IS_ZERO(&u)) {
129129
goto top;
130+
}
130131

131132
/* now a = C, b = D, gcd == g*v */
132133

bn_s_mp_karatsuba_mul.c

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,29 @@ mp_err s_mp_karatsuba_mul(const mp_int *a, const mp_int *b, mp_int *c)
4545
B = B >> 1;
4646

4747
/* init copy all the temps */
48-
if (mp_init_size(&x0, B) != MP_OKAY)
48+
if (mp_init_size(&x0, B) != MP_OKAY) {
4949
goto LBL_ERR;
50-
if (mp_init_size(&x1, a->used - B) != MP_OKAY)
50+
}
51+
if (mp_init_size(&x1, a->used - B) != MP_OKAY) {
5152
goto X0;
52-
if (mp_init_size(&y0, B) != MP_OKAY)
53+
}
54+
if (mp_init_size(&y0, B) != MP_OKAY) {
5355
goto X1;
54-
if (mp_init_size(&y1, b->used - B) != MP_OKAY)
56+
}
57+
if (mp_init_size(&y1, b->used - B) != MP_OKAY) {
5558
goto Y0;
59+
}
5660

5761
/* init temps */
58-
if (mp_init_size(&t1, B * 2) != MP_OKAY)
62+
if (mp_init_size(&t1, B * 2) != MP_OKAY) {
5963
goto Y1;
60-
if (mp_init_size(&x0y0, B * 2) != MP_OKAY)
64+
}
65+
if (mp_init_size(&x0y0, B * 2) != MP_OKAY) {
6166
goto T1;
62-
if (mp_init_size(&x1y1, B * 2) != MP_OKAY)
67+
}
68+
if (mp_init_size(&x1y1, B * 2) != MP_OKAY) {
6369
goto X0Y0;
70+
}
6471

6572
/* now shift the digits */
6673
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)
103110

104111
/* now calc the products x0y0 and x1y1 */
105112
/* after this x0 is no longer required, free temp [x0==t2]! */
106-
if (mp_mul(&x0, &y0, &x0y0) != MP_OKAY)
113+
if (mp_mul(&x0, &y0, &x0y0) != MP_OKAY) {
107114
goto X1Y1; /* x0y0 = x0*y0 */
108-
if (mp_mul(&x1, &y1, &x1y1) != MP_OKAY)
115+
}
116+
if (mp_mul(&x1, &y1, &x1y1) != MP_OKAY) {
109117
goto X1Y1; /* x1y1 = x1*y1 */
118+
}
110119

111120
/* now calc x1+x0 and y1+y0 */
112-
if (s_mp_add(&x1, &x0, &t1) != MP_OKAY)
121+
if (s_mp_add(&x1, &x0, &t1) != MP_OKAY) {
113122
goto X1Y1; /* t1 = x1 - x0 */
114-
if (s_mp_add(&y1, &y0, &x0) != MP_OKAY)
123+
}
124+
if (s_mp_add(&y1, &y0, &x0) != MP_OKAY) {
115125
goto X1Y1; /* t2 = y1 - y0 */
116-
if (mp_mul(&t1, &x0, &t1) != MP_OKAY)
126+
}
127+
if (mp_mul(&t1, &x0, &t1) != MP_OKAY) {
117128
goto X1Y1; /* t1 = (x1 + x0) * (y1 + y0) */
129+
}
118130

119131
/* add x0y0 */
120-
if (mp_add(&x0y0, &x1y1, &x0) != MP_OKAY)
132+
if (mp_add(&x0y0, &x1y1, &x0) != MP_OKAY) {
121133
goto X1Y1; /* t2 = x0y0 + x1y1 */
122-
if (s_mp_sub(&t1, &x0, &t1) != MP_OKAY)
134+
}
135+
if (s_mp_sub(&t1, &x0, &t1) != MP_OKAY) {
123136
goto X1Y1; /* t1 = (x1+x0)*(y1+y0) - (x1y1 + x0y0) */
137+
}
124138

125139
/* shift by B */
126-
if (mp_lshd(&t1, B) != MP_OKAY)
140+
if (mp_lshd(&t1, B) != MP_OKAY) {
127141
goto X1Y1; /* t1 = (x0y0 + x1y1 - (x1-x0)*(y1-y0))<<B */
128-
if (mp_lshd(&x1y1, B * 2) != MP_OKAY)
142+
}
143+
if (mp_lshd(&x1y1, B * 2) != MP_OKAY) {
129144
goto X1Y1; /* x1y1 = x1y1 << 2*B */
145+
}
130146

131-
if (mp_add(&x0y0, &t1, &t1) != MP_OKAY)
147+
if (mp_add(&x0y0, &t1, &t1) != MP_OKAY) {
132148
goto X1Y1; /* t1 = x0y0 + t1 */
133-
if (mp_add(&t1, &x1y1, c) != MP_OKAY)
149+
}
150+
if (mp_add(&t1, &x1y1, c) != MP_OKAY) {
134151
goto X1Y1; /* t1 = x0y0 + t1 + x1y1 */
152+
}
135153

136154
/* Algorithm succeeded set the return code to MP_OKAY */
137155
err = MP_OKAY;

0 commit comments

Comments
 (0)