Commit 05399033b8e582605fd27c5d4bdd4abf7a284a33

Steffen Jaeckel 2019-03-26T22:01:36

Merge pull request #186 from fperrad/20190326_lint some linting

diff --git a/bn_mp_read_radix.c b/bn_mp_read_radix.c
index 5c3a5c6..abfc4a1 100644
--- a/bn_mp_read_radix.c
+++ b/bn_mp_read_radix.c
@@ -12,7 +12,7 @@
  * SPDX-License-Identifier: Unlicense
  */
 
-#define MP_TOUPPER(c) ((c) >= 'a' && (c) <= 'z' ? (c) + 'A' - 'a' : (c))
+#define MP_TOUPPER(c) ((((c) >= 'a') && ((c) <= 'z')) ? (((c) + 'A') - 'a') : (c))
 
 /* read a string [ASCII] in a given radix */
 int mp_read_radix(mp_int *a, const char *str, int radix)
diff --git a/tommath_private.h b/tommath_private.h
index 7d62c1e..725aa4b 100644
--- a/tommath_private.h
+++ b/tommath_private.h
@@ -90,10 +90,11 @@ extern const size_t mp_s_rmap_reverse_sz;
 int func_name (mp_int * a, type b)                       \
 {                                                        \
    int x = 0;                                            \
-   int res = mp_grow(a, (CHAR_BIT * sizeof(type) + DIGIT_BIT - 1) / DIGIT_BIT); \
+   int new_size = (((CHAR_BIT * sizeof(type)) + DIGIT_BIT) - 1) / DIGIT_BIT; \
+   int res = mp_grow(a, new_size);                       \
    if (res == MP_OKAY) {                                 \
      mp_zero(a);                                         \
-     while (b) {                                         \
+     while (b != 0u) {                                   \
         a->dp[x++] = ((mp_digit)b & MP_MASK);            \
         b >>= DIGIT_BIT;                                 \
      }                                                   \