diff options
author | David Robillard <d@drobilla.net> | 2021-09-10 20:11:28 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-09-10 20:11:28 -0400 |
commit | 733d7601d7f75b70bb0bf3315c5a282a7d699b67 (patch) | |
tree | 08631b160906f413866655be0327341d451d5a2b | |
parent | b45b6b442f0e3f821921a48f957944f485adfd1b (diff) | |
download | zix-733d7601d7f75b70bb0bf3315c5a282a7d699b67.tar.gz zix-733d7601d7f75b70bb0bf3315c5a282a7d699b67.tar.bz2 zix-733d7601d7f75b70bb0bf3315c5a282a7d699b67.zip |
Be explicit about the sign of defined integer constants
-rw-r--r-- | src/btree.c | 8 | ||||
-rw-r--r-- | test/bitset_test.c | 2 | ||||
-rw-r--r-- | test/ring_test.c | 10 |
3 files changed, 10 insertions, 10 deletions
diff --git a/src/btree.c b/src/btree.c index 49b7516..3553a9a 100644 --- a/src/btree.c +++ b/src/btree.c @@ -25,12 +25,12 @@ // #define ZIX_BTREE_SORTED_CHECK 1 #ifndef ZIX_BTREE_PAGE_SIZE -# define ZIX_BTREE_PAGE_SIZE 4096 +# define ZIX_BTREE_PAGE_SIZE 4096u #endif -#define ZIX_BTREE_NODE_SPACE (ZIX_BTREE_PAGE_SIZE - 2 * sizeof(uint16_t)) -#define ZIX_BTREE_LEAF_VALS ((ZIX_BTREE_NODE_SPACE / sizeof(void*)) - 1) -#define ZIX_BTREE_INODE_VALS (ZIX_BTREE_LEAF_VALS / 2) +#define ZIX_BTREE_NODE_SPACE (ZIX_BTREE_PAGE_SIZE - 2u * sizeof(uint16_t)) +#define ZIX_BTREE_LEAF_VALS ((ZIX_BTREE_NODE_SPACE / sizeof(void*)) - 1u) +#define ZIX_BTREE_INODE_VALS (ZIX_BTREE_LEAF_VALS / 2u) struct ZixBTreeImpl { ZixBTreeNode* root; diff --git a/test/bitset_test.c b/test/bitset_test.c index dda59d3..27f1d2d 100644 --- a/test/bitset_test.c +++ b/test/bitset_test.c @@ -21,7 +21,7 @@ #include <stdarg.h> #include <stdio.h> -#define N_BITS 256 +#define N_BITS 256u #define N_ELEMS (ZIX_BITSET_ELEMS(N_BITS)) #define MIN(a, b) (((a) < (b)) ? (a) : (b)) diff --git a/test/ring_test.c b/test/ring_test.c index 7616346..c11d998 100644 --- a/test/ring_test.c +++ b/test/ring_test.c @@ -25,7 +25,7 @@ #include <stdio.h> #include <stdlib.h> -#define MSG_SIZE 20 +#define MSG_SIZE 20u static ZixRing* ring = 0; static unsigned n_writes = 0; @@ -46,7 +46,7 @@ failure(const char* fmt, ...) static int gen_msg(int* msg, int start) { - for (int i = 0; i < MSG_SIZE; ++i) { + for (unsigned i = 0u; i < MSG_SIZE; ++i) { msg[i] = start; start = (start + 1) % INT_MAX; } @@ -56,9 +56,9 @@ gen_msg(int* msg, int start) static int cmp_msg(int* msg1, int* msg2) { - for (int i = 0; i < MSG_SIZE; ++i) { + for (unsigned i = 0u; i < MSG_SIZE; ++i) { if (msg1[i] != msg2[i]) { - return !failure("%d != %d @ %d\n", msg1[i], msg2[i], i); + return !failure("%d != %d @ %u\n", msg1[i], msg2[i], i); } } @@ -131,7 +131,7 @@ main(int argc, char** argv) zix_ring_free(NULL); - printf("Testing %u writes of %d ints to a %u int ring...\n", + printf("Testing %u writes of %u ints to a %u int ring...\n", n_writes, MSG_SIZE, size); |