diff options
author | David Robillard <d@drobilla.net> | 2022-08-19 15:14:24 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-08-19 15:14:24 -0400 |
commit | 1c440b76eeaf4968debe18973435832200a0a12f (patch) | |
tree | d722c92fa8c16016d67eedc8d683c24f837a8d61 /src | |
parent | 171aa2a60a8deeaf7b7692a0ecb6de56df1607f8 (diff) | |
download | zix-1c440b76eeaf4968debe18973435832200a0a12f.tar.gz zix-1c440b76eeaf4968debe18973435832200a0a12f.tar.bz2 zix-1c440b76eeaf4968debe18973435832200a0a12f.zip |
Avoid mixing signed and unsigned integers
Diffstat (limited to 'src')
-rw-r--r-- | src/bitset.c | 2 | ||||
-rw-r--r-- | src/bump_allocator.c | 6 | ||||
-rw-r--r-- | src/digest.c | 2 | ||||
-rw-r--r-- | src/hash.c | 2 | ||||
-rw-r--r-- | src/ring.c | 4 | ||||
-rw-r--r-- | src/tree.c | 2 |
6 files changed, 9 insertions, 9 deletions
diff --git a/src/bitset.c b/src/bitset.c index 6889925..d180ccd 100644 --- a/src/bitset.c +++ b/src/bitset.c @@ -75,7 +75,7 @@ zix_bitset_count_up_to(const ZixBitset* b, const ZixBitsetTally* t, size_t i) } if (extra) { - const ZixBitset mask = ~(~(ZixBitset)0 << extra); + const ZixBitset mask = ~(~(ZixBitset)0U << extra); count += zix_bitset_popcount(b[full_elems] & mask); } diff --git a/src/bump_allocator.c b/src/bump_allocator.c index eedd3e9..0bacb28 100644 --- a/src/bump_allocator.c +++ b/src/bump_allocator.c @@ -15,8 +15,8 @@ static const size_t min_alignment = sizeof(uintmax_t); static size_t round_up_multiple(const size_t number, const size_t factor) { - assert(factor); // Factor must be non-zero - assert((factor & (factor - 1)) == 0U); // Factor must be a power of two + assert(factor); // Factor must be non-zero + assert((factor & (factor - 1U)) == 0U); // Factor must be a power of two return (number + factor - 1U) & ~(factor - 1U); } @@ -27,7 +27,7 @@ zix_bump_malloc(ZixAllocator* const allocator, const size_t size) { ZixBumpAllocator* const state = (ZixBumpAllocator*)allocator; - assert((uintptr_t)((char*)state->buffer + state->top) % min_alignment == 0); + assert((uintptr_t)((char*)state->buffer + state->top) % min_alignment == 0U); /* For C malloc(), the result is guaranteed to be aligned for any variable. What that means is deliberately vague to accommodate diverse platforms, diff --git a/src/digest.c b/src/digest.c index 3af9e8c..5853e37 100644 --- a/src/digest.c +++ b/src/digest.c @@ -113,7 +113,7 @@ zix_digest64_aligned(const uint64_t seed, const void* const key, size_t len) static inline uint32_t rotl32(const uint32_t val, const uint32_t bits) { - return ((val << bits) | (val >> (32 - bits))); + return ((val << bits) | (val >> (32U - bits))); } static inline uint32_t @@ -328,7 +328,7 @@ zix_hash_insert_at(ZixHash* const hash, // Update size and rehash if we exceeded the maximum load const size_t max_load = hash->n_entries / 2U + hash->n_entries / 8U; - const size_t new_count = hash->count + 1; + const size_t new_count = hash->count + 1U; if (new_count >= max_load) { const ZixStatus st = grow(hash); if (st) { @@ -86,7 +86,7 @@ zix_ring_new(ZixAllocator* const allocator, const uint32_t size) ring->write_head = 0; ring->read_head = 0; ring->size = next_power_of_two(size); - ring->size_mask = ring->size - 1; + ring->size_mask = ring->size - 1U; if (!(ring->buf = (char*)zix_malloc(allocator, ring->size))) { zix_free(allocator, ring); @@ -162,7 +162,7 @@ zix_ring_write_space(const ZixRing* const ring) uint32_t zix_ring_capacity(const ZixRing* const ring) { - return ring->size - 1; + return ring->size - 1U; } static inline uint32_t @@ -417,7 +417,7 @@ zix_tree_remove(ZixTree* t, ZixTreeIter* ti) t->destroy(n->data, t->destroy_user_data); zix_free(t->allocator, n); --t->size; - assert(t->size == 0); + assert(!t->size); return ZIX_STATUS_SUCCESS; } |