Commit 69a7ca78aac48a23664cadc9a3706d165b332cd3

Steffen Jaeckel 2019-10-15T19:20:34

Merge pull request #376 from fperrad/20191015_lint some linting

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"