Merge pull request #128 from fperrad/20181128_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
diff --git a/bn_mp_get_double.c b/bn_mp_get_double.c
index 542993d..8ce314f 100644
--- a/bn_mp_get_double.c
+++ b/bn_mp_get_double.c
@@ -16,14 +16,14 @@
double mp_get_double(const mp_int *a)
{
int i;
- double d = 0, fac = 1;
+ double d = 0.0, fac = 1.0;
for (i = 0; i < DIGIT_BIT; ++i) {
- fac *= 2;
+ fac *= 2.0;
}
for (i = USED(a); i --> 0;) {
- d = d * fac + (double)DIGIT(a, i);
+ d = (d * fac) + (double)DIGIT(a, i);
}
- return mp_isneg(a) ? -d : d;
+ return (mp_isneg(a) != MP_NO) ? -d : d;
}
#endif
diff --git a/bn_mp_set_double.c b/bn_mp_set_double.c
index 0a5f771..0e230c7 100644
--- a/bn_mp_set_double.c
+++ b/bn_mp_set_double.c
@@ -14,7 +14,7 @@
*/
#if defined(__STDC_IEC_559__) || defined(__GCC_IEC_559)
-int mp_set_double(mp_int *a, double d)
+int mp_set_double(mp_int *a, double b)
{
uint64_t frac;
int exp, res;
@@ -22,10 +22,10 @@ int mp_set_double(mp_int *a, double d)
double dbl;
uint64_t bits;
} cast;
- cast.dbl = d;
+ cast.dbl = b;
- exp = (int)(cast.bits >> 52) & 0x7FF;
- frac = (cast.bits & ((1ULL << 52) - 1)) | (1ULL << 52);
+ exp = (unsigned)(cast.bits >> 52) & 0x7FFU;
+ frac = (cast.bits & ((1ULL << 52) - 1ULL)) | (1ULL << 52);
if (exp == 0x7FF) { /* +-inf, NaN */
return MP_VAL;
@@ -37,8 +37,8 @@ int mp_set_double(mp_int *a, double d)
return res;
}
- res = exp < 0 ? mp_div_2d(a, -exp, a, 0) : mp_mul_2d(a, exp, a);
- if ((cast.bits >> 63) && !mp_iszero(a)) {
+ res = (exp < 0) ? mp_div_2d(a, -exp, a, NULL) : mp_mul_2d(a, exp, a);
+ if (((cast.bits >> 63) != 0ULL) && (mp_iszero(a) == MP_NO)) {
SIGN(a) = MP_NEG;
}