Merge pull request #387 from fperrad/20191019_lint some linting (cherry picked from commit 8095b3b61240628f052153d6c37539955632564e)
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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
diff --git a/bn_mp_prime_next_prime.c b/bn_mp_prime_next_prime.c
index 1e971fa..d656565 100644
--- a/bn_mp_prime_next_prime.c
+++ b/bn_mp_prime_next_prime.c
@@ -10,9 +10,10 @@
*/
mp_err mp_prime_next_prime(mp_int *a, int t, int bbs_style)
{
- int x, y, cmp;
- mp_err err;
- mp_bool res = MP_NO;
+ int x, y;
+ mp_ord cmp;
+ mp_err err;
+ mp_bool res = MP_NO;
mp_digit res_tab[PRIVATE_MP_PRIME_TAB_SIZE], step, kstep;
mp_int b;
diff --git a/bn_s_mp_toom_mul.c b/bn_s_mp_toom_mul.c
index 8efd803..86901b0 100644
--- a/bn_s_mp_toom_mul.c
+++ b/bn_s_mp_toom_mul.c
@@ -32,7 +32,8 @@
mp_err s_mp_toom_mul(const mp_int *a, const mp_int *b, mp_int *c)
{
mp_int S1, S2, T1, a0, a1, a2, b0, b1, b2;
- int err, B, count;
+ int B, count;
+ mp_err err;
/* init temps */
if ((err = mp_init_multi(&S1, &S2, &T1, NULL)) != MP_OKAY) {
diff --git a/bn_s_mp_toom_sqr.c b/bn_s_mp_toom_sqr.c
index 9eaa9d0..f2ffb30 100644
--- a/bn_s_mp_toom_sqr.c
+++ b/bn_s_mp_toom_sqr.c
@@ -22,7 +22,8 @@ mp_err s_mp_toom_sqr(const mp_int *a, mp_int *b)
{
mp_int S0, a0, a1, a2;
mp_digit *tmpa, *tmpc;
- mp_err err, B, count;
+ int B, count;
+ mp_err err;
/* init temps */
diff --git a/etc/2kprime.c b/etc/2kprime.c
index 55cb5f4..95ed2de 100644
--- a/etc/2kprime.c
+++ b/etc/2kprime.c
@@ -8,7 +8,7 @@ int main(void)
{
char buf[2000];
size_t x;
- int y;
+ mp_bool y;
mp_int q, p;
FILE *out;
clock_t t1;
@@ -43,7 +43,7 @@ top:
/* quick test on q */
mp_prime_is_prime(&q, 1, &y);
- if (y == 0) {
+ if (y == MP_NO) {
continue;
}
@@ -51,20 +51,20 @@ top:
mp_sub_d(&q, 1uL, &p);
mp_div_2(&p, &p);
mp_prime_is_prime(&p, 3, &y);
- if (y == 0) {
+ if (y == MP_NO) {
continue;
}
/* test on q */
mp_prime_is_prime(&q, 3, &y);
- if (y == 0) {
+ if (y == MP_NO) {
continue;
}
break;
}
- if (y == 0) {
+ if (y == MP_NO) {
++sizes[x];
goto top;
}
diff --git a/etc/drprime.c b/etc/drprime.c
index 146455e..64e31ef 100644
--- a/etc/drprime.c
+++ b/etc/drprime.c
@@ -5,7 +5,8 @@ static int sizes[] = { 1+256/MP_DIGIT_BIT, 1+512/MP_DIGIT_BIT, 1+768/MP_DIGIT_BI
int main(void)
{
- int res, x, y;
+ mp_bool res;
+ int x, y;
char buf[4096];
FILE *out;
mp_int a, b;
@@ -29,23 +30,23 @@ top:
a.used = sizes[x];
/* now loop */
- res = 0;
+ res = MP_NO;
for (;;) {
a.dp[0] += 4uL;
if (a.dp[0] >= MP_MASK) break;
mp_prime_is_prime(&a, 1, &res);
- if (res == 0) continue;
+ if (res == MP_NO) continue;
printf(".");
fflush(stdout);
mp_sub_d(&a, 1uL, &b);
mp_div_2(&b, &b);
mp_prime_is_prime(&b, 3, &res);
- if (res == 0) continue;
+ if (res == MP_NO) continue;
mp_prime_is_prime(&a, 3, &res);
- if (res == 1) break;
+ if (res == MP_YES) break;
}
- if (res != 1) {
+ if (res != MP_YES) {
printf("Error not DR modulus\n");
sizes[x] += 1;
goto top;
diff --git a/etc/mersenne.c b/etc/mersenne.c
index f6d7cb6..0c9f52f 100644
--- a/etc/mersenne.c
+++ b/etc/mersenne.c
@@ -5,12 +5,13 @@
#include <time.h>
#include <tommath.h>
-static int is_mersenne(long s, int *pp)
+static mp_err is_mersenne(long s, mp_bool *pp)
{
mp_int n, u;
- int res, k;
+ mp_err res;
+ int k;
- *pp = 0;
+ *pp = MP_NO;
if ((res = mp_init(&n)) != MP_OKAY) {
return res;
@@ -55,9 +56,9 @@ static int is_mersenne(long s, int *pp)
}
/* if u == 0 then its prime */
- if (mp_iszero(&u) == 1) {
+ if (mp_iszero(&u) == MP_YES) {
mp_prime_is_prime(&n, 8, pp);
- if (*pp != 1) printf("FAILURE\n");
+ if (*pp != MP_YES) printf("FAILURE\n");
}
res = MP_OKAY;
@@ -102,7 +103,7 @@ static int isprime(long k)
int main(void)
{
- int pp;
+ mp_bool pp;
long k;
clock_t tt;
@@ -118,7 +119,7 @@ int main(void)
return -1;
}
- if (pp == 1) {
+ if (pp == MP_YES) {
/* count time */
tt = clock() - tt;
diff --git a/etc/pprime.c b/etc/pprime.c
index fa622f8..009a18c 100644
--- a/etc/pprime.c
+++ b/etc/pprime.c
@@ -179,10 +179,11 @@ static mp_digit prime_digit(void)
/* makes a prime of at least k bits */
-static int pprime(int k, int li, mp_int *p, mp_int *q)
+static mp_err pprime(int k, int li, mp_int *p, mp_int *q)
{
mp_int a, b, c, n, x, y, z, v;
- int res, ii;
+ mp_err res;
+ int ii;
static const mp_digit bases[] = { 2, 3, 5, 7, 11, 13, 17, 19 };
/* single digit ? */
diff --git a/etc/tune.c b/etc/tune.c
index 057e372..bc2cdfe 100644
--- a/etc/tune.c
+++ b/etc/tune.c
@@ -61,7 +61,8 @@ static int s_offset = 1;
#define s_mp_mul(a, b, c) s_mp_mul_digs(a, b, c, (a)->used + (b)->used + 1)
static uint64_t s_time_mul(int size)
{
- int x, e;
+ int x;
+ mp_err e;
mp_int a, b, c, d;
uint64_t t1;
@@ -106,7 +107,8 @@ LTM_ERR:
static uint64_t s_time_sqr(int size)
{
- int x, e;
+ int x;
+ mp_err e;
mp_int a, b, c;
uint64_t t1;
diff --git a/tommath.h b/tommath.h
index 8dd3bb3..e87bb08 100644
--- a/tommath.h
+++ b/tommath.h
@@ -135,7 +135,7 @@ typedef enum {
MP_MEM = -2, /* out of mem */
MP_VAL = -3, /* invalid input */
MP_ITER = -4, /* maximum iterations reached */
- MP_BUF = -5, /* buffer overflow, supplied buffer too small */
+ MP_BUF = -5 /* buffer overflow, supplied buffer too small */
} mp_err;
typedef enum {
MP_LSB_FIRST = -1,