summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-08-13 17:25:57 +0200
committerDavid Robillard <d@drobilla.net>2020-08-13 17:25:57 +0200
commitfc253203d7aa52d866e21576215de6c40c45f9c4 (patch)
treee06c737e09c771eb47dea34b7cb5c55c412c5934
parentea0fd7ddc5086a553e7a94b16b46700af476f3dd (diff)
downloadzix-fc253203d7aa52d866e21576215de6c40c45f9c4.tar.gz
zix-fc253203d7aa52d866e21576215de6c40c45f9c4.tar.bz2
zix-fc253203d7aa52d866e21576215de6c40c45f9c4.zip
Fix signed operands of bitwise operators
-rw-r--r--.clang-tidy1
-rw-r--r--test/btree_test.c2
-rw-r--r--zix/digest.c2
-rw-r--r--zix/ring.c10
-rw-r--r--zix/trie_util.h2
5 files changed, 8 insertions, 9 deletions
diff --git a/.clang-tidy b/.clang-tidy
index 84771ad..b77d9ae 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -12,7 +12,6 @@ Checks: >
-cppcoreguidelines-init-variables,
-google-readability-casting,
-hicpp-multiway-paths-covered,
- -hicpp-signed-bitwise,
-llvm-header-guard,
-readability-else-after-return,
WarningsAsErrors: '*'
diff --git a/test/btree_test.c b/test/btree_test.c
index a54d38a..67419be 100644
--- a/test/btree_test.c
+++ b/test/btree_test.c
@@ -34,7 +34,7 @@ static bool expect_failure = false;
static uintptr_t
unique_rand(size_t i)
{
- i ^= 0x00005CA1E; // Juggle bits to avoid linear clumps
+ i ^= 0x00005CA1Eu; // Juggle bits to avoid linear clumps
// Largest prime < 2^32 which satisfies (2^32 = 3 mod 4)
static const uint32_t prime = 4294967291;
diff --git a/zix/digest.c b/zix/digest.c
index 7d9c035..d6ceb0e 100644
--- a/zix/digest.c
+++ b/zix/digest.c
@@ -50,7 +50,7 @@ zix_digest_add(uint32_t hash, const void* const buf, const size_t len)
#else
// Classic DJB hash
for (size_t i = 0; i < len; ++i) {
- hash = (hash << 5) + hash + str[i];
+ hash = (hash << 5u) + hash + str[i];
}
#endif
return hash;
diff --git a/zix/ring.c b/zix/ring.c
index 18a133d..a62d833 100644
--- a/zix/ring.c
+++ b/zix/ring.c
@@ -56,11 +56,11 @@ next_power_of_two(uint32_t size)
{
// http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
size--;
- size |= size >> 1;
- size |= size >> 2;
- size |= size >> 4;
- size |= size >> 8;
- size |= size >> 16;
+ size |= size >> 1u;
+ size |= size >> 2u;
+ size |= size >> 4u;
+ size |= size >> 8u;
+ size |= size >> 16u;
size++;
return size;
}
diff --git a/zix/trie_util.h b/zix/trie_util.h
index ed429b3..c10f30a 100644
--- a/zix/trie_util.h
+++ b/zix/trie_util.h
@@ -48,7 +48,7 @@ zix_trie_find_key(const uint8_t* const keys, const size_t n, const uint8_t k)
size_t first = 0;
size_t len = n;
while (len > 0) {
- const size_t half = len >> 1;
+ const size_t half = len >> 1u;
const size_t i = first + half;
if (keys[i] < k) {
const size_t chop = half + 1;