shachain: Fix signed/unsigned mismatches
authorJon Griffiths <jon_p_griffiths@yahoo.com>
Wed, 24 Aug 2016 07:50:40 +0000 (19:50 +1200)
committerJon Griffiths <jon_p_griffiths@yahoo.com>
Mon, 29 Aug 2016 04:55:58 +0000 (16:55 +1200)
Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
ccan/crypto/shachain/shachain.c

index 6cfb7244f981472994c813eb8d91fb72df99fd75..c6bd37e8f55c76cd72a2720669e8083d4d4585fe 100644 (file)
@@ -12,12 +12,12 @@ static void change_bit(unsigned char *arr, size_t index)
        arr[index / CHAR_BIT] ^= (1 << (index % CHAR_BIT));
 }
 
-static int count_trailing_zeroes(shachain_index_t index)
+static unsigned int count_trailing_zeroes(shachain_index_t index)
 {
 #if HAVE_BUILTIN_CTZLL
-       return index ? __builtin_ctzll(index) : INDEX_BITS;
+       return index ? (unsigned int)__builtin_ctzll(index) : INDEX_BITS;
 #else
-       int i;
+       unsigned int i;
 
        for (i = 0; i < INDEX_BITS; i++) {
                if (index & (1ULL << i))
@@ -77,7 +77,7 @@ void shachain_init(struct shachain *chain)
 bool shachain_add_hash(struct shachain *chain,
                       shachain_index_t index, const struct sha256 *hash)
 {
-       int i, pos;
+       unsigned int i, pos;
 
        /* You have to insert them in order! */
        assert(index == chain->min_index - 1 ||
@@ -107,7 +107,7 @@ bool shachain_add_hash(struct shachain *chain,
 bool shachain_get_hash(const struct shachain *chain,
                       shachain_index_t index, struct sha256 *hash)
 {
-       int i;
+       unsigned int i;
 
        for (i = 0; i < chain->num_valid; i++) {
                /* If we can get from key to index only by resetting bits,