fix some usages of enum types
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
diff --git a/bn_mp_ilogb.c b/bn_mp_ilogb.c
index d72c952..efcd5f9 100644
--- a/bn_mp_ilogb.c
+++ b/bn_mp_ilogb.c
@@ -73,7 +73,7 @@ static mp_digit s_digit_ilogb(mp_digit base, mp_digit n)
mp_err mp_ilogb(const mp_int *a, mp_digit base, mp_int *c)
{
mp_err err;
- int cmp;
+ mp_ord cmp;
unsigned int high, low, mid;
mp_int bracket_low, bracket_high, bracket_mid, t, bi_base;
mp_digit tmp;
@@ -90,8 +90,7 @@ mp_err mp_ilogb(const mp_int *a, mp_digit base, mp_int *c)
return MP_VAL;
}
if (base == 2u) {
- cmp = mp_count_bits(a) - 1;
- mp_set_int(c, (unsigned long)cmp);
+ mp_set_int(c, (unsigned long)(mp_count_bits(a) - 1));
return err;
}
if (a->used == 1) {
diff --git a/bn_mp_n_root_ex.c b/bn_mp_n_root_ex.c
index c37f575..8705c6a 100644
--- a/bn_mp_n_root_ex.c
+++ b/bn_mp_n_root_ex.c
@@ -15,7 +15,7 @@
mp_err mp_n_root_ex(const mp_int *a, mp_digit b, mp_int *c, int fast)
{
mp_int t1, t2, t3, a_;
- int cmp;
+ mp_ord cmp;
int ilog2;
mp_err res;
diff --git a/bn_mp_prime_is_prime.c b/bn_mp_prime_is_prime.c
index db94dec..e3f2436 100644
--- a/bn_mp_prime_is_prime.c
+++ b/bn_mp_prime_is_prime.c
@@ -51,7 +51,7 @@ mp_err mp_prime_is_prime(const mp_int *a, int t, mp_bool *result)
if ((err = mp_is_square(a, &res)) != MP_OKAY) {
return err;
}
- if (res != 0) {
+ if (res != MP_NO) {
return MP_OKAY;
}
diff --git a/bn_mp_prime_strong_lucas_selfridge.c b/bn_mp_prime_strong_lucas_selfridge.c
index f30179c..389f62d 100644
--- a/bn_mp_prime_strong_lucas_selfridge.c
+++ b/bn_mp_prime_strong_lucas_selfridge.c
@@ -72,7 +72,7 @@ mp_err mp_prime_strong_lucas_selfridge(const mp_int *a, mp_bool *result)
/* CZ TODO: Some of them need the full 32 bit, hence the (temporary) exclusion of MP_8BIT */
int32_t D, Ds, J, sign, P, Q, r, s, u, Nbits;
mp_err e;
- int oddness;
+ mp_bool oddness;
*result = MP_NO;
/*
diff --git a/callgraph.txt b/callgraph.txt
index a5eea03..4eb61ea 100644
--- a/callgraph.txt
+++ b/callgraph.txt
@@ -2533,9 +2533,9 @@ BN_MP_GROW_C
BN_MP_ILOGB_C
-+--->BN_MP_COUNT_BITS_C
+--->BN_MP_SET_INT_C
| +--->BN_MP_SET_LONG_C
++--->BN_MP_COUNT_BITS_C
+--->BN_MP_SET_C
| +--->BN_MP_ZERO_C
+--->BN_MP_CMP_D_C
diff --git a/demo/test.c b/demo/test.c
index 9457487..69c8fbc 100644
--- a/demo/test.c
+++ b/demo/test.c
@@ -148,8 +148,8 @@ static int test_s_mp_jacobi(void)
{ 9, { -1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1 } },
};
- int i, n, should, cnt;
- mp_err err;
+ int i, n, cnt;
+ mp_err err, should;
mp_int a, b;
if (mp_init_multi(&a, &b, NULL)!= MP_OKAY) {
return EXIT_FAILURE;
@@ -1267,9 +1267,10 @@ LBL_ERR:
}
/* stripped down version of mp_radix_size. The faster version can be off by up t
o +3 */
-static int s_rs(const mp_int *a, int radix, int *size)
+static mp_err s_rs(const mp_int *a, int radix, int *size)
{
- int res, digs = 0;
+ mp_err res;
+ int digs = 0;
mp_int t;
mp_digit d;
*size = 0;
@@ -1431,7 +1432,7 @@ LBL_ERR:
static int test_mp_incr(void)
{
mp_int a, b;
- int e = MP_OKAY;
+ mp_err e = MP_OKAY;
if ((e = mp_init_multi(&a, &b, NULL)) != MP_OKAY) {
goto LTM_ERR;
@@ -1496,7 +1497,7 @@ LTM_ERR:
static int test_mp_decr(void)
{
mp_int a, b;
- int e = MP_OKAY;
+ mp_err e = MP_OKAY;
if ((e = mp_init_multi(&a, &b, NULL)) != MP_OKAY) {
goto LTM_ERR;
@@ -1585,7 +1586,7 @@ LTM_ERR:
static int test_mp_n_root(void)
{
mp_int a, c, r;
- int e;
+ mp_err e;
int i, j;
const char *input[] = {
@@ -1803,7 +1804,7 @@ LTM_ERR:
static int test_s_mp_balance_mul(void)
{
mp_int a, b, c;
- int e = MP_OKAY;
+ mp_err e = MP_OKAY;
const char *na =
"4b0I5uMTujCysw+1OOuOyH2FX2WymrHUqi8BBDb7XpkV/4i7vXTbEYUy/kdIfCKu5jT5JEqYkdmnn3jAYo8XShPzNLxZx9yoLjxYRyptSuOI2B1DspvbIVYXY12sxPZ4/HCJ4Usm2MU5lO/006KnDMxuxiv1rm6YZJZ0eZU";
diff --git a/tommath_class.h b/tommath_class.h
index 9faa0fa..880ea8b 100644
--- a/tommath_class.h
+++ b/tommath_class.h
@@ -435,8 +435,8 @@
#endif
#if defined(BN_MP_ILOGB_C)
-# define BN_MP_COUNT_BITS_C
# define BN_MP_SET_INT_C
+# define BN_MP_COUNT_BITS_C
# define BN_MP_SET_C
# define BN_MP_CMP_D_C
# define BN_MP_ZERO_C