Merge pull request #376 from fperrad/20191015_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
diff --git a/bn_mp_log_u32.c b/bn_mp_log_u32.c
index fa60ba3..f7bca01 100644
--- a/bn_mp_log_u32.c
+++ b/bn_mp_log_u32.c
@@ -92,9 +92,9 @@ mp_err mp_log_u32(const mp_int *a, uint32_t base, uint32_t *c)
}
/* A small shortcut for bases that are powers of two. */
- if (!(base & (base - 1u))) {
+ if ((base & (base - 1u)) == 0u) {
int y, bit_count;
- for (y=0; (y < 7) && !(base & 1u); y++) {
+ for (y=0; (y < 7) && ((base & 1u) == 0u); y++) {
base >>= 1;
}
bit_count = mp_count_bits(a) - 1;
@@ -108,7 +108,7 @@ mp_err mp_log_u32(const mp_int *a, uint32_t base, uint32_t *c)
}
cmp = mp_cmp_d(a, base);
- if (cmp == MP_LT || cmp == MP_EQ) {
+ if ((cmp == MP_LT) || (cmp == MP_EQ)) {
*c = cmp == MP_EQ;
return err;
}
@@ -167,7 +167,7 @@ mp_err mp_log_u32(const mp_int *a, uint32_t base, uint32_t *c)
}
}
- *c = mp_cmp(&bracket_high, a) == MP_EQ ? high : low;
+ *c = (mp_cmp(&bracket_high, a) == MP_EQ) ? high : low;
LBL_END:
LBL_ERR:
diff --git a/etc/mont.c b/etc/mont.c
index 1b4f2b3..4652410 100644
--- a/etc/mont.c
+++ b/etc/mont.c
@@ -1,5 +1,6 @@
/* tests the montgomery routines */
#include <tommath.h>
+#include <stdlib.h>
#include <time.h>
int main(void)
diff --git a/etc/pprime.c b/etc/pprime.c
index 706aec8..fa622f8 100644
--- a/etc/pprime.c
+++ b/etc/pprime.c
@@ -4,6 +4,7 @@
*
* Tom St Denis, tomstdenis@gmail.com, http://tom.gmail.com
*/
+#include <stdlib.h>
#include <time.h>
#include "tommath.h"