Merge pull request #287 from fperrad/20190522_lint some linting
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
diff --git a/bn_mp_and.c b/bn_mp_and.c
index 1ee14e8..c259f8d 100644
--- a/bn_mp_and.c
+++ b/bn_mp_and.c
@@ -9,7 +9,7 @@ mp_err mp_and(const mp_int *a, const mp_int *b, mp_int *c)
int used = MP_MAX(a->used, b->used) + 1, i;
mp_err err;
mp_digit ac = 1, bc = 1, cc = 1;
- mp_sign csign = (a->sign == MP_NEG && b->sign == MP_NEG) ? MP_NEG : MP_ZPOS;
+ mp_sign csign = ((a->sign == MP_NEG) && (b->sign == MP_NEG)) ? MP_NEG : MP_ZPOS;
if (c->alloc < used) {
if ((err = mp_grow(c, used)) != MP_OKAY) {
@@ -22,20 +22,20 @@ mp_err mp_and(const mp_int *a, const mp_int *b, mp_int *c)
/* convert to two complement if negative */
if (a->sign == MP_NEG) {
- ac += i >= a->used ? MP_MASK : ~a->dp[i] & MP_MASK;
+ ac += (i >= a->used) ? MP_MASK : (~a->dp[i] & MP_MASK);
x = ac & MP_MASK;
ac >>= MP_DIGIT_BIT;
} else {
- x = i >= a->used ? 0 : a->dp[i];
+ x = (i >= a->used) ? 0uL : a->dp[i];
}
/* convert to two complement if negative */
if (b->sign == MP_NEG) {
- bc += i >= b->used ? MP_MASK : ~b->dp[i] & MP_MASK;
+ bc += (i >= b->used) ? MP_MASK : (~b->dp[i] & MP_MASK);
y = bc & MP_MASK;
bc >>= MP_DIGIT_BIT;
} else {
- y = i >= b->used ? 0 : b->dp[i];
+ y = (i >= b->used) ? 0uL : b->dp[i];
}
c->dp[i] = x & y;
diff --git a/bn_mp_count_bits.c b/bn_mp_count_bits.c
index bba9a94..b7c2cad 100644
--- a/bn_mp_count_bits.c
+++ b/bn_mp_count_bits.c
@@ -19,9 +19,9 @@ int mp_count_bits(const mp_int *a)
/* take the last digit and count the bits in it */
q = a->dp[a->used - 1];
- while (q > (mp_digit)0) {
+ while (q > 0u) {
++r;
- q >>= (mp_digit)1;
+ q >>= 1u;
}
return r;
}
diff --git a/bn_mp_fread.c b/bn_mp_fread.c
index 04a1316..52ea773 100644
--- a/bn_mp_fread.c
+++ b/bn_mp_fread.c
@@ -49,7 +49,7 @@ mp_err mp_fread(mp_int *a, int radix, FILE *stream)
}
} while ((ch = fgetc(stream)) != EOF);
- if (!mp_iszero(a)) {
+ if (a->used != 0) {
a->sign = neg;
}
diff --git a/bn_mp_ilogb.c b/bn_mp_ilogb.c
index efcd5f9..0ca0193 100644
--- a/bn_mp_ilogb.c
+++ b/bn_mp_ilogb.c
@@ -24,10 +24,10 @@ static mp_digit s_digit_ilogb(mp_digit base, mp_digit n)
mp_digit ret, high = 1uL, low = 0uL, mid;
if (n < base) {
- return (mp_digit)0uL;
+ return 0uL;
}
if (n == base) {
- return (mp_digit)1uL;
+ return 1uL;
}
bracket_high = (mp_word) base ;
diff --git a/bn_mp_or.c b/bn_mp_or.c
index 6102a8a..cdacbfb 100644
--- a/bn_mp_or.c
+++ b/bn_mp_or.c
@@ -9,7 +9,7 @@ mp_err mp_or(const mp_int *a, const mp_int *b, mp_int *c)
int used = MP_MAX(a->used, b->used) + 1, i;
mp_err err;
mp_digit ac = 1, bc = 1, cc = 1;
- mp_sign csign = (a->sign == MP_NEG || b->sign == MP_NEG) ? MP_NEG : MP_ZPOS;
+ mp_sign csign = ((a->sign == MP_NEG) || (b->sign == MP_NEG)) ? MP_NEG : MP_ZPOS;
if (c->alloc < used) {
if ((err = mp_grow(c, used)) != MP_OKAY) {
@@ -22,20 +22,20 @@ mp_err mp_or(const mp_int *a, const mp_int *b, mp_int *c)
/* convert to two complement if negative */
if (a->sign == MP_NEG) {
- ac += i >= a->used ? MP_MASK : ~a->dp[i] & MP_MASK;
+ ac += (i >= a->used) ? MP_MASK : (~a->dp[i] & MP_MASK);
x = ac & MP_MASK;
ac >>= MP_DIGIT_BIT;
} else {
- x = i >= a->used ? 0 : a->dp[i];
+ x = (i >= a->used) ? 0uL : a->dp[i];
}
/* convert to two complement if negative */
if (b->sign == MP_NEG) {
- bc += i >= b->used ? MP_MASK : ~b->dp[i] & MP_MASK;
+ bc += (i >= b->used) ? MP_MASK : (~b->dp[i] & MP_MASK);
y = bc & MP_MASK;
bc >>= MP_DIGIT_BIT;
} else {
- y = i >= b->used ? 0 : b->dp[i];
+ y = (i >= b->used) ? 0uL : b->dp[i];
}
c->dp[i] = x | y;
diff --git a/bn_mp_xor.c b/bn_mp_xor.c
index c066e65..71e7ca1 100644
--- a/bn_mp_xor.c
+++ b/bn_mp_xor.c
@@ -22,20 +22,20 @@ mp_err mp_xor(const mp_int *a, const mp_int *b, mp_int *c)
/* convert to two complement if negative */
if (a->sign == MP_NEG) {
- ac += i >= a->used ? MP_MASK : ~a->dp[i] & MP_MASK;
+ ac += (i >= a->used) ? MP_MASK : (~a->dp[i] & MP_MASK);
x = ac & MP_MASK;
ac >>= MP_DIGIT_BIT;
} else {
- x = i >= a->used ? 0 : a->dp[i];
+ x = (i >= a->used) ? 0uL : a->dp[i];
}
/* convert to two complement if negative */
if (b->sign == MP_NEG) {
- bc += i >= b->used ? MP_MASK : ~b->dp[i] & MP_MASK;
+ bc += (i >= b->used) ? MP_MASK : (~b->dp[i] & MP_MASK);
y = bc & MP_MASK;
bc >>= MP_DIGIT_BIT;
} else {
- y = i >= b->used ? 0 : b->dp[i];
+ y = (i >= b->used) ? 0uL : b->dp[i];
}
c->dp[i] = x ^ y;
diff --git a/bn_s_mp_toom_mul.c b/bn_s_mp_toom_mul.c
index e80b6f6..ce47f25 100644
--- a/bn_s_mp_toom_mul.c
+++ b/bn_s_mp_toom_mul.c
@@ -63,7 +63,7 @@ mp_err s_mp_toom_mul(const mp_int *a, const mp_int *b, mp_int *c)
goto LTM_ERRa2;
}
for (; count < a->used; count++) {
- a2.dp[count - 2 * B] = a->dp[count];
+ a2.dp[count - (2 * B)] = a->dp[count];
a2.used++;
}
@@ -88,7 +88,7 @@ mp_err s_mp_toom_mul(const mp_int *a, const mp_int *b, mp_int *c)
goto LTM_ERRb2;
}
for (; count < b->used; count++) {
- b2.dp[count - 2 * B] = b->dp[count];
+ b2.dp[count - (2 * B)] = b->dp[count];
b2.used++;
}
diff --git a/tommath_class.h b/tommath_class.h
index 5f148cd..b72f545 100644
--- a/tommath_class.h
+++ b/tommath_class.h
@@ -401,7 +401,6 @@
# define BN_MP_ZERO_C
# define BN_MP_MUL_D_C
# define BN_MP_ADD_D_C
-# define BN_MP_ISZERO_C
#endif
#if defined(BN_MP_FWRITE_C)