diff options
author | Maxim Uvarov <maxim.uvarov@linaro.org> | 2017-01-27 18:19:14 +0300 |
---|---|---|
committer | Maxim Uvarov <maxim.uvarov@linaro.org> | 2017-01-27 21:38:38 +0300 |
commit | 7df357dd591cce23f76221945091a019c0caa7ec (patch) | |
tree | f84dde4cace5e06a5333fe840be70a13ea3ea095 /helper/cuckootable.c | |
parent | a51c171ebe9e9b0aaced13bc0956bdb38c8cfc7b (diff) |
helper: fix compilation with warnings
After turning on lost CFLAGS for checking errors,
following things needs to be corrected to make code
compile.
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Reviewed-by: Mike Holmes <mike.holmes@linaro.org>
Diffstat (limited to 'helper/cuckootable.c')
-rw-r--r-- | helper/cuckootable.c | 50 |
1 files changed, 20 insertions, 30 deletions
diff --git a/helper/cuckootable.c b/helper/cuckootable.c index 83647ec2d..6a7fb215e 100644 --- a/helper/cuckootable.c +++ b/helper/cuckootable.c @@ -148,18 +148,6 @@ align32pow2(uint32_t x) return x + 1; } -/** - * Returns true if n is a power of 2 - * @param n - * Number to check - * @return 1 if true, 0 otherwise - */ -static inline int -is_power_of_2(uint32_t n) -{ - return n && !(n & (n - 1)); -} - odph_table_t odph_cuckoo_table_lookup(const char *name) { @@ -209,7 +197,7 @@ odph_cuckoo_table_create( } /* Guarantee there's no existing */ - tbl = (odph_cuckoo_table_impl *)odph_cuckoo_table_lookup(name); + tbl = (odph_cuckoo_table_impl *)(void *)odph_cuckoo_table_lookup(name); if (tbl != NULL) { ODPH_DBG("cuckoo hash table %s already exists\n", name); return NULL; @@ -240,8 +228,7 @@ odph_cuckoo_table_create( /* header of this mem block is the table impl struct, * then the bucket pool. */ - tbl->buckets = (struct cuckoo_table_bucket *)( - (char *)tbl + impl_size); + tbl->buckets = (void *)((char *)tbl + impl_size); /* initialize key-value buffer pool */ snprintf(pool_name, sizeof(pool_name), "kv_%s", name); @@ -309,17 +296,18 @@ odph_cuckoo_table_create( int odph_cuckoo_table_destroy(odph_table_t tbl) { - int ret, i, j; + int ret; odph_cuckoo_table_impl *impl = NULL; char pool_name[ODPH_TABLE_NAME_LEN + 3]; odp_event_t ev; odp_shm_t shm; odp_pool_t pool; + uint32_t i, j; if (tbl == NULL) return -1; - impl = (odph_cuckoo_table_impl *)tbl; + impl = (odph_cuckoo_table_impl *)(void *)tbl; /* check magic word */ if (impl->magicword != ODPH_CUCKOO_TABLE_MAGIC_WORD) { @@ -578,11 +566,14 @@ cuckoo_table_add_key_with_hash( int odph_cuckoo_table_put_value(odph_table_t tbl, void *key, void *value) { + odph_cuckoo_table_impl *impl; + int ret; + if ((tbl == NULL) || (key == NULL)) return -EINVAL; - odph_cuckoo_table_impl *impl = (odph_cuckoo_table_impl *)tbl; - int ret = cuckoo_table_add_key_with_hash( + impl = (odph_cuckoo_table_impl *)(void *)tbl; + ret = cuckoo_table_add_key_with_hash( impl, key, hash(impl, key), value); if (ret < 0) @@ -651,17 +642,16 @@ cuckoo_table_lookup_with_hash( return -ENOENT; } -int -odph_cuckoo_table_get_value( - odph_table_t tbl, void *key, void *buffer, uint32_t buffer_size) +int odph_cuckoo_table_get_value(odph_table_t tbl, void *key, + void *buffer, uint32_t buffer_size ODP_UNUSED) { - if ((tbl == NULL) || (key == NULL)) - return -EINVAL; - - odph_cuckoo_table_impl *impl = (odph_cuckoo_table_impl *)tbl; + odph_cuckoo_table_impl *impl = (odph_cuckoo_table_impl *)(void *)tbl; void *tmp = NULL; int ret; + if ((tbl == NULL) || (key == NULL)) + return -EINVAL; + ret = cuckoo_table_lookup_with_hash(impl, key, hash(impl, key), &tmp); if (ret < 0) @@ -734,13 +724,13 @@ cuckoo_table_del_key_with_hash( int odph_cuckoo_table_remove_value(odph_table_t tbl, void *key) { + odph_cuckoo_table_impl *impl = (void *)tbl; + int ret; + if ((tbl == NULL) || (key == NULL)) return -EINVAL; - odph_cuckoo_table_impl *impl = (odph_cuckoo_table_impl *)tbl; - int ret = cuckoo_table_del_key_with_hash( - impl, key, hash(impl, key)); - + ret = cuckoo_table_del_key_with_hash(impl, key, hash(impl, key)); if (ret < 0) return -1; |