diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/generic/lru.c | 4 | ||||
-rw-r--r-- | lib/generic/test_trie.c | 6 | ||||
-rw-r--r-- | lib/generic/trie.c | 2 |
3 files changed, 6 insertions, 6 deletions
diff --git a/lib/generic/lru.c b/lib/generic/lru.c index 857b20b3..71b8730b 100644 --- a/lib/generic/lru.c +++ b/lib/generic/lru.c @@ -50,9 +50,9 @@ static uint item_size(const struct lru *lru, uint key_len, uint val_len) /** @internal Return pointer to value in an lru_item. */ static void * item_val(const struct lru *lru, struct lru_item *it) { - size_t key_end = it->data + it->key_len - (char *)NULL; + size_t key_end = (uintptr_t)(it->data + it->key_len); size_t val_begin = round_power(key_end, lru->val_alignment); - return (char *)NULL + val_begin; + return (void *)(uintptr_t)val_begin; } /** @internal Free each item. */ diff --git a/lib/generic/test_trie.c b/lib/generic/test_trie.c index 9ecd67cd..ce164906 100644 --- a/lib/generic/test_trie.c +++ b/lib/generic/test_trie.c @@ -48,7 +48,7 @@ static void test_insert(void **state) trie_val_t *data = trie_get_ins(t, dict[i], KEY_LEN(dict[i])); assert_non_null(data); assert_null(*data); - *data = (char *)NULL + i; // yes, ugly + *data = (void *)(intptr_t)i; // yes, ugly assert_ptr_equal(trie_get_try(t, dict[i], KEY_LEN(dict[i])), data); } assert_int_equal(trie_weight(t), dict_size); @@ -82,7 +82,7 @@ static void test_iter(void **state) const char *key = trie_it_key(it, &len); assert_int_equal(KEY_LEN(key), len); assert_string_equal(key, dict_sorted[i]); - assert_ptr_equal(dict[(char *)*trie_it_val(it) - (char *)NULL], + assert_ptr_equal(dict[(uintptr_t)*trie_it_val(it)], dict_sorted[i]); } assert_true(trie_it_finished(it)); @@ -100,7 +100,7 @@ static void test_queue(void **state) assert_non_null(key); assert_int_equal(len, KEY_LEN(key)); assert_non_null(data); - ptrdiff_t key_i = (char *)*data - (char *)NULL; + uintptr_t key_i = (uintptr_t)*data; assert_string_equal(key, dict[key_i]); len = 30; diff --git a/lib/generic/trie.c b/lib/generic/trie.c index 21254eb4..e2ce061e 100644 --- a/lib/generic/trie.c +++ b/lib/generic/trie.c @@ -116,7 +116,7 @@ static inline void empty_root(node_t *root) { static void assert_portability(void) { #if FLAGS_HACK kr_require(((union node){ .leaf = { - .key = (tkey_t *)(((uint8_t *)NULL) + 1), + .key = (tkey_t *)(void *)(uintptr_t)1, .val = NULL } }).branch.flags == 1); #endif |