diff mbox series

[PATCHv3,1/2] helper: fix compilation with warnings

Message ID 20170127151915.16510-1-maxim.uvarov@linaro.org
State New
Headers show
Series [PATCHv3,1/2] helper: fix compilation with warnings | expand

Commit Message

Maxim Uvarov Jan. 27, 2017, 3:19 p.m. UTC
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>

---
 v3: fix gcc compilation
 v2: rebase

 helper/chksum.c        |  4 ++--
 helper/cuckootable.c   | 49 ++++++++++++++++++++-----------------------------
 helper/hashtable.c     | 42 ++++++++++++++++++++++++++----------------
 helper/iplookuptable.c | 49 ++++++++++++++++++++++++-------------------------
 helper/lineartable.c   | 27 +++++++++++++++++----------
 helper/threads.c       |  2 +-
 6 files changed, 90 insertions(+), 83 deletions(-)

-- 
2.11.0.295.gd7dffce

Comments

Mike Holmes Jan. 27, 2017, 3:40 p.m. UTC | #1
One nit below on formatting.

On 27 January 2017 at 10:19, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:

> 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>



> ---

>  v3: fix gcc compilation

>  v2: rebase

>

>  helper/chksum.c        |  4 ++--

>  helper/cuckootable.c   | 49 ++++++++++++++++++++----------

> -------------------

>  helper/hashtable.c     | 42 ++++++++++++++++++++++++++----------------

>  helper/iplookuptable.c | 49 ++++++++++++++++++++++++------

> -------------------

>  helper/lineartable.c   | 27 +++++++++++++++++----------

>  helper/threads.c       |  2 +-

>  6 files changed, 90 insertions(+), 83 deletions(-)

>

> diff --git a/helper/chksum.c b/helper/chksum.c

> index b7eef67e..f740618d 100644

> --- a/helper/chksum.c

> +++ b/helper/chksum.c

> @@ -49,7 +49,7 @@ static uint32_t data_seg_sum(uint8_t   *data8_ptr,

>                 data_len--;

>         }

>

> -       data16_ptr = (uint16_t *)data8_ptr;

> +       data16_ptr = (uint16_t *)(void *)data8_ptr;

>

>         /* The following code tries to gain a modest performance

> enhancement by

>          * unrolling the normal 16 bits at a time loop eight times.  Even

> @@ -216,7 +216,7 @@ static inline int odph_process_l3_hdr(odp_packet_t

> odp_pkt,

>                         ipv6_hdr_ptr = &ipv6_hdr;

>                 }

>

> -               addrs_ptr        = (uint16_t *)&ipv6_hdr_ptr->src_addr;

> +               addrs_ptr        = (uint16_t *)(void

> *)&ipv6_hdr_ptr->src_addr;

>                 addrs_len        = 2 * ODPH_IPV6ADDR_LEN;

>                 protocol         = ipv6_hdr_ptr->next_hdr;

>                 ipv6_payload_len = odp_be_to_cpu_16(ipv6_hdr_ptr-

> >payload_len);

> diff --git a/helper/cuckootable.c b/helper/cuckootable.c

> index 83647ec2..396e7f53 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,7 +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 *)(

> +       tbl->buckets = (void *)(

>                         (char *)tbl + impl_size);

>


Can't this all fit on one line ?


>

>         /* initialize key-value buffer pool */

> @@ -309,17 +297,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 +567,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 +643,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 +725,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;

>

> diff --git a/helper/hashtable.c b/helper/hashtable.c

> index 983b3da9..1c2b8523 100644

> --- a/helper/hashtable.c

> +++ b/helper/hashtable.c

> @@ -101,9 +101,9 @@ odph_table_t odph_hash_table_create(const char *name,

> uint32_t capacity,

>          * the last part is the element node pool

>          */

>

> -       tbl->lock_pool = (odp_rwlock_t *)((char *)tbl

> +       tbl->lock_pool = (odp_rwlock_t *)(void *)((char *)tbl

>                         + sizeof(odph_hash_table_imp));

> -       tbl->list_head_pool = (odph_list_head *)((char *)tbl->lock_pool

> +       tbl->list_head_pool = (odph_list_head *)(void *)((char

> *)tbl->lock_pool

>                         + ODPH_MAX_BUCKET_NUM * sizeof(odp_rwlock_t));

>

>         node_mem = tbl->init_cap - sizeof(odph_hash_table_imp)

> @@ -112,8 +112,9 @@ odph_table_t odph_hash_table_create(const char *name,

> uint32_t capacity,

>

>         node_num = node_mem / (sizeof(odph_hash_node) + key_size +

> value_size);

>         tbl->hash_node_num = node_num;

> -       tbl->hash_node_pool = (odph_hash_node *)((char

> *)tbl->list_head_pool

> -                               + ODPH_MAX_BUCKET_NUM *

> sizeof(odph_list_head));

> +       tbl->hash_node_pool =

> +               (odph_hash_node *)(void *)((char *)tbl->list_head_pool

> +               + ODPH_MAX_BUCKET_NUM * sizeof(odph_list_head));

>

>         /* init every list head and rw lock */

>         for (i = 0; i < ODPH_MAX_BUCKET_NUM; i++) {

> @@ -130,8 +131,9 @@ int odph_hash_table_destroy(odph_table_t table)

>         int ret;

>

>         if (table != NULL) {

> -               odph_hash_table_imp *hash_tbl = (odph_hash_table_imp

> *)table;

> +               odph_hash_table_imp *hash_tbl;

>

> +               hash_tbl = (odph_hash_table_imp *)(void *)table;

>                 if (hash_tbl->magicword != ODPH_HASH_TABLE_MAGIC_WORD)

>                         return ODPH_FAIL;

>

> @@ -164,7 +166,7 @@ odph_table_t odph_hash_table_lookup(const char *name)

>   * This hash algorithm is the most simple one, so we choose it as an DEMO

>   * User can use any other algorithm, like CRC...

>   */

> -uint16_t odp_key_hash(void *key, uint32_t key_size)

> +static uint16_t odp_key_hash(void *key, uint32_t key_size)

>  {

>         register uint32_t hash = 0;

>         uint32_t idx = (key_size == 0 ? 1 : key_size);

> @@ -181,18 +183,19 @@ uint16_t odp_key_hash(void *key, uint32_t key_size)

>  /**

>   * Get an available node from pool

>   */

> -odph_hash_node *odp_hashnode_take(odph_table_t table)

> +static odph_hash_node *hashnode_take(odph_table_t table)

>  {

> -       odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;

> +       odph_hash_table_imp *tbl;

>         uint32_t idx;

>         odph_hash_node *node;

>

> +       tbl = (odph_hash_table_imp *)(void *)table;

>         for (idx = 0; idx < tbl->hash_node_num; idx++) {

>                 /** notice: memory of one hash_node is

>                  * not only sizeof(odph_hash_node)

>                  * should add the size of Flexible Array

>                  */

> -               node = (odph_hash_node *)((char *)tbl->hash_node_pool

> +               node = (odph_hash_node *)(void *)((char

> *)tbl->hash_node_pool

>                                 + idx * (sizeof(odph_hash_node)

>                                                 + tbl->key_size

>                                                 + tbl->value_size));

> @@ -208,13 +211,15 @@ odph_hash_node *odp_hashnode_take(odph_table_t

> table)

>  /**

>   * Release an node to the pool

>   */

> -void odp_hashnode_give(odph_table_t table, odph_hash_node *node)

> +static void hashnode_give(odph_table_t table, odph_hash_node *node)

>  {

> -       odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;

> +       odph_hash_table_imp *tbl;

>

>         if (node == NULL)

>                 return;

>

> +       tbl = (odph_hash_table_imp *)(void *)table;

> +

>         odph_list_del(&node->list_node);

>         memset(node, 0,

>                (sizeof(odph_hash_node) + tbl->key_size + tbl->value_size));

> @@ -223,7 +228,7 @@ void odp_hashnode_give(odph_table_t table,

> odph_hash_node *node)

>  /* should make sure the input table exists and is available */

>  int odph_hash_put_value(odph_table_t table, void *key, void *value)

>  {

> -       odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;

> +       odph_hash_table_imp *tbl;

>         uint16_t hash = 0;

>         odph_hash_node *node = NULL;

>         char *tmp = NULL;

> @@ -231,6 +236,7 @@ int odph_hash_put_value(odph_table_t table, void

> *key, void *value)

>         if (table == NULL || key == NULL || value == NULL)

>                 return ODPH_FAIL;

>

> +       tbl = (odph_hash_table_imp *)(void *)table;

>         /* hash value is just the index of the list head in pool */

>         hash = odp_key_hash(key, tbl->key_size);

>

> @@ -249,7 +255,7 @@ int odph_hash_put_value(odph_table_t table, void

> *key, void *value)

>         }

>

>         /*if the key is a new one, get a new hash node form the pool */

> -       node = odp_hashnode_take(table);

> +       node = hashnode_take(table);

>         if (node == NULL) {

>                 odp_rwlock_write_unlock(&tbl->lock_pool[hash]);

>                 return ODPH_FAIL;

> @@ -271,11 +277,13 @@ int odph_hash_put_value(odph_table_t table, void

> *key, void *value)

>  int odph_hash_get_value(odph_table_t table, void *key, void *buffer,

>                         uint32_t buffer_size)

>  {

> -       odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;

> +       odph_hash_table_imp *tbl;

>         uint16_t hash = 0;

>         odph_hash_node *node;

>         char *tmp = NULL;

>

> +       tbl = (odph_hash_table_imp *)(void *)table;

> +

>         if (table == NULL || key == NULL || buffer == NULL ||

>             buffer_size < tbl->value_size)

>                 return ODPH_FAIL;

> @@ -308,13 +316,15 @@ int odph_hash_get_value(odph_table_t table, void

> *key, void *buffer,

>  /* should make sure the input table exists and is available */

>  int odph_hash_remove_value(odph_table_t table, void *key)

>  {

> -       odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;

> +       odph_hash_table_imp *tbl;

>         uint16_t hash = 0;

>         odph_hash_node *node;

>

>         if (table == NULL || key == NULL)

>                 return ODPH_FAIL;

>

> +       tbl = (odph_hash_table_imp *)(void *)table;

> +

>         /* hash value is just the index of the list head in pool */

>         hash = odp_key_hash(key, tbl->key_size);

>

> @@ -324,7 +334,7 @@ int odph_hash_remove_value(odph_table_t table, void

> *key)

>                            list_node)

>         {

>                 if (memcmp(node->content, key, tbl->key_size) == 0) {

> -                       odp_hashnode_give(table, node);

> +                       hashnode_give(table, node);

>                         odp_rwlock_write_unlock(&tbl->lock_pool[hash]);

>                         return ODPH_SUCCESS;

>                 }

> diff --git a/helper/iplookuptable.c b/helper/iplookuptable.c

> index f6d6f880..aaebea33 100644

> --- a/helper/iplookuptable.c

> +++ b/helper/iplookuptable.c

> @@ -60,7 +60,7 @@ typedef struct {

>  } prefix_entry_t;

>

>  #define ENTRY_SIZE (sizeof(prefix_entry_t) + sizeof(odp_buffer_t))

> -#define ENTRY_BUFF_ARR(x) ((odp_buffer_t *)((char *)x \

> +#define ENTRY_BUFF_ARR(x) ((odp_buffer_t *)(void *)((char *)x \

>                         + sizeof(prefix_entry_t) * ENTRY_NUM_SUBTREE))

>

>  /** @internal trie node struct

> @@ -434,16 +434,15 @@ odph_iplookup_table_lookup(const char *name)

>         return NULL;

>  }

>

> -odph_table_t

> -odph_iplookup_table_create(

> -               const char *name, uint32_t ODP_IGNORED_1,

> -               uint32_t ODP_IGNORED_2, uint32_t value_size)

> +odph_table_t odph_iplookup_table_create(const char *name,

> +                                       uint32_t p1 ODP_UNUSED,

> +                                       uint32_t p2 ODP_UNUSED,

> +                                       uint32_t value_size)

>  {

>         odph_iplookup_table_impl *tbl;

>         odp_shm_t shm_tbl;

>         odp_queue_t queue;

>         odp_queue_param_t qparam;

> -

>         unsigned i;

>         uint32_t impl_size, l1_size;

>         char queue_name[ODPH_TABLE_NAME_LEN + 2];

> @@ -455,7 +454,7 @@ odph_iplookup_table_create(

>         }

>

>         /* Guarantee there's no existing */

> -       tbl = (odph_iplookup_table_impl *)odph_iplookup_table_lookup(

> name);

> +       tbl = (void *)odph_iplookup_table_lookup(name);

>         if (tbl != NULL) {

>                 ODPH_DBG("IP prefix table %s already exists\n", name);

>                 return NULL;

> @@ -482,7 +481,7 @@ odph_iplookup_table_create(

>         /* header of this mem block is the table impl struct,

>          * then the l1 entries array.

>          */

> -       tbl->l1e = (prefix_entry_t *)((char *)tbl + impl_size);

> +       tbl->l1e = (prefix_entry_t *)(void *)((char *)tbl + impl_size);

>         for (i = 0; i < ENTRY_NUM_L1; i++)

>                 tbl->l1e[i].nexthop = ODP_BUFFER_INVALID;

>

> @@ -528,7 +527,7 @@ odph_iplookup_table_destroy(odph_table_t tbl)

>         if (tbl == NULL)

>                 return -1;

>

> -       impl = (odph_iplookup_table_impl *)tbl;

> +       impl = (odph_iplookup_table_impl *)(void *)tbl;

>

>         /* check magic word */

>         if (impl->magicword != ODPH_IP_LOOKUP_TABLE_MAGIC_WORD) {

> @@ -664,15 +663,15 @@ prefix_insert_iter(

>  int

>  odph_iplookup_table_put_value(odph_table_t tbl, void *key, void *value)

>  {

> -       if ((tbl == NULL) || (key == NULL) || (value == NULL))

> -               return -1;

> -

> -       odph_iplookup_table_impl *impl = (odph_iplookup_table_impl *)tbl;

> +       odph_iplookup_table_impl *impl = (void *)tbl;

>         odph_iplookup_prefix_t *prefix = (odph_iplookup_prefix_t *)key;

>         prefix_entry_t *l1e = NULL;

>         odp_buffer_t nexthop = *((odp_buffer_t *)value);

>         int ret = 0;

>

> +       if ((tbl == NULL) || (key == NULL) || (value == NULL))

> +               return -1;

> +

>         if (prefix->cidr == 0)

>                 return -1;

>         prefix->ip = prefix->ip & (0xffffffff << (IP_LENGTH -

> prefix->cidr));

> @@ -704,18 +703,18 @@ odph_iplookup_table_put_value(odph_table_t tbl,

> void *key, void *value)

>         return ret;

>  }

>

> -int

> -odph_iplookup_table_get_value(

> -               odph_table_t tbl, void *key, void *buffer, uint32_t

> buffer_size)

> +int odph_iplookup_table_get_value(odph_table_t tbl, void *key,

> +                                 void *buffer ODP_UNUSED,

> +                                 uint32_t buffer_size ODP_UNUSED)

>  {

> -       if ((tbl == NULL) || (key == NULL) || (buffer == NULL))

> -               return -EINVAL;

> -

> -       odph_iplookup_table_impl *impl = (odph_iplookup_table_impl *)tbl;

> +       odph_iplookup_table_impl *impl = (void *)tbl;

>         uint32_t ip = *((uint32_t *)key);

>         prefix_entry_t *entry = &impl->l1e[ip >> 16];

>         odp_buffer_t *buff = (odp_buffer_t *)buffer;

>

> +       if ((tbl == NULL) || (key == NULL) || (buffer == NULL))

> +               return -EINVAL;

> +

>         if (entry == NULL) {

>                 ODPH_DBG("failed to get L1 entry.\n");

>                 return -1;

> @@ -880,15 +879,15 @@ prefix_delete_iter(

>  int

>  odph_iplookup_table_remove_value(odph_table_t tbl, void *key)

>  {

> -       if ((tbl == NULL) || (key == NULL))

> -               return -EINVAL;

> -

> -       odph_iplookup_table_impl *impl = (odph_iplookup_table_impl *)tbl;

> +       odph_iplookup_table_impl *impl = (void *)tbl;

>         odph_iplookup_prefix_t *prefix = (odph_iplookup_prefix_t *)key;

>         uint32_t ip = prefix->ip;

>         uint8_t cidr = prefix->cidr;

>

> -       if (prefix->cidr < 0)

> +       if ((tbl == NULL) || (key == NULL))

> +               return -EINVAL;

> +

> +       if (!prefix->cidr)

>                 return -EINVAL;

>

>         prefix_entry_t *entry = &impl->l1e[ip >> 16];

> diff --git a/helper/lineartable.c b/helper/lineartable.c

> index 89179014..e1a396c1 100644

> --- a/helper/lineartable.c

> +++ b/helper/lineartable.c

> @@ -41,9 +41,10 @@ typedef struct {

>   */

>

>  odph_table_t odph_linear_table_create(const char *name, uint32_t capacity,

> -                                     uint32_t ODP_IGNORED, uint32_t

> value_size)

> +                                     uint32_t un ODPH_UNUSED,

> +                                     uint32_t value_size)

>  {

> -       int idx;

> +       uint32_t idx;

>         uint32_t node_num;

>         odp_shm_t shmem;

>         odph_linear_table_imp *tbl;

> @@ -90,8 +91,10 @@ odph_table_t odph_linear_table_create(const char *name,

> uint32_t capacity,

>

>         /* initialize rwlock*/

>         for (idx = 0; idx < tbl->node_sum; idx++) {

> -               odp_rwlock_t *lock = (odp_rwlock_t *)((char

> *)tbl->value_array

> -                               + idx * tbl->value_size);

> +               odp_rwlock_t *lock;

> +

> +               lock = (odp_rwlock_t *)(void *)((char *)tbl->value_array

> +                      + idx * tbl->value_size);

>                 odp_rwlock_init(lock);

>         }

>

> @@ -106,7 +109,7 @@ int odph_linear_table_destroy(odph_table_t table)

>         odph_linear_table_imp *linear_tbl = NULL;

>

>         if (table != NULL) {

> -               linear_tbl = (odph_linear_table_imp *)table;

> +               linear_tbl = (odph_linear_table_imp *)(void *)table;

>

>                 /* check magicword, make sure the memory is used by a

> table */

>                 if (linear_tbl->magicword != ODPH_LINEAR_TABLE_MAGIC_WORD)

> @@ -142,9 +145,10 @@ odph_table_t odph_linear_table_lookup(const char

> *name)

>  }

>

>  /* should make sure the input table exists and is available */

> -int odph_lineartable_put_value(odph_table_t table, void *key, void

> *value)

> +static int odph_lineartable_put_value(odph_table_t table,

> +                                     void *key, void *value)

>  {

> -       odph_linear_table_imp *tbl = (odph_linear_table_imp *)table;

> +       odph_linear_table_imp *tbl;

>         uint32_t ikey = 0;

>         void *entry = NULL;

>         odp_rwlock_t *lock = NULL;

> @@ -152,6 +156,7 @@ int odph_lineartable_put_value(odph_table_t table,

> void *key, void *value)

>         if (table == NULL || key == NULL || value == NULL)

>                 return ODPH_FAIL;

>

> +       tbl = (odph_linear_table_imp *)(void *)table;

>         ikey = *(uint32_t *)key;

>         if (ikey >= tbl->node_sum)

>                 return ODPH_FAIL;

> @@ -170,10 +175,11 @@ int odph_lineartable_put_value(odph_table_t table,

> void *key, void *value)

>  }

>

>  /* should make sure the input table exists and is available */

> -int odph_lineartable_get_value(odph_table_t table, void *key, void

> *buffer,

> -                              uint32_t buffer_size)

> +static int odph_lineartable_get_value(odph_table_t table,

> +                                     void *key, void *buffer,

> +                                     uint32_t buffer_size ODPH_UNUSED)

>  {

> -       odph_linear_table_imp *tbl = (odph_linear_table_imp *)table;

> +       odph_linear_table_imp *tbl;

>         uint32_t ikey = 0;

>         void *entry = NULL;

>         odp_rwlock_t *lock = NULL;

> @@ -181,6 +187,7 @@ int odph_lineartable_get_value(odph_table_t table,

> void *key, void *buffer,

>         if (table == NULL || key == NULL || buffer == NULL)

>                 return ODPH_FAIL;

>

> +       tbl = (odph_linear_table_imp *)(void *)table;

>         ikey = *(uint32_t *)key;

>         if (ikey >= tbl->node_sum)

>                 return ODPH_FAIL;

> diff --git a/helper/threads.c b/helper/threads.c

> index fe5d2bde..cb747e5b 100644

> --- a/helper/threads.c

> +++ b/helper/threads.c

> @@ -419,7 +419,7 @@ int odph_parse_options(int argc, char *argv[],

>                 {0, 0, 0, 0}

>                 };

>

> -       static char *helper_short_options = "";

> +       static const char *helper_short_options = "";

>

>         /* defaults: */

>         helper_options.proc = false;

> --

> 2.11.0.295.gd7dffce

>

>



-- 
Mike Holmes
Program Manager - Linaro Networking Group
Linaro.org <http://www.linaro.org/> *│ *Open source software for ARM SoCs
"Work should be fun and collaborative, the rest follows"
Maxim Uvarov Jan. 27, 2017, 3:43 p.m. UTC | #2
On 01/27/17 18:40, Mike Holmes wrote:
> One nit below on formatting.

> 

> On 27 January 2017 at 10:19, Maxim Uvarov <maxim.uvarov@linaro.org

> <mailto:maxim.uvarov@linaro.org>> wrote:

> 

>     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

>     <mailto:maxim.uvarov@linaro.org>>

> 

> 

> Reviewed-by: Mike Holmes <mike.holmes@linaro.org

> <mailto:mike.holmes@linaro.org>>


for both patches?

can I merge lines on apply?


>  

> 

>     ---

>      v3: fix gcc compilation

>      v2: rebase

> 

>      helper/chksum.c        |  4 ++--

>      helper/cuckootable.c   | 49

>     ++++++++++++++++++++-----------------------------

>      helper/hashtable.c     | 42 ++++++++++++++++++++++++++----------------

>      helper/iplookuptable.c | 49

>     ++++++++++++++++++++++++-------------------------

>      helper/lineartable.c   | 27 +++++++++++++++++----------

>      helper/threads.c       |  2 +-

>      6 files changed, 90 insertions(+), 83 deletions(-)

> 

>     diff --git a/helper/chksum.c b/helper/chksum.c

>     index b7eef67e..f740618d 100644

>     --- a/helper/chksum.c

>     +++ b/helper/chksum.c

>     @@ -49,7 +49,7 @@ static uint32_t data_seg_sum(uint8_t   *data8_ptr,

>                     data_len--;

>             }

> 

>     -       data16_ptr = (uint16_t *)data8_ptr;

>     +       data16_ptr = (uint16_t *)(void *)data8_ptr;

> 

>             /* The following code tries to gain a modest performance

>     enhancement by

>              * unrolling the normal 16 bits at a time loop eight times. 

>     Even

>     @@ -216,7 +216,7 @@ static inline int

>     odph_process_l3_hdr(odp_packet_t odp_pkt,

>                             ipv6_hdr_ptr = &ipv6_hdr;

>                     }

> 

>     -               addrs_ptr        = (uint16_t *)&ipv6_hdr_ptr->src_addr;

>     +               addrs_ptr        = (uint16_t *)(void

>     *)&ipv6_hdr_ptr->src_addr;

>                     addrs_len        = 2 * ODPH_IPV6ADDR_LEN;

>                     protocol         = ipv6_hdr_ptr->next_hdr;

>                     ipv6_payload_len =

>     odp_be_to_cpu_16(ipv6_hdr_ptr->payload_len);

>     diff --git a/helper/cuckootable.c b/helper/cuckootable.c

>     index 83647ec2..396e7f53 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,7 +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 *)(

>     +       tbl->buckets = (void *)(

>                             (char *)tbl + impl_size);

> 

> 

> Can't this all fit on one line ?

>  

> 

> 

>             /* initialize key-value buffer pool */

>     @@ -309,17 +297,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 +567,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 +643,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 +725,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;

> 

>     diff --git a/helper/hashtable.c b/helper/hashtable.c

>     index 983b3da9..1c2b8523 100644

>     --- a/helper/hashtable.c

>     +++ b/helper/hashtable.c

>     @@ -101,9 +101,9 @@ odph_table_t odph_hash_table_create(const char

>     *name, uint32_t capacity,

>              * the last part is the element node pool

>              */

> 

>     -       tbl->lock_pool = (odp_rwlock_t *)((char *)tbl

>     +       tbl->lock_pool = (odp_rwlock_t *)(void *)((char *)tbl

>                             + sizeof(odph_hash_table_imp));

>     -       tbl->list_head_pool = (odph_list_head *)((char *)tbl->lock_pool

>     +       tbl->list_head_pool = (odph_list_head *)(void *)((char

>     *)tbl->lock_pool

>                             + ODPH_MAX_BUCKET_NUM * sizeof(odp_rwlock_t));

> 

>             node_mem = tbl->init_cap - sizeof(odph_hash_table_imp)

>     @@ -112,8 +112,9 @@ odph_table_t odph_hash_table_create(const char

>     *name, uint32_t capacity,

> 

>             node_num = node_mem / (sizeof(odph_hash_node) + key_size +

>     value_size);

>             tbl->hash_node_num = node_num;

>     -       tbl->hash_node_pool = (odph_hash_node *)((char

>     *)tbl->list_head_pool

>     -                               + ODPH_MAX_BUCKET_NUM *

>     sizeof(odph_list_head));

>     +       tbl->hash_node_pool =

>     +               (odph_hash_node *)(void *)((char *)tbl->list_head_pool

>     +               + ODPH_MAX_BUCKET_NUM * sizeof(odph_list_head));

> 

>             /* init every list head and rw lock */

>             for (i = 0; i < ODPH_MAX_BUCKET_NUM; i++) {

>     @@ -130,8 +131,9 @@ int odph_hash_table_destroy(odph_table_t table)

>             int ret;

> 

>             if (table != NULL) {

>     -               odph_hash_table_imp *hash_tbl = (odph_hash_table_imp

>     *)table;

>     +               odph_hash_table_imp *hash_tbl;

> 

>     +               hash_tbl = (odph_hash_table_imp *)(void *)table;

>                     if (hash_tbl->magicword != ODPH_HASH_TABLE_MAGIC_WORD)

>                             return ODPH_FAIL;

> 

>     @@ -164,7 +166,7 @@ odph_table_t odph_hash_table_lookup(const char

>     *name)

>       * This hash algorithm is the most simple one, so we choose it as

>     an DEMO

>       * User can use any other algorithm, like CRC...

>       */

>     -uint16_t odp_key_hash(void *key, uint32_t key_size)

>     +static uint16_t odp_key_hash(void *key, uint32_t key_size)

>      {

>             register uint32_t hash = 0;

>             uint32_t idx = (key_size == 0 ? 1 : key_size);

>     @@ -181,18 +183,19 @@ uint16_t odp_key_hash(void *key, uint32_t

>     key_size)

>      /**

>       * Get an available node from pool

>       */

>     -odph_hash_node *odp_hashnode_take(odph_table_t table)

>     +static odph_hash_node *hashnode_take(odph_table_t table)

>      {

>     -       odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;

>     +       odph_hash_table_imp *tbl;

>             uint32_t idx;

>             odph_hash_node *node;

> 

>     +       tbl = (odph_hash_table_imp *)(void *)table;

>             for (idx = 0; idx < tbl->hash_node_num; idx++) {

>                     /** notice: memory of one hash_node is

>                      * not only sizeof(odph_hash_node)

>                      * should add the size of Flexible Array

>                      */

>     -               node = (odph_hash_node *)((char *)tbl->hash_node_pool

>     +               node = (odph_hash_node *)(void *)((char

>     *)tbl->hash_node_pool

>                                     + idx * (sizeof(odph_hash_node)

>                                                     + tbl->key_size

>                                                     + tbl->value_size));

>     @@ -208,13 +211,15 @@ odph_hash_node *odp_hashnode_take(odph_table_t

>     table)

>      /**

>       * Release an node to the pool

>       */

>     -void odp_hashnode_give(odph_table_t table, odph_hash_node *node)

>     +static void hashnode_give(odph_table_t table, odph_hash_node *node)

>      {

>     -       odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;

>     +       odph_hash_table_imp *tbl;

> 

>             if (node == NULL)

>                     return;

> 

>     +       tbl = (odph_hash_table_imp *)(void *)table;

>     +

>             odph_list_del(&node->list_node);

>             memset(node, 0,

>                    (sizeof(odph_hash_node) + tbl->key_size +

>     tbl->value_size));

>     @@ -223,7 +228,7 @@ void odp_hashnode_give(odph_table_t table,

>     odph_hash_node *node)

>      /* should make sure the input table exists and is available */

>      int odph_hash_put_value(odph_table_t table, void *key, void *value)

>      {

>     -       odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;

>     +       odph_hash_table_imp *tbl;

>             uint16_t hash = 0;

>             odph_hash_node *node = NULL;

>             char *tmp = NULL;

>     @@ -231,6 +236,7 @@ int odph_hash_put_value(odph_table_t table, void

>     *key, void *value)

>             if (table == NULL || key == NULL || value == NULL)

>                     return ODPH_FAIL;

> 

>     +       tbl = (odph_hash_table_imp *)(void *)table;

>             /* hash value is just the index of the list head in pool */

>             hash = odp_key_hash(key, tbl->key_size);

> 

>     @@ -249,7 +255,7 @@ int odph_hash_put_value(odph_table_t table, void

>     *key, void *value)

>             }

> 

>             /*if the key is a new one, get a new hash node form the pool */

>     -       node = odp_hashnode_take(table);

>     +       node = hashnode_take(table);

>             if (node == NULL) {

>                     odp_rwlock_write_unlock(&tbl->lock_pool[hash]);

>                     return ODPH_FAIL;

>     @@ -271,11 +277,13 @@ int odph_hash_put_value(odph_table_t table,

>     void *key, void *value)

>      int odph_hash_get_value(odph_table_t table, void *key, void *buffer,

>                             uint32_t buffer_size)

>      {

>     -       odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;

>     +       odph_hash_table_imp *tbl;

>             uint16_t hash = 0;

>             odph_hash_node *node;

>             char *tmp = NULL;

> 

>     +       tbl = (odph_hash_table_imp *)(void *)table;

>     +

>             if (table == NULL || key == NULL || buffer == NULL ||

>                 buffer_size < tbl->value_size)

>                     return ODPH_FAIL;

>     @@ -308,13 +316,15 @@ int odph_hash_get_value(odph_table_t table,

>     void *key, void *buffer,

>      /* should make sure the input table exists and is available */

>      int odph_hash_remove_value(odph_table_t table, void *key)

>      {

>     -       odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;

>     +       odph_hash_table_imp *tbl;

>             uint16_t hash = 0;

>             odph_hash_node *node;

> 

>             if (table == NULL || key == NULL)

>                     return ODPH_FAIL;

> 

>     +       tbl = (odph_hash_table_imp *)(void *)table;

>     +

>             /* hash value is just the index of the list head in pool */

>             hash = odp_key_hash(key, tbl->key_size);

> 

>     @@ -324,7 +334,7 @@ int odph_hash_remove_value(odph_table_t table,

>     void *key)

>                                list_node)

>             {

>                     if (memcmp(node->content, key, tbl->key_size) == 0) {

>     -                       odp_hashnode_give(table, node);

>     +                       hashnode_give(table, node);

>                             odp_rwlock_write_unlock(&tbl->lock_pool[hash]);

>                             return ODPH_SUCCESS;

>                     }

>     diff --git a/helper/iplookuptable.c b/helper/iplookuptable.c

>     index f6d6f880..aaebea33 100644

>     --- a/helper/iplookuptable.c

>     +++ b/helper/iplookuptable.c

>     @@ -60,7 +60,7 @@ typedef struct {

>      } prefix_entry_t;

> 

>      #define ENTRY_SIZE (sizeof(prefix_entry_t) + sizeof(odp_buffer_t))

>     -#define ENTRY_BUFF_ARR(x) ((odp_buffer_t *)((char *)x \

>     +#define ENTRY_BUFF_ARR(x) ((odp_buffer_t *)(void *)((char *)x \

>                             + sizeof(prefix_entry_t) * ENTRY_NUM_SUBTREE))

> 

>      /** @internal trie node struct

>     @@ -434,16 +434,15 @@ odph_iplookup_table_lookup(const char *name)

>             return NULL;

>      }

> 

>     -odph_table_t

>     -odph_iplookup_table_create(

>     -               const char *name, uint32_t ODP_IGNORED_1,

>     -               uint32_t ODP_IGNORED_2, uint32_t value_size)

>     +odph_table_t odph_iplookup_table_create(const char *name,

>     +                                       uint32_t p1 ODP_UNUSED,

>     +                                       uint32_t p2 ODP_UNUSED,

>     +                                       uint32_t value_size)

>      {

>             odph_iplookup_table_impl *tbl;

>             odp_shm_t shm_tbl;

>             odp_queue_t queue;

>             odp_queue_param_t qparam;

>     -

>             unsigned i;

>             uint32_t impl_size, l1_size;

>             char queue_name[ODPH_TABLE_NAME_LEN + 2];

>     @@ -455,7 +454,7 @@ odph_iplookup_table_create(

>             }

> 

>             /* Guarantee there's no existing */

>     -       tbl = (odph_iplookup_table_impl

>     *)odph_iplookup_table_lookup(name);

>     +       tbl = (void *)odph_iplookup_table_lookup(name);

>             if (tbl != NULL) {

>                     ODPH_DBG("IP prefix table %s already exists\n", name);

>                     return NULL;

>     @@ -482,7 +481,7 @@ odph_iplookup_table_create(

>             /* header of this mem block is the table impl struct,

>              * then the l1 entries array.

>              */

>     -       tbl->l1e = (prefix_entry_t *)((char *)tbl + impl_size);

>     +       tbl->l1e = (prefix_entry_t *)(void *)((char *)tbl + impl_size);

>             for (i = 0; i < ENTRY_NUM_L1; i++)

>                     tbl->l1e[i].nexthop = ODP_BUFFER_INVALID;

> 

>     @@ -528,7 +527,7 @@ odph_iplookup_table_destroy(odph_table_t tbl)

>             if (tbl == NULL)

>                     return -1;

> 

>     -       impl = (odph_iplookup_table_impl *)tbl;

>     +       impl = (odph_iplookup_table_impl *)(void *)tbl;

> 

>             /* check magic word */

>             if (impl->magicword != ODPH_IP_LOOKUP_TABLE_MAGIC_WORD) {

>     @@ -664,15 +663,15 @@ prefix_insert_iter(

>      int

>      odph_iplookup_table_put_value(odph_table_t tbl, void *key, void *value)

>      {

>     -       if ((tbl == NULL) || (key == NULL) || (value == NULL))

>     -               return -1;

>     -

>     -       odph_iplookup_table_impl *impl = (odph_iplookup_table_impl

>     *)tbl;

>     +       odph_iplookup_table_impl *impl = (void *)tbl;

>             odph_iplookup_prefix_t *prefix = (odph_iplookup_prefix_t *)key;

>             prefix_entry_t *l1e = NULL;

>             odp_buffer_t nexthop = *((odp_buffer_t *)value);

>             int ret = 0;

> 

>     +       if ((tbl == NULL) || (key == NULL) || (value == NULL))

>     +               return -1;

>     +

>             if (prefix->cidr == 0)

>                     return -1;

>             prefix->ip = prefix->ip & (0xffffffff << (IP_LENGTH -

>     prefix->cidr));

>     @@ -704,18 +703,18 @@ odph_iplookup_table_put_value(odph_table_t

>     tbl, void *key, void *value)

>             return ret;

>      }

> 

>     -int

>     -odph_iplookup_table_get_value(

>     -               odph_table_t tbl, void *key, void *buffer, uint32_t

>     buffer_size)

>     +int odph_iplookup_table_get_value(odph_table_t tbl, void *key,

>     +                                 void *buffer ODP_UNUSED,

>     +                                 uint32_t buffer_size ODP_UNUSED)

>      {

>     -       if ((tbl == NULL) || (key == NULL) || (buffer == NULL))

>     -               return -EINVAL;

>     -

>     -       odph_iplookup_table_impl *impl = (odph_iplookup_table_impl

>     *)tbl;

>     +       odph_iplookup_table_impl *impl = (void *)tbl;

>             uint32_t ip = *((uint32_t *)key);

>             prefix_entry_t *entry = &impl->l1e[ip >> 16];

>             odp_buffer_t *buff = (odp_buffer_t *)buffer;

> 

>     +       if ((tbl == NULL) || (key == NULL) || (buffer == NULL))

>     +               return -EINVAL;

>     +

>             if (entry == NULL) {

>                     ODPH_DBG("failed to get L1 entry.\n");

>                     return -1;

>     @@ -880,15 +879,15 @@ prefix_delete_iter(

>      int

>      odph_iplookup_table_remove_value(odph_table_t tbl, void *key)

>      {

>     -       if ((tbl == NULL) || (key == NULL))

>     -               return -EINVAL;

>     -

>     -       odph_iplookup_table_impl *impl = (odph_iplookup_table_impl

>     *)tbl;

>     +       odph_iplookup_table_impl *impl = (void *)tbl;

>             odph_iplookup_prefix_t *prefix = (odph_iplookup_prefix_t *)key;

>             uint32_t ip = prefix->ip;

>             uint8_t cidr = prefix->cidr;

> 

>     -       if (prefix->cidr < 0)

>     +       if ((tbl == NULL) || (key == NULL))

>     +               return -EINVAL;

>     +

>     +       if (!prefix->cidr)

>                     return -EINVAL;

> 

>             prefix_entry_t *entry = &impl->l1e[ip >> 16];

>     diff --git a/helper/lineartable.c b/helper/lineartable.c

>     index 89179014..e1a396c1 100644

>     --- a/helper/lineartable.c

>     +++ b/helper/lineartable.c

>     @@ -41,9 +41,10 @@ typedef struct {

>       */

> 

>      odph_table_t odph_linear_table_create(const char *name, uint32_t

>     capacity,

>     -                                     uint32_t ODP_IGNORED, uint32_t

>     value_size)

>     +                                     uint32_t un ODPH_UNUSED,

>     +                                     uint32_t value_size)

>      {

>     -       int idx;

>     +       uint32_t idx;

>             uint32_t node_num;

>             odp_shm_t shmem;

>             odph_linear_table_imp *tbl;

>     @@ -90,8 +91,10 @@ odph_table_t odph_linear_table_create(const char

>     *name, uint32_t capacity,

> 

>             /* initialize rwlock*/

>             for (idx = 0; idx < tbl->node_sum; idx++) {

>     -               odp_rwlock_t *lock = (odp_rwlock_t *)((char

>     *)tbl->value_array

>     -                               + idx * tbl->value_size);

>     +               odp_rwlock_t *lock;

>     +

>     +               lock = (odp_rwlock_t *)(void *)((char *)tbl->value_array

>     +                      + idx * tbl->value_size);

>                     odp_rwlock_init(lock);

>             }

> 

>     @@ -106,7 +109,7 @@ int odph_linear_table_destroy(odph_table_t table)

>             odph_linear_table_imp *linear_tbl = NULL;

> 

>             if (table != NULL) {

>     -               linear_tbl = (odph_linear_table_imp *)table;

>     +               linear_tbl = (odph_linear_table_imp *)(void *)table;

> 

>                     /* check magicword, make sure the memory is used by

>     a table */

>                     if (linear_tbl->magicword !=

>     ODPH_LINEAR_TABLE_MAGIC_WORD)

>     @@ -142,9 +145,10 @@ odph_table_t odph_linear_table_lookup(const

>     char *name)

>      }

> 

>      /* should make sure the input table exists and is available */

>     -int odph_lineartable_put_value(odph_table_t table, void *key, void

>     *value)

>     +static int odph_lineartable_put_value(odph_table_t table,

>     +                                     void *key, void *value)

>      {

>     -       odph_linear_table_imp *tbl = (odph_linear_table_imp *)table;

>     +       odph_linear_table_imp *tbl;

>             uint32_t ikey = 0;

>             void *entry = NULL;

>             odp_rwlock_t *lock = NULL;

>     @@ -152,6 +156,7 @@ int odph_lineartable_put_value(odph_table_t

>     table, void *key, void *value)

>             if (table == NULL || key == NULL || value == NULL)

>                     return ODPH_FAIL;

> 

>     +       tbl = (odph_linear_table_imp *)(void *)table;

>             ikey = *(uint32_t *)key;

>             if (ikey >= tbl->node_sum)

>                     return ODPH_FAIL;

>     @@ -170,10 +175,11 @@ int odph_lineartable_put_value(odph_table_t

>     table, void *key, void *value)

>      }

> 

>      /* should make sure the input table exists and is available */

>     -int odph_lineartable_get_value(odph_table_t table, void *key, void

>     *buffer,

>     -                              uint32_t buffer_size)

>     +static int odph_lineartable_get_value(odph_table_t table,

>     +                                     void *key, void *buffer,

>     +                                     uint32_t buffer_size ODPH_UNUSED)

>      {

>     -       odph_linear_table_imp *tbl = (odph_linear_table_imp *)table;

>     +       odph_linear_table_imp *tbl;

>             uint32_t ikey = 0;

>             void *entry = NULL;

>             odp_rwlock_t *lock = NULL;

>     @@ -181,6 +187,7 @@ int odph_lineartable_get_value(odph_table_t

>     table, void *key, void *buffer,

>             if (table == NULL || key == NULL || buffer == NULL)

>                     return ODPH_FAIL;

> 

>     +       tbl = (odph_linear_table_imp *)(void *)table;

>             ikey = *(uint32_t *)key;

>             if (ikey >= tbl->node_sum)

>                     return ODPH_FAIL;

>     diff --git a/helper/threads.c b/helper/threads.c

>     index fe5d2bde..cb747e5b 100644

>     --- a/helper/threads.c

>     +++ b/helper/threads.c

>     @@ -419,7 +419,7 @@ int odph_parse_options(int argc, char *argv[],

>                     {0, 0, 0, 0}

>                     };

> 

>     -       static char *helper_short_options = "";

>     +       static const char *helper_short_options = "";

> 

>             /* defaults: */

>             helper_options.proc = false;

>     --

>     2.11.0.295.gd7dffce

> 

> 

> 

> 

> -- 

> Mike Holmes

> Program Manager - Linaro Networking Group

> Linaro.org <http://www.linaro.org/>* **│ *Open source software for ARM SoCs

> "Work should be fun and collaborative, the rest follows"

> 

> __

> 

>
Mike Holmes Jan. 27, 2017, 3:47 p.m. UTC | #3
On 27 January 2017 at 10:43, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:

> On 01/27/17 18:40, Mike Holmes wrote:

> > One nit below on formatting.

> >

> > On 27 January 2017 at 10:19, Maxim Uvarov <maxim.uvarov@linaro.org

> > <mailto:maxim.uvarov@linaro.org>> wrote:

> >

> >     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

> >     <mailto:maxim.uvarov@linaro.org>>

> >

> >

> > Reviewed-by: Mike Holmes <mike.holmes@linaro.org

> > <mailto:mike.holmes@linaro.org>>

>

> for both patches?

>

>

sorry yes


> can I merge lines on apply?

>


yes


>

>

> >

> >

> >     ---

> >      v3: fix gcc compilation

> >      v2: rebase

> >

> >      helper/chksum.c        |  4 ++--

> >      helper/cuckootable.c   | 49

> >     ++++++++++++++++++++-----------------------------

> >      helper/hashtable.c     | 42 ++++++++++++++++++++++++++----

> ------------

> >      helper/iplookuptable.c | 49

> >     ++++++++++++++++++++++++-------------------------

> >      helper/lineartable.c   | 27 +++++++++++++++++----------

> >      helper/threads.c       |  2 +-

> >      6 files changed, 90 insertions(+), 83 deletions(-)

> >

> >     diff --git a/helper/chksum.c b/helper/chksum.c

> >     index b7eef67e..f740618d 100644

> >     --- a/helper/chksum.c

> >     +++ b/helper/chksum.c

> >     @@ -49,7 +49,7 @@ static uint32_t data_seg_sum(uint8_t   *data8_ptr,

> >                     data_len--;

> >             }

> >

> >     -       data16_ptr = (uint16_t *)data8_ptr;

> >     +       data16_ptr = (uint16_t *)(void *)data8_ptr;

> >

> >             /* The following code tries to gain a modest performance

> >     enhancement by

> >              * unrolling the normal 16 bits at a time loop eight times.

> >     Even

> >     @@ -216,7 +216,7 @@ static inline int

> >     odph_process_l3_hdr(odp_packet_t odp_pkt,

> >                             ipv6_hdr_ptr = &ipv6_hdr;

> >                     }

> >

> >     -               addrs_ptr        = (uint16_t

> *)&ipv6_hdr_ptr->src_addr;

> >     +               addrs_ptr        = (uint16_t *)(void

> >     *)&ipv6_hdr_ptr->src_addr;

> >                     addrs_len        = 2 * ODPH_IPV6ADDR_LEN;

> >                     protocol         = ipv6_hdr_ptr->next_hdr;

> >                     ipv6_payload_len =

> >     odp_be_to_cpu_16(ipv6_hdr_ptr->payload_len);

> >     diff --git a/helper/cuckootable.c b/helper/cuckootable.c

> >     index 83647ec2..396e7f53 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,7 +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 *)(

> >     +       tbl->buckets = (void *)(

> >                             (char *)tbl + impl_size);

> >

> >

> > Can't this all fit on one line ?

> >

> >

> >

> >             /* initialize key-value buffer pool */

> >     @@ -309,17 +297,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 +567,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 +643,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 +725,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;

> >

> >     diff --git a/helper/hashtable.c b/helper/hashtable.c

> >     index 983b3da9..1c2b8523 100644

> >     --- a/helper/hashtable.c

> >     +++ b/helper/hashtable.c

> >     @@ -101,9 +101,9 @@ odph_table_t odph_hash_table_create(const char

> >     *name, uint32_t capacity,

> >              * the last part is the element node pool

> >              */

> >

> >     -       tbl->lock_pool = (odp_rwlock_t *)((char *)tbl

> >     +       tbl->lock_pool = (odp_rwlock_t *)(void *)((char *)tbl

> >                             + sizeof(odph_hash_table_imp));

> >     -       tbl->list_head_pool = (odph_list_head *)((char

> *)tbl->lock_pool

> >     +       tbl->list_head_pool = (odph_list_head *)(void *)((char

> >     *)tbl->lock_pool

> >                             + ODPH_MAX_BUCKET_NUM *

> sizeof(odp_rwlock_t));

> >

> >             node_mem = tbl->init_cap - sizeof(odph_hash_table_imp)

> >     @@ -112,8 +112,9 @@ odph_table_t odph_hash_table_create(const char

> >     *name, uint32_t capacity,

> >

> >             node_num = node_mem / (sizeof(odph_hash_node) + key_size +

> >     value_size);

> >             tbl->hash_node_num = node_num;

> >     -       tbl->hash_node_pool = (odph_hash_node *)((char

> >     *)tbl->list_head_pool

> >     -                               + ODPH_MAX_BUCKET_NUM *

> >     sizeof(odph_list_head));

> >     +       tbl->hash_node_pool =

> >     +               (odph_hash_node *)(void *)((char

> *)tbl->list_head_pool

> >     +               + ODPH_MAX_BUCKET_NUM * sizeof(odph_list_head));

> >

> >             /* init every list head and rw lock */

> >             for (i = 0; i < ODPH_MAX_BUCKET_NUM; i++) {

> >     @@ -130,8 +131,9 @@ int odph_hash_table_destroy(odph_table_t table)

> >             int ret;

> >

> >             if (table != NULL) {

> >     -               odph_hash_table_imp *hash_tbl = (odph_hash_table_imp

> >     *)table;

> >     +               odph_hash_table_imp *hash_tbl;

> >

> >     +               hash_tbl = (odph_hash_table_imp *)(void *)table;

> >                     if (hash_tbl->magicword !=

> ODPH_HASH_TABLE_MAGIC_WORD)

> >                             return ODPH_FAIL;

> >

> >     @@ -164,7 +166,7 @@ odph_table_t odph_hash_table_lookup(const char

> >     *name)

> >       * This hash algorithm is the most simple one, so we choose it as

> >     an DEMO

> >       * User can use any other algorithm, like CRC...

> >       */

> >     -uint16_t odp_key_hash(void *key, uint32_t key_size)

> >     +static uint16_t odp_key_hash(void *key, uint32_t key_size)

> >      {

> >             register uint32_t hash = 0;

> >             uint32_t idx = (key_size == 0 ? 1 : key_size);

> >     @@ -181,18 +183,19 @@ uint16_t odp_key_hash(void *key, uint32_t

> >     key_size)

> >      /**

> >       * Get an available node from pool

> >       */

> >     -odph_hash_node *odp_hashnode_take(odph_table_t table)

> >     +static odph_hash_node *hashnode_take(odph_table_t table)

> >      {

> >     -       odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;

> >     +       odph_hash_table_imp *tbl;

> >             uint32_t idx;

> >             odph_hash_node *node;

> >

> >     +       tbl = (odph_hash_table_imp *)(void *)table;

> >             for (idx = 0; idx < tbl->hash_node_num; idx++) {

> >                     /** notice: memory of one hash_node is

> >                      * not only sizeof(odph_hash_node)

> >                      * should add the size of Flexible Array

> >                      */

> >     -               node = (odph_hash_node *)((char *)tbl->hash_node_pool

> >     +               node = (odph_hash_node *)(void *)((char

> >     *)tbl->hash_node_pool

> >                                     + idx * (sizeof(odph_hash_node)

> >                                                     + tbl->key_size

> >                                                     + tbl->value_size));

> >     @@ -208,13 +211,15 @@ odph_hash_node *odp_hashnode_take(odph_table_t

> >     table)

> >      /**

> >       * Release an node to the pool

> >       */

> >     -void odp_hashnode_give(odph_table_t table, odph_hash_node *node)

> >     +static void hashnode_give(odph_table_t table, odph_hash_node *node)

> >      {

> >     -       odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;

> >     +       odph_hash_table_imp *tbl;

> >

> >             if (node == NULL)

> >                     return;

> >

> >     +       tbl = (odph_hash_table_imp *)(void *)table;

> >     +

> >             odph_list_del(&node->list_node);

> >             memset(node, 0,

> >                    (sizeof(odph_hash_node) + tbl->key_size +

> >     tbl->value_size));

> >     @@ -223,7 +228,7 @@ void odp_hashnode_give(odph_table_t table,

> >     odph_hash_node *node)

> >      /* should make sure the input table exists and is available */

> >      int odph_hash_put_value(odph_table_t table, void *key, void *value)

> >      {

> >     -       odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;

> >     +       odph_hash_table_imp *tbl;

> >             uint16_t hash = 0;

> >             odph_hash_node *node = NULL;

> >             char *tmp = NULL;

> >     @@ -231,6 +236,7 @@ int odph_hash_put_value(odph_table_t table, void

> >     *key, void *value)

> >             if (table == NULL || key == NULL || value == NULL)

> >                     return ODPH_FAIL;

> >

> >     +       tbl = (odph_hash_table_imp *)(void *)table;

> >             /* hash value is just the index of the list head in pool */

> >             hash = odp_key_hash(key, tbl->key_size);

> >

> >     @@ -249,7 +255,7 @@ int odph_hash_put_value(odph_table_t table, void

> >     *key, void *value)

> >             }

> >

> >             /*if the key is a new one, get a new hash node form the pool

> */

> >     -       node = odp_hashnode_take(table);

> >     +       node = hashnode_take(table);

> >             if (node == NULL) {

> >                     odp_rwlock_write_unlock(&tbl->lock_pool[hash]);

> >                     return ODPH_FAIL;

> >     @@ -271,11 +277,13 @@ int odph_hash_put_value(odph_table_t table,

> >     void *key, void *value)

> >      int odph_hash_get_value(odph_table_t table, void *key, void

> *buffer,

> >                             uint32_t buffer_size)

> >      {

> >     -       odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;

> >     +       odph_hash_table_imp *tbl;

> >             uint16_t hash = 0;

> >             odph_hash_node *node;

> >             char *tmp = NULL;

> >

> >     +       tbl = (odph_hash_table_imp *)(void *)table;

> >     +

> >             if (table == NULL || key == NULL || buffer == NULL ||

> >                 buffer_size < tbl->value_size)

> >                     return ODPH_FAIL;

> >     @@ -308,13 +316,15 @@ int odph_hash_get_value(odph_table_t table,

> >     void *key, void *buffer,

> >      /* should make sure the input table exists and is available */

> >      int odph_hash_remove_value(odph_table_t table, void *key)

> >      {

> >     -       odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;

> >     +       odph_hash_table_imp *tbl;

> >             uint16_t hash = 0;

> >             odph_hash_node *node;

> >

> >             if (table == NULL || key == NULL)

> >                     return ODPH_FAIL;

> >

> >     +       tbl = (odph_hash_table_imp *)(void *)table;

> >     +

> >             /* hash value is just the index of the list head in pool */

> >             hash = odp_key_hash(key, tbl->key_size);

> >

> >     @@ -324,7 +334,7 @@ int odph_hash_remove_value(odph_table_t table,

> >     void *key)

> >                                list_node)

> >             {

> >                     if (memcmp(node->content, key, tbl->key_size) == 0) {

> >     -                       odp_hashnode_give(table, node);

> >     +                       hashnode_give(table, node);

> >                             odp_rwlock_write_unlock(&tbl->

> lock_pool[hash]);

> >                             return ODPH_SUCCESS;

> >                     }

> >     diff --git a/helper/iplookuptable.c b/helper/iplookuptable.c

> >     index f6d6f880..aaebea33 100644

> >     --- a/helper/iplookuptable.c

> >     +++ b/helper/iplookuptable.c

> >     @@ -60,7 +60,7 @@ typedef struct {

> >      } prefix_entry_t;

> >

> >      #define ENTRY_SIZE (sizeof(prefix_entry_t) + sizeof(odp_buffer_t))

> >     -#define ENTRY_BUFF_ARR(x) ((odp_buffer_t *)((char *)x \

> >     +#define ENTRY_BUFF_ARR(x) ((odp_buffer_t *)(void *)((char *)x \

> >                             + sizeof(prefix_entry_t) *

> ENTRY_NUM_SUBTREE))

> >

> >      /** @internal trie node struct

> >     @@ -434,16 +434,15 @@ odph_iplookup_table_lookup(const char *name)

> >             return NULL;

> >      }

> >

> >     -odph_table_t

> >     -odph_iplookup_table_create(

> >     -               const char *name, uint32_t ODP_IGNORED_1,

> >     -               uint32_t ODP_IGNORED_2, uint32_t value_size)

> >     +odph_table_t odph_iplookup_table_create(const char *name,

> >     +                                       uint32_t p1 ODP_UNUSED,

> >     +                                       uint32_t p2 ODP_UNUSED,

> >     +                                       uint32_t value_size)

> >      {

> >             odph_iplookup_table_impl *tbl;

> >             odp_shm_t shm_tbl;

> >             odp_queue_t queue;

> >             odp_queue_param_t qparam;

> >     -

> >             unsigned i;

> >             uint32_t impl_size, l1_size;

> >             char queue_name[ODPH_TABLE_NAME_LEN + 2];

> >     @@ -455,7 +454,7 @@ odph_iplookup_table_create(

> >             }

> >

> >             /* Guarantee there's no existing */

> >     -       tbl = (odph_iplookup_table_impl

> >     *)odph_iplookup_table_lookup(name);

> >     +       tbl = (void *)odph_iplookup_table_lookup(name);

> >             if (tbl != NULL) {

> >                     ODPH_DBG("IP prefix table %s already exists\n",

> name);

> >                     return NULL;

> >     @@ -482,7 +481,7 @@ odph_iplookup_table_create(

> >             /* header of this mem block is the table impl struct,

> >              * then the l1 entries array.

> >              */

> >     -       tbl->l1e = (prefix_entry_t *)((char *)tbl + impl_size);

> >     +       tbl->l1e = (prefix_entry_t *)(void *)((char *)tbl +

> impl_size);

> >             for (i = 0; i < ENTRY_NUM_L1; i++)

> >                     tbl->l1e[i].nexthop = ODP_BUFFER_INVALID;

> >

> >     @@ -528,7 +527,7 @@ odph_iplookup_table_destroy(odph_table_t tbl)

> >             if (tbl == NULL)

> >                     return -1;

> >

> >     -       impl = (odph_iplookup_table_impl *)tbl;

> >     +       impl = (odph_iplookup_table_impl *)(void *)tbl;

> >

> >             /* check magic word */

> >             if (impl->magicword != ODPH_IP_LOOKUP_TABLE_MAGIC_WORD) {

> >     @@ -664,15 +663,15 @@ prefix_insert_iter(

> >      int

> >      odph_iplookup_table_put_value(odph_table_t tbl, void *key, void

> *value)

> >      {

> >     -       if ((tbl == NULL) || (key == NULL) || (value == NULL))

> >     -               return -1;

> >     -

> >     -       odph_iplookup_table_impl *impl = (odph_iplookup_table_impl

> >     *)tbl;

> >     +       odph_iplookup_table_impl *impl = (void *)tbl;

> >             odph_iplookup_prefix_t *prefix = (odph_iplookup_prefix_t

> *)key;

> >             prefix_entry_t *l1e = NULL;

> >             odp_buffer_t nexthop = *((odp_buffer_t *)value);

> >             int ret = 0;

> >

> >     +       if ((tbl == NULL) || (key == NULL) || (value == NULL))

> >     +               return -1;

> >     +

> >             if (prefix->cidr == 0)

> >                     return -1;

> >             prefix->ip = prefix->ip & (0xffffffff << (IP_LENGTH -

> >     prefix->cidr));

> >     @@ -704,18 +703,18 @@ odph_iplookup_table_put_value(odph_table_t

> >     tbl, void *key, void *value)

> >             return ret;

> >      }

> >

> >     -int

> >     -odph_iplookup_table_get_value(

> >     -               odph_table_t tbl, void *key, void *buffer, uint32_t

> >     buffer_size)

> >     +int odph_iplookup_table_get_value(odph_table_t tbl, void *key,

> >     +                                 void *buffer ODP_UNUSED,

> >     +                                 uint32_t buffer_size ODP_UNUSED)

> >      {

> >     -       if ((tbl == NULL) || (key == NULL) || (buffer == NULL))

> >     -               return -EINVAL;

> >     -

> >     -       odph_iplookup_table_impl *impl = (odph_iplookup_table_impl

> >     *)tbl;

> >     +       odph_iplookup_table_impl *impl = (void *)tbl;

> >             uint32_t ip = *((uint32_t *)key);

> >             prefix_entry_t *entry = &impl->l1e[ip >> 16];

> >             odp_buffer_t *buff = (odp_buffer_t *)buffer;

> >

> >     +       if ((tbl == NULL) || (key == NULL) || (buffer == NULL))

> >     +               return -EINVAL;

> >     +

> >             if (entry == NULL) {

> >                     ODPH_DBG("failed to get L1 entry.\n");

> >                     return -1;

> >     @@ -880,15 +879,15 @@ prefix_delete_iter(

> >      int

> >      odph_iplookup_table_remove_value(odph_table_t tbl, void *key)

> >      {

> >     -       if ((tbl == NULL) || (key == NULL))

> >     -               return -EINVAL;

> >     -

> >     -       odph_iplookup_table_impl *impl = (odph_iplookup_table_impl

> >     *)tbl;

> >     +       odph_iplookup_table_impl *impl = (void *)tbl;

> >             odph_iplookup_prefix_t *prefix = (odph_iplookup_prefix_t

> *)key;

> >             uint32_t ip = prefix->ip;

> >             uint8_t cidr = prefix->cidr;

> >

> >     -       if (prefix->cidr < 0)

> >     +       if ((tbl == NULL) || (key == NULL))

> >     +               return -EINVAL;

> >     +

> >     +       if (!prefix->cidr)

> >                     return -EINVAL;

> >

> >             prefix_entry_t *entry = &impl->l1e[ip >> 16];

> >     diff --git a/helper/lineartable.c b/helper/lineartable.c

> >     index 89179014..e1a396c1 100644

> >     --- a/helper/lineartable.c

> >     +++ b/helper/lineartable.c

> >     @@ -41,9 +41,10 @@ typedef struct {

> >       */

> >

> >      odph_table_t odph_linear_table_create(const char *name, uint32_t

> >     capacity,

> >     -                                     uint32_t ODP_IGNORED, uint32_t

> >     value_size)

> >     +                                     uint32_t un ODPH_UNUSED,

> >     +                                     uint32_t value_size)

> >      {

> >     -       int idx;

> >     +       uint32_t idx;

> >             uint32_t node_num;

> >             odp_shm_t shmem;

> >             odph_linear_table_imp *tbl;

> >     @@ -90,8 +91,10 @@ odph_table_t odph_linear_table_create(const char

> >     *name, uint32_t capacity,

> >

> >             /* initialize rwlock*/

> >             for (idx = 0; idx < tbl->node_sum; idx++) {

> >     -               odp_rwlock_t *lock = (odp_rwlock_t *)((char

> >     *)tbl->value_array

> >     -                               + idx * tbl->value_size);

> >     +               odp_rwlock_t *lock;

> >     +

> >     +               lock = (odp_rwlock_t *)(void *)((char

> *)tbl->value_array

> >     +                      + idx * tbl->value_size);

> >                     odp_rwlock_init(lock);

> >             }

> >

> >     @@ -106,7 +109,7 @@ int odph_linear_table_destroy(odph_table_t

> table)

> >             odph_linear_table_imp *linear_tbl = NULL;

> >

> >             if (table != NULL) {

> >     -               linear_tbl = (odph_linear_table_imp *)table;

> >     +               linear_tbl = (odph_linear_table_imp *)(void *)table;

> >

> >                     /* check magicword, make sure the memory is used by

> >     a table */

> >                     if (linear_tbl->magicword !=

> >     ODPH_LINEAR_TABLE_MAGIC_WORD)

> >     @@ -142,9 +145,10 @@ odph_table_t odph_linear_table_lookup(const

> >     char *name)

> >      }

> >

> >      /* should make sure the input table exists and is available */

> >     -int odph_lineartable_put_value(odph_table_t table, void *key, void

> >     *value)

> >     +static int odph_lineartable_put_value(odph_table_t table,

> >     +                                     void *key, void *value)

> >      {

> >     -       odph_linear_table_imp *tbl = (odph_linear_table_imp *)table;

> >     +       odph_linear_table_imp *tbl;

> >             uint32_t ikey = 0;

> >             void *entry = NULL;

> >             odp_rwlock_t *lock = NULL;

> >     @@ -152,6 +156,7 @@ int odph_lineartable_put_value(odph_table_t

> >     table, void *key, void *value)

> >             if (table == NULL || key == NULL || value == NULL)

> >                     return ODPH_FAIL;

> >

> >     +       tbl = (odph_linear_table_imp *)(void *)table;

> >             ikey = *(uint32_t *)key;

> >             if (ikey >= tbl->node_sum)

> >                     return ODPH_FAIL;

> >     @@ -170,10 +175,11 @@ int odph_lineartable_put_value(odph_table_t

> >     table, void *key, void *value)

> >      }

> >

> >      /* should make sure the input table exists and is available */

> >     -int odph_lineartable_get_value(odph_table_t table, void *key, void

> >     *buffer,

> >     -                              uint32_t buffer_size)

> >     +static int odph_lineartable_get_value(odph_table_t table,

> >     +                                     void *key, void *buffer,

> >     +                                     uint32_t buffer_size

> ODPH_UNUSED)

> >      {

> >     -       odph_linear_table_imp *tbl = (odph_linear_table_imp *)table;

> >     +       odph_linear_table_imp *tbl;

> >             uint32_t ikey = 0;

> >             void *entry = NULL;

> >             odp_rwlock_t *lock = NULL;

> >     @@ -181,6 +187,7 @@ int odph_lineartable_get_value(odph_table_t

> >     table, void *key, void *buffer,

> >             if (table == NULL || key == NULL || buffer == NULL)

> >                     return ODPH_FAIL;

> >

> >     +       tbl = (odph_linear_table_imp *)(void *)table;

> >             ikey = *(uint32_t *)key;

> >             if (ikey >= tbl->node_sum)

> >                     return ODPH_FAIL;

> >     diff --git a/helper/threads.c b/helper/threads.c

> >     index fe5d2bde..cb747e5b 100644

> >     --- a/helper/threads.c

> >     +++ b/helper/threads.c

> >     @@ -419,7 +419,7 @@ int odph_parse_options(int argc, char *argv[],

> >                     {0, 0, 0, 0}

> >                     };

> >

> >     -       static char *helper_short_options = "";

> >     +       static const char *helper_short_options = "";

> >

> >             /* defaults: */

> >             helper_options.proc = false;

> >     --

> >     2.11.0.295.gd7dffce

> >

> >

> >

> >

> > --

> > Mike Holmes

> > Program Manager - Linaro Networking Group

> > Linaro.org <http://www.linaro.org/>* **│ *Open source software for ARM

> SoCs

> > "Work should be fun and collaborative, the rest follows"

> >

> > __

> >

> >

>

>



-- 
Mike Holmes
Program Manager - Linaro Networking Group
Linaro.org <http://www.linaro.org/> *│ *Open source software for ARM SoCs
"Work should be fun and collaborative, the rest follows"
Maxim Uvarov Jan. 27, 2017, 6:40 p.m. UTC | #4
Merged,
Maxim.

On 01/27/17 18:47, Mike Holmes wrote:
> 

> 

> On 27 January 2017 at 10:43, Maxim Uvarov <maxim.uvarov@linaro.org

> <mailto:maxim.uvarov@linaro.org>> wrote:

> 

>     On 01/27/17 18:40, Mike Holmes wrote:

>     > One nit below on formatting.

>     >

>     > On 27 January 2017 at 10:19, Maxim Uvarov <maxim.uvarov@linaro.org <mailto:maxim.uvarov@linaro.org>

>     > <mailto:maxim.uvarov@linaro.org <mailto:maxim.uvarov@linaro.org>>> wrote:

>     >

>     >     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 <mailto:maxim.uvarov@linaro.org>

>     >     <mailto:maxim.uvarov@linaro.org <mailto:maxim.uvarov@linaro.org>>>

>     >

>     >

>     > Reviewed-by: Mike Holmes <mike.holmes@linaro.org

>     <mailto:mike.holmes@linaro.org>

>     > <mailto:mike.holmes@linaro.org <mailto:mike.holmes@linaro.org>>>

> 

>     for both patches?

> 

>  

> sorry yes

>  

> 

>     can I merge lines on apply?

> 

> 

> yes

>  

> 

> 

> 

>     >

>     >

>     >     ---

>     >      v3: fix gcc compilation

>     >      v2: rebase

>     >

>     >      helper/chksum.c        |  4 ++--

>     >      helper/cuckootable.c   | 49

>     >     ++++++++++++++++++++-----------------------------

>     >      helper/hashtable.c     | 42

>     ++++++++++++++++++++++++++----------------

>     >      helper/iplookuptable.c | 49

>     >     ++++++++++++++++++++++++-------------------------

>     >      helper/lineartable.c   | 27 +++++++++++++++++----------

>     >      helper/threads.c       |  2 +-

>     >      6 files changed, 90 insertions(+), 83 deletions(-)

>     >

>     >     diff --git a/helper/chksum.c b/helper/chksum.c

>     >     index b7eef67e..f740618d 100644

>     >     --- a/helper/chksum.c

>     >     +++ b/helper/chksum.c

>     >     @@ -49,7 +49,7 @@ static uint32_t data_seg_sum(uint8_t 

>      *data8_ptr,

>     >                     data_len--;

>     >             }

>     >

>     >     -       data16_ptr = (uint16_t *)data8_ptr;

>     >     +       data16_ptr = (uint16_t *)(void *)data8_ptr;

>     >

>     >             /* The following code tries to gain a modest performance

>     >     enhancement by

>     >              * unrolling the normal 16 bits at a time loop eight

>     times.

>     >     Even

>     >     @@ -216,7 +216,7 @@ static inline int

>     >     odph_process_l3_hdr(odp_packet_t odp_pkt,

>     >                             ipv6_hdr_ptr = &ipv6_hdr;

>     >                     }

>     >

>     >     -               addrs_ptr        = (uint16_t

>     *)&ipv6_hdr_ptr->src_addr;

>     >     +               addrs_ptr        = (uint16_t *)(void

>     >     *)&ipv6_hdr_ptr->src_addr;

>     >                     addrs_len        = 2 * ODPH_IPV6ADDR_LEN;

>     >                     protocol         = ipv6_hdr_ptr->next_hdr;

>     >                     ipv6_payload_len =

>     >     odp_be_to_cpu_16(ipv6_hdr_ptr->payload_len);

>     >     diff --git a/helper/cuckootable.c b/helper/cuckootable.c

>     >     index 83647ec2..396e7f53 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,7 +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 *)(

>     >     +       tbl->buckets = (void *)(

>     >                             (char *)tbl + impl_size);

>     >

>     >

>     > Can't this all fit on one line ?

>     >

>     >

>     >

>     >             /* initialize key-value buffer pool */

>     >     @@ -309,17 +297,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 +567,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 +643,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 +725,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;

>     >

>     >     diff --git a/helper/hashtable.c b/helper/hashtable.c

>     >     index 983b3da9..1c2b8523 100644

>     >     --- a/helper/hashtable.c

>     >     +++ b/helper/hashtable.c

>     >     @@ -101,9 +101,9 @@ odph_table_t odph_hash_table_create(const char

>     >     *name, uint32_t capacity,

>     >              * the last part is the element node pool

>     >              */

>     >

>     >     -       tbl->lock_pool = (odp_rwlock_t *)((char *)tbl

>     >     +       tbl->lock_pool = (odp_rwlock_t *)(void *)((char *)tbl

>     >                             + sizeof(odph_hash_table_imp));

>     >     -       tbl->list_head_pool = (odph_list_head *)((char

>     *)tbl->lock_pool

>     >     +       tbl->list_head_pool = (odph_list_head *)(void *)((char

>     >     *)tbl->lock_pool

>     >                             + ODPH_MAX_BUCKET_NUM *

>     sizeof(odp_rwlock_t));

>     >

>     >             node_mem = tbl->init_cap - sizeof(odph_hash_table_imp)

>     >     @@ -112,8 +112,9 @@ odph_table_t odph_hash_table_create(const char

>     >     *name, uint32_t capacity,

>     >

>     >             node_num = node_mem / (sizeof(odph_hash_node) + key_size +

>     >     value_size);

>     >             tbl->hash_node_num = node_num;

>     >     -       tbl->hash_node_pool = (odph_hash_node *)((char

>     >     *)tbl->list_head_pool

>     >     -                               + ODPH_MAX_BUCKET_NUM *

>     >     sizeof(odph_list_head));

>     >     +       tbl->hash_node_pool =

>     >     +               (odph_hash_node *)(void *)((char

>     *)tbl->list_head_pool

>     >     +               + ODPH_MAX_BUCKET_NUM * sizeof(odph_list_head));

>     >

>     >             /* init every list head and rw lock */

>     >             for (i = 0; i < ODPH_MAX_BUCKET_NUM; i++) {

>     >     @@ -130,8 +131,9 @@ int odph_hash_table_destroy(odph_table_t

>     table)

>     >             int ret;

>     >

>     >             if (table != NULL) {

>     >     -               odph_hash_table_imp *hash_tbl =

>     (odph_hash_table_imp

>     >     *)table;

>     >     +               odph_hash_table_imp *hash_tbl;

>     >

>     >     +               hash_tbl = (odph_hash_table_imp *)(void *)table;

>     >                     if (hash_tbl->magicword !=

>     ODPH_HASH_TABLE_MAGIC_WORD)

>     >                             return ODPH_FAIL;

>     >

>     >     @@ -164,7 +166,7 @@ odph_table_t odph_hash_table_lookup(const char

>     >     *name)

>     >       * This hash algorithm is the most simple one, so we choose it as

>     >     an DEMO

>     >       * User can use any other algorithm, like CRC...

>     >       */

>     >     -uint16_t odp_key_hash(void *key, uint32_t key_size)

>     >     +static uint16_t odp_key_hash(void *key, uint32_t key_size)

>     >      {

>     >             register uint32_t hash = 0;

>     >             uint32_t idx = (key_size == 0 ? 1 : key_size);

>     >     @@ -181,18 +183,19 @@ uint16_t odp_key_hash(void *key, uint32_t

>     >     key_size)

>     >      /**

>     >       * Get an available node from pool

>     >       */

>     >     -odph_hash_node *odp_hashnode_take(odph_table_t table)

>     >     +static odph_hash_node *hashnode_take(odph_table_t table)

>     >      {

>     >     -       odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;

>     >     +       odph_hash_table_imp *tbl;

>     >             uint32_t idx;

>     >             odph_hash_node *node;

>     >

>     >     +       tbl = (odph_hash_table_imp *)(void *)table;

>     >             for (idx = 0; idx < tbl->hash_node_num; idx++) {

>     >                     /** notice: memory of one hash_node is

>     >                      * not only sizeof(odph_hash_node)

>     >                      * should add the size of Flexible Array

>     >                      */

>     >     -               node = (odph_hash_node *)((char

>     *)tbl->hash_node_pool

>     >     +               node = (odph_hash_node *)(void *)((char

>     >     *)tbl->hash_node_pool

>     >                                     + idx * (sizeof(odph_hash_node)

>     >                                                     + tbl->key_size

>     >                                                     +

>     tbl->value_size));

>     >     @@ -208,13 +211,15 @@ odph_hash_node

>     *odp_hashnode_take(odph_table_t

>     >     table)

>     >      /**

>     >       * Release an node to the pool

>     >       */

>     >     -void odp_hashnode_give(odph_table_t table, odph_hash_node *node)

>     >     +static void hashnode_give(odph_table_t table, odph_hash_node

>     *node)

>     >      {

>     >     -       odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;

>     >     +       odph_hash_table_imp *tbl;

>     >

>     >             if (node == NULL)

>     >                     return;

>     >

>     >     +       tbl = (odph_hash_table_imp *)(void *)table;

>     >     +

>     >             odph_list_del(&node->list_node);

>     >             memset(node, 0,

>     >                    (sizeof(odph_hash_node) + tbl->key_size +

>     >     tbl->value_size));

>     >     @@ -223,7 +228,7 @@ void odp_hashnode_give(odph_table_t table,

>     >     odph_hash_node *node)

>     >      /* should make sure the input table exists and is available */

>     >      int odph_hash_put_value(odph_table_t table, void *key, void

>     *value)

>     >      {

>     >     -       odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;

>     >     +       odph_hash_table_imp *tbl;

>     >             uint16_t hash = 0;

>     >             odph_hash_node *node = NULL;

>     >             char *tmp = NULL;

>     >     @@ -231,6 +236,7 @@ int odph_hash_put_value(odph_table_t

>     table, void

>     >     *key, void *value)

>     >             if (table == NULL || key == NULL || value == NULL)

>     >                     return ODPH_FAIL;

>     >

>     >     +       tbl = (odph_hash_table_imp *)(void *)table;

>     >             /* hash value is just the index of the list head in

>     pool */

>     >             hash = odp_key_hash(key, tbl->key_size);

>     >

>     >     @@ -249,7 +255,7 @@ int odph_hash_put_value(odph_table_t

>     table, void

>     >     *key, void *value)

>     >             }

>     >

>     >             /*if the key is a new one, get a new hash node form

>     the pool */

>     >     -       node = odp_hashnode_take(table);

>     >     +       node = hashnode_take(table);

>     >             if (node == NULL) {

>     >                     odp_rwlock_write_unlock(&tbl->lock_pool[hash]);

>     >                     return ODPH_FAIL;

>     >     @@ -271,11 +277,13 @@ int odph_hash_put_value(odph_table_t table,

>     >     void *key, void *value)

>     >      int odph_hash_get_value(odph_table_t table, void *key, void

>     *buffer,

>     >                             uint32_t buffer_size)

>     >      {

>     >     -       odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;

>     >     +       odph_hash_table_imp *tbl;

>     >             uint16_t hash = 0;

>     >             odph_hash_node *node;

>     >             char *tmp = NULL;

>     >

>     >     +       tbl = (odph_hash_table_imp *)(void *)table;

>     >     +

>     >             if (table == NULL || key == NULL || buffer == NULL ||

>     >                 buffer_size < tbl->value_size)

>     >                     return ODPH_FAIL;

>     >     @@ -308,13 +316,15 @@ int odph_hash_get_value(odph_table_t table,

>     >     void *key, void *buffer,

>     >      /* should make sure the input table exists and is available */

>     >      int odph_hash_remove_value(odph_table_t table, void *key)

>     >      {

>     >     -       odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;

>     >     +       odph_hash_table_imp *tbl;

>     >             uint16_t hash = 0;

>     >             odph_hash_node *node;

>     >

>     >             if (table == NULL || key == NULL)

>     >                     return ODPH_FAIL;

>     >

>     >     +       tbl = (odph_hash_table_imp *)(void *)table;

>     >     +

>     >             /* hash value is just the index of the list head in

>     pool */

>     >             hash = odp_key_hash(key, tbl->key_size);

>     >

>     >     @@ -324,7 +334,7 @@ int odph_hash_remove_value(odph_table_t table,

>     >     void *key)

>     >                                list_node)

>     >             {

>     >                     if (memcmp(node->content, key, tbl->key_size)

>     == 0) {

>     >     -                       odp_hashnode_give(table, node);

>     >     +                       hashnode_give(table, node);

>     >                           

>      odp_rwlock_write_unlock(&tbl->lock_pool[hash]);

>     >                             return ODPH_SUCCESS;

>     >                     }

>     >     diff --git a/helper/iplookuptable.c b/helper/iplookuptable.c

>     >     index f6d6f880..aaebea33 100644

>     >     --- a/helper/iplookuptable.c

>     >     +++ b/helper/iplookuptable.c

>     >     @@ -60,7 +60,7 @@ typedef struct {

>     >      } prefix_entry_t;

>     >

>     >      #define ENTRY_SIZE (sizeof(prefix_entry_t) +

>     sizeof(odp_buffer_t))

>     >     -#define ENTRY_BUFF_ARR(x) ((odp_buffer_t *)((char *)x \

>     >     +#define ENTRY_BUFF_ARR(x) ((odp_buffer_t *)(void *)((char *)x \

>     >                             + sizeof(prefix_entry_t) *

>     ENTRY_NUM_SUBTREE))

>     >

>     >      /** @internal trie node struct

>     >     @@ -434,16 +434,15 @@ odph_iplookup_table_lookup(const char *name)

>     >             return NULL;

>     >      }

>     >

>     >     -odph_table_t

>     >     -odph_iplookup_table_create(

>     >     -               const char *name, uint32_t ODP_IGNORED_1,

>     >     -               uint32_t ODP_IGNORED_2, uint32_t value_size)

>     >     +odph_table_t odph_iplookup_table_create(const char *name,

>     >     +                                       uint32_t p1 ODP_UNUSED,

>     >     +                                       uint32_t p2 ODP_UNUSED,

>     >     +                                       uint32_t value_size)

>     >      {

>     >             odph_iplookup_table_impl *tbl;

>     >             odp_shm_t shm_tbl;

>     >             odp_queue_t queue;

>     >             odp_queue_param_t qparam;

>     >     -

>     >             unsigned i;

>     >             uint32_t impl_size, l1_size;

>     >             char queue_name[ODPH_TABLE_NAME_LEN + 2];

>     >     @@ -455,7 +454,7 @@ odph_iplookup_table_create(

>     >             }

>     >

>     >             /* Guarantee there's no existing */

>     >     -       tbl = (odph_iplookup_table_impl

>     >     *)odph_iplookup_table_lookup(name);

>     >     +       tbl = (void *)odph_iplookup_table_lookup(name);

>     >             if (tbl != NULL) {

>     >                     ODPH_DBG("IP prefix table %s already

>     exists\n", name);

>     >                     return NULL;

>     >     @@ -482,7 +481,7 @@ odph_iplookup_table_create(

>     >             /* header of this mem block is the table impl struct,

>     >              * then the l1 entries array.

>     >              */

>     >     -       tbl->l1e = (prefix_entry_t *)((char *)tbl + impl_size);

>     >     +       tbl->l1e = (prefix_entry_t *)(void *)((char *)tbl +

>     impl_size);

>     >             for (i = 0; i < ENTRY_NUM_L1; i++)

>     >                     tbl->l1e[i].nexthop = ODP_BUFFER_INVALID;

>     >

>     >     @@ -528,7 +527,7 @@ odph_iplookup_table_destroy(odph_table_t tbl)

>     >             if (tbl == NULL)

>     >                     return -1;

>     >

>     >     -       impl = (odph_iplookup_table_impl *)tbl;

>     >     +       impl = (odph_iplookup_table_impl *)(void *)tbl;

>     >

>     >             /* check magic word */

>     >             if (impl->magicword != ODPH_IP_LOOKUP_TABLE_MAGIC_WORD) {

>     >     @@ -664,15 +663,15 @@ prefix_insert_iter(

>     >      int

>     >      odph_iplookup_table_put_value(odph_table_t tbl, void *key,

>     void *value)

>     >      {

>     >     -       if ((tbl == NULL) || (key == NULL) || (value == NULL))

>     >     -               return -1;

>     >     -

>     >     -       odph_iplookup_table_impl *impl = (odph_iplookup_table_impl

>     >     *)tbl;

>     >     +       odph_iplookup_table_impl *impl = (void *)tbl;

>     >             odph_iplookup_prefix_t *prefix =

>     (odph_iplookup_prefix_t *)key;

>     >             prefix_entry_t *l1e = NULL;

>     >             odp_buffer_t nexthop = *((odp_buffer_t *)value);

>     >             int ret = 0;

>     >

>     >     +       if ((tbl == NULL) || (key == NULL) || (value == NULL))

>     >     +               return -1;

>     >     +

>     >             if (prefix->cidr == 0)

>     >                     return -1;

>     >             prefix->ip = prefix->ip & (0xffffffff << (IP_LENGTH -

>     >     prefix->cidr));

>     >     @@ -704,18 +703,18 @@ odph_iplookup_table_put_value(odph_table_t

>     >     tbl, void *key, void *value)

>     >             return ret;

>     >      }

>     >

>     >     -int

>     >     -odph_iplookup_table_get_value(

>     >     -               odph_table_t tbl, void *key, void *buffer,

>     uint32_t

>     >     buffer_size)

>     >     +int odph_iplookup_table_get_value(odph_table_t tbl, void *key,

>     >     +                                 void *buffer ODP_UNUSED,

>     >     +                                 uint32_t buffer_size ODP_UNUSED)

>     >      {

>     >     -       if ((tbl == NULL) || (key == NULL) || (buffer == NULL))

>     >     -               return -EINVAL;

>     >     -

>     >     -       odph_iplookup_table_impl *impl = (odph_iplookup_table_impl

>     >     *)tbl;

>     >     +       odph_iplookup_table_impl *impl = (void *)tbl;

>     >             uint32_t ip = *((uint32_t *)key);

>     >             prefix_entry_t *entry = &impl->l1e[ip >> 16];

>     >             odp_buffer_t *buff = (odp_buffer_t *)buffer;

>     >

>     >     +       if ((tbl == NULL) || (key == NULL) || (buffer == NULL))

>     >     +               return -EINVAL;

>     >     +

>     >             if (entry == NULL) {

>     >                     ODPH_DBG("failed to get L1 entry.\n");

>     >                     return -1;

>     >     @@ -880,15 +879,15 @@ prefix_delete_iter(

>     >      int

>     >      odph_iplookup_table_remove_value(odph_table_t tbl, void *key)

>     >      {

>     >     -       if ((tbl == NULL) || (key == NULL))

>     >     -               return -EINVAL;

>     >     -

>     >     -       odph_iplookup_table_impl *impl = (odph_iplookup_table_impl

>     >     *)tbl;

>     >     +       odph_iplookup_table_impl *impl = (void *)tbl;

>     >             odph_iplookup_prefix_t *prefix =

>     (odph_iplookup_prefix_t *)key;

>     >             uint32_t ip = prefix->ip;

>     >             uint8_t cidr = prefix->cidr;

>     >

>     >     -       if (prefix->cidr < 0)

>     >     +       if ((tbl == NULL) || (key == NULL))

>     >     +               return -EINVAL;

>     >     +

>     >     +       if (!prefix->cidr)

>     >                     return -EINVAL;

>     >

>     >             prefix_entry_t *entry = &impl->l1e[ip >> 16];

>     >     diff --git a/helper/lineartable.c b/helper/lineartable.c

>     >     index 89179014..e1a396c1 100644

>     >     --- a/helper/lineartable.c

>     >     +++ b/helper/lineartable.c

>     >     @@ -41,9 +41,10 @@ typedef struct {

>     >       */

>     >

>     >      odph_table_t odph_linear_table_create(const char *name, uint32_t

>     >     capacity,

>     >     -                                     uint32_t ODP_IGNORED,

>     uint32_t

>     >     value_size)

>     >     +                                     uint32_t un ODPH_UNUSED,

>     >     +                                     uint32_t value_size)

>     >      {

>     >     -       int idx;

>     >     +       uint32_t idx;

>     >             uint32_t node_num;

>     >             odp_shm_t shmem;

>     >             odph_linear_table_imp *tbl;

>     >     @@ -90,8 +91,10 @@ odph_table_t odph_linear_table_create(const

>     char

>     >     *name, uint32_t capacity,

>     >

>     >             /* initialize rwlock*/

>     >             for (idx = 0; idx < tbl->node_sum; idx++) {

>     >     -               odp_rwlock_t *lock = (odp_rwlock_t *)((char

>     >     *)tbl->value_array

>     >     -                               + idx * tbl->value_size);

>     >     +               odp_rwlock_t *lock;

>     >     +

>     >     +               lock = (odp_rwlock_t *)(void *)((char

>     *)tbl->value_array

>     >     +                      + idx * tbl->value_size);

>     >                     odp_rwlock_init(lock);

>     >             }

>     >

>     >     @@ -106,7 +109,7 @@ int odph_linear_table_destroy(odph_table_t

>     table)

>     >             odph_linear_table_imp *linear_tbl = NULL;

>     >

>     >             if (table != NULL) {

>     >     -               linear_tbl = (odph_linear_table_imp *)table;

>     >     +               linear_tbl = (odph_linear_table_imp *)(void

>     *)table;

>     >

>     >                     /* check magicword, make sure the memory is

>     used by

>     >     a table */

>     >                     if (linear_tbl->magicword !=

>     >     ODPH_LINEAR_TABLE_MAGIC_WORD)

>     >     @@ -142,9 +145,10 @@ odph_table_t odph_linear_table_lookup(const

>     >     char *name)

>     >      }

>     >

>     >      /* should make sure the input table exists and is available */

>     >     -int odph_lineartable_put_value(odph_table_t table, void *key,

>     void

>     >     *value)

>     >     +static int odph_lineartable_put_value(odph_table_t table,

>     >     +                                     void *key, void *value)

>     >      {

>     >     -       odph_linear_table_imp *tbl = (odph_linear_table_imp

>     *)table;

>     >     +       odph_linear_table_imp *tbl;

>     >             uint32_t ikey = 0;

>     >             void *entry = NULL;

>     >             odp_rwlock_t *lock = NULL;

>     >     @@ -152,6 +156,7 @@ int odph_lineartable_put_value(odph_table_t

>     >     table, void *key, void *value)

>     >             if (table == NULL || key == NULL || value == NULL)

>     >                     return ODPH_FAIL;

>     >

>     >     +       tbl = (odph_linear_table_imp *)(void *)table;

>     >             ikey = *(uint32_t *)key;

>     >             if (ikey >= tbl->node_sum)

>     >                     return ODPH_FAIL;

>     >     @@ -170,10 +175,11 @@ int odph_lineartable_put_value(odph_table_t

>     >     table, void *key, void *value)

>     >      }

>     >

>     >      /* should make sure the input table exists and is available */

>     >     -int odph_lineartable_get_value(odph_table_t table, void *key,

>     void

>     >     *buffer,

>     >     -                              uint32_t buffer_size)

>     >     +static int odph_lineartable_get_value(odph_table_t table,

>     >     +                                     void *key, void *buffer,

>     >     +                                     uint32_t buffer_size

>     ODPH_UNUSED)

>     >      {

>     >     -       odph_linear_table_imp *tbl = (odph_linear_table_imp

>     *)table;

>     >     +       odph_linear_table_imp *tbl;

>     >             uint32_t ikey = 0;

>     >             void *entry = NULL;

>     >             odp_rwlock_t *lock = NULL;

>     >     @@ -181,6 +187,7 @@ int odph_lineartable_get_value(odph_table_t

>     >     table, void *key, void *buffer,

>     >             if (table == NULL || key == NULL || buffer == NULL)

>     >                     return ODPH_FAIL;

>     >

>     >     +       tbl = (odph_linear_table_imp *)(void *)table;

>     >             ikey = *(uint32_t *)key;

>     >             if (ikey >= tbl->node_sum)

>     >                     return ODPH_FAIL;

>     >     diff --git a/helper/threads.c b/helper/threads.c

>     >     index fe5d2bde..cb747e5b 100644

>     >     --- a/helper/threads.c

>     >     +++ b/helper/threads.c

>     >     @@ -419,7 +419,7 @@ int odph_parse_options(int argc, char *argv[],

>     >                     {0, 0, 0, 0}

>     >                     };

>     >

>     >     -       static char *helper_short_options = "";

>     >     +       static const char *helper_short_options = "";

>     >

>     >             /* defaults: */

>     >             helper_options.proc = false;

>     >     --

>     >     2.11.0.295.gd7dffce

>     >

>     >

>     >

>     >

>     > --

>     > Mike Holmes

>     > Program Manager - Linaro Networking Group

>     > Linaro.org <http://www.linaro.org/>* **│ *Open source software for

>     ARM SoCs

>     > "Work should be fun and collaborative, the rest follows"

>     >

>     > __

>     >

>     >

> 

> 

> 

> 

> -- 

> Mike Holmes

> Program Manager - Linaro Networking Group

> Linaro.org <http://www.linaro.org/>* **│ *Open source software for ARM SoCs

> "Work should be fun and collaborative, the rest follows"

> 

> __

> 

>
diff mbox series

Patch

diff --git a/helper/chksum.c b/helper/chksum.c
index b7eef67e..f740618d 100644
--- a/helper/chksum.c
+++ b/helper/chksum.c
@@ -49,7 +49,7 @@  static uint32_t data_seg_sum(uint8_t   *data8_ptr,
 		data_len--;
 	}
 
-	data16_ptr = (uint16_t *)data8_ptr;
+	data16_ptr = (uint16_t *)(void *)data8_ptr;
 
 	/* The following code tries to gain a modest performance enhancement by
 	 * unrolling the normal 16 bits at a time loop eight times.  Even
@@ -216,7 +216,7 @@  static inline int odph_process_l3_hdr(odp_packet_t odp_pkt,
 			ipv6_hdr_ptr = &ipv6_hdr;
 		}
 
-		addrs_ptr        = (uint16_t *)&ipv6_hdr_ptr->src_addr;
+		addrs_ptr        = (uint16_t *)(void *)&ipv6_hdr_ptr->src_addr;
 		addrs_len        = 2 * ODPH_IPV6ADDR_LEN;
 		protocol         = ipv6_hdr_ptr->next_hdr;
 		ipv6_payload_len = odp_be_to_cpu_16(ipv6_hdr_ptr->payload_len);
diff --git a/helper/cuckootable.c b/helper/cuckootable.c
index 83647ec2..396e7f53 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,7 +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 *)(
+	tbl->buckets = (void *)(
 			(char *)tbl + impl_size);
 
 	/* initialize key-value buffer pool */
@@ -309,17 +297,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 +567,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 +643,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 +725,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;
 
diff --git a/helper/hashtable.c b/helper/hashtable.c
index 983b3da9..1c2b8523 100644
--- a/helper/hashtable.c
+++ b/helper/hashtable.c
@@ -101,9 +101,9 @@  odph_table_t odph_hash_table_create(const char *name, uint32_t capacity,
 	 * the last part is the element node pool
 	 */
 
-	tbl->lock_pool = (odp_rwlock_t *)((char *)tbl
+	tbl->lock_pool = (odp_rwlock_t *)(void *)((char *)tbl
 			+ sizeof(odph_hash_table_imp));
-	tbl->list_head_pool = (odph_list_head *)((char *)tbl->lock_pool
+	tbl->list_head_pool = (odph_list_head *)(void *)((char *)tbl->lock_pool
 			+ ODPH_MAX_BUCKET_NUM * sizeof(odp_rwlock_t));
 
 	node_mem = tbl->init_cap - sizeof(odph_hash_table_imp)
@@ -112,8 +112,9 @@  odph_table_t odph_hash_table_create(const char *name, uint32_t capacity,
 
 	node_num = node_mem / (sizeof(odph_hash_node) + key_size + value_size);
 	tbl->hash_node_num = node_num;
-	tbl->hash_node_pool = (odph_hash_node *)((char *)tbl->list_head_pool
-				+ ODPH_MAX_BUCKET_NUM * sizeof(odph_list_head));
+	tbl->hash_node_pool =
+		(odph_hash_node *)(void *)((char *)tbl->list_head_pool
+		+ ODPH_MAX_BUCKET_NUM * sizeof(odph_list_head));
 
 	/* init every list head and rw lock */
 	for (i = 0; i < ODPH_MAX_BUCKET_NUM; i++) {
@@ -130,8 +131,9 @@  int odph_hash_table_destroy(odph_table_t table)
 	int ret;
 
 	if (table != NULL) {
-		odph_hash_table_imp *hash_tbl = (odph_hash_table_imp *)table;
+		odph_hash_table_imp *hash_tbl;
 
+		hash_tbl = (odph_hash_table_imp *)(void *)table;
 		if (hash_tbl->magicword != ODPH_HASH_TABLE_MAGIC_WORD)
 			return ODPH_FAIL;
 
@@ -164,7 +166,7 @@  odph_table_t odph_hash_table_lookup(const char *name)
  * This hash algorithm is the most simple one, so we choose it as an DEMO
  * User can use any other algorithm, like CRC...
  */
-uint16_t odp_key_hash(void *key, uint32_t key_size)
+static uint16_t odp_key_hash(void *key, uint32_t key_size)
 {
 	register uint32_t hash = 0;
 	uint32_t idx = (key_size == 0 ? 1 : key_size);
@@ -181,18 +183,19 @@  uint16_t odp_key_hash(void *key, uint32_t key_size)
 /**
  * Get an available node from pool
  */
-odph_hash_node *odp_hashnode_take(odph_table_t table)
+static odph_hash_node *hashnode_take(odph_table_t table)
 {
-	odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;
+	odph_hash_table_imp *tbl;
 	uint32_t idx;
 	odph_hash_node *node;
 
+	tbl = (odph_hash_table_imp *)(void *)table;
 	for (idx = 0; idx < tbl->hash_node_num; idx++) {
 		/** notice: memory of one hash_node is
 		 * not only sizeof(odph_hash_node)
 		 * should add the size of Flexible Array
 		 */
-		node = (odph_hash_node *)((char *)tbl->hash_node_pool
+		node = (odph_hash_node *)(void *)((char *)tbl->hash_node_pool
 				+ idx * (sizeof(odph_hash_node)
 						+ tbl->key_size
 						+ tbl->value_size));
@@ -208,13 +211,15 @@  odph_hash_node *odp_hashnode_take(odph_table_t table)
 /**
  * Release an node to the pool
  */
-void odp_hashnode_give(odph_table_t table, odph_hash_node *node)
+static void hashnode_give(odph_table_t table, odph_hash_node *node)
 {
-	odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;
+	odph_hash_table_imp *tbl;
 
 	if (node == NULL)
 		return;
 
+	tbl = (odph_hash_table_imp *)(void *)table;
+
 	odph_list_del(&node->list_node);
 	memset(node, 0,
 	       (sizeof(odph_hash_node) + tbl->key_size + tbl->value_size));
@@ -223,7 +228,7 @@  void odp_hashnode_give(odph_table_t table, odph_hash_node *node)
 /* should make sure the input table exists and is available */
 int odph_hash_put_value(odph_table_t table, void *key, void *value)
 {
-	odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;
+	odph_hash_table_imp *tbl;
 	uint16_t hash = 0;
 	odph_hash_node *node = NULL;
 	char *tmp = NULL;
@@ -231,6 +236,7 @@  int odph_hash_put_value(odph_table_t table, void *key, void *value)
 	if (table == NULL || key == NULL || value == NULL)
 		return ODPH_FAIL;
 
+	tbl = (odph_hash_table_imp *)(void *)table;
 	/* hash value is just the index of the list head in pool */
 	hash = odp_key_hash(key, tbl->key_size);
 
@@ -249,7 +255,7 @@  int odph_hash_put_value(odph_table_t table, void *key, void *value)
 	}
 
 	/*if the key is a new one, get a new hash node form the pool */
-	node = odp_hashnode_take(table);
+	node = hashnode_take(table);
 	if (node == NULL) {
 		odp_rwlock_write_unlock(&tbl->lock_pool[hash]);
 		return ODPH_FAIL;
@@ -271,11 +277,13 @@  int odph_hash_put_value(odph_table_t table, void *key, void *value)
 int odph_hash_get_value(odph_table_t table, void *key, void *buffer,
 			uint32_t buffer_size)
 {
-	odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;
+	odph_hash_table_imp *tbl;
 	uint16_t hash = 0;
 	odph_hash_node *node;
 	char *tmp = NULL;
 
+	tbl = (odph_hash_table_imp *)(void *)table;
+
 	if (table == NULL || key == NULL || buffer == NULL ||
 	    buffer_size < tbl->value_size)
 		return ODPH_FAIL;
@@ -308,13 +316,15 @@  int odph_hash_get_value(odph_table_t table, void *key, void *buffer,
 /* should make sure the input table exists and is available */
 int odph_hash_remove_value(odph_table_t table, void *key)
 {
-	odph_hash_table_imp *tbl = (odph_hash_table_imp *)table;
+	odph_hash_table_imp *tbl;
 	uint16_t hash = 0;
 	odph_hash_node *node;
 
 	if (table == NULL || key == NULL)
 		return ODPH_FAIL;
 
+	tbl = (odph_hash_table_imp *)(void *)table;
+
 	/* hash value is just the index of the list head in pool */
 	hash = odp_key_hash(key, tbl->key_size);
 
@@ -324,7 +334,7 @@  int odph_hash_remove_value(odph_table_t table, void *key)
 			   list_node)
 	{
 		if (memcmp(node->content, key, tbl->key_size) == 0) {
-			odp_hashnode_give(table, node);
+			hashnode_give(table, node);
 			odp_rwlock_write_unlock(&tbl->lock_pool[hash]);
 			return ODPH_SUCCESS;
 		}
diff --git a/helper/iplookuptable.c b/helper/iplookuptable.c
index f6d6f880..aaebea33 100644
--- a/helper/iplookuptable.c
+++ b/helper/iplookuptable.c
@@ -60,7 +60,7 @@  typedef struct {
 } prefix_entry_t;
 
 #define ENTRY_SIZE (sizeof(prefix_entry_t) + sizeof(odp_buffer_t))
-#define ENTRY_BUFF_ARR(x) ((odp_buffer_t *)((char *)x \
+#define ENTRY_BUFF_ARR(x) ((odp_buffer_t *)(void *)((char *)x \
 			+ sizeof(prefix_entry_t) * ENTRY_NUM_SUBTREE))
 
 /** @internal trie node struct
@@ -434,16 +434,15 @@  odph_iplookup_table_lookup(const char *name)
 	return NULL;
 }
 
-odph_table_t
-odph_iplookup_table_create(
-		const char *name, uint32_t ODP_IGNORED_1,
-		uint32_t ODP_IGNORED_2, uint32_t value_size)
+odph_table_t odph_iplookup_table_create(const char *name,
+					uint32_t p1 ODP_UNUSED,
+					uint32_t p2 ODP_UNUSED,
+					uint32_t value_size)
 {
 	odph_iplookup_table_impl *tbl;
 	odp_shm_t shm_tbl;
 	odp_queue_t queue;
 	odp_queue_param_t qparam;
-
 	unsigned i;
 	uint32_t impl_size, l1_size;
 	char queue_name[ODPH_TABLE_NAME_LEN + 2];
@@ -455,7 +454,7 @@  odph_iplookup_table_create(
 	}
 
 	/* Guarantee there's no existing */
-	tbl = (odph_iplookup_table_impl *)odph_iplookup_table_lookup(name);
+	tbl = (void *)odph_iplookup_table_lookup(name);
 	if (tbl != NULL) {
 		ODPH_DBG("IP prefix table %s already exists\n", name);
 		return NULL;
@@ -482,7 +481,7 @@  odph_iplookup_table_create(
 	/* header of this mem block is the table impl struct,
 	 * then the l1 entries array.
 	 */
-	tbl->l1e = (prefix_entry_t *)((char *)tbl + impl_size);
+	tbl->l1e = (prefix_entry_t *)(void *)((char *)tbl + impl_size);
 	for (i = 0; i < ENTRY_NUM_L1; i++)
 		tbl->l1e[i].nexthop = ODP_BUFFER_INVALID;
 
@@ -528,7 +527,7 @@  odph_iplookup_table_destroy(odph_table_t tbl)
 	if (tbl == NULL)
 		return -1;
 
-	impl = (odph_iplookup_table_impl *)tbl;
+	impl = (odph_iplookup_table_impl *)(void *)tbl;
 
 	/* check magic word */
 	if (impl->magicword != ODPH_IP_LOOKUP_TABLE_MAGIC_WORD) {
@@ -664,15 +663,15 @@  prefix_insert_iter(
 int
 odph_iplookup_table_put_value(odph_table_t tbl, void *key, void *value)
 {
-	if ((tbl == NULL) || (key == NULL) || (value == NULL))
-		return -1;
-
-	odph_iplookup_table_impl *impl = (odph_iplookup_table_impl *)tbl;
+	odph_iplookup_table_impl *impl = (void *)tbl;
 	odph_iplookup_prefix_t *prefix = (odph_iplookup_prefix_t *)key;
 	prefix_entry_t *l1e = NULL;
 	odp_buffer_t nexthop = *((odp_buffer_t *)value);
 	int ret = 0;
 
+	if ((tbl == NULL) || (key == NULL) || (value == NULL))
+		return -1;
+
 	if (prefix->cidr == 0)
 		return -1;
 	prefix->ip = prefix->ip & (0xffffffff << (IP_LENGTH - prefix->cidr));
@@ -704,18 +703,18 @@  odph_iplookup_table_put_value(odph_table_t tbl, void *key, void *value)
 	return ret;
 }
 
-int
-odph_iplookup_table_get_value(
-		odph_table_t tbl, void *key, void *buffer, uint32_t buffer_size)
+int odph_iplookup_table_get_value(odph_table_t tbl, void *key,
+				  void *buffer ODP_UNUSED,
+				  uint32_t buffer_size ODP_UNUSED)
 {
-	if ((tbl == NULL) || (key == NULL) || (buffer == NULL))
-		return -EINVAL;
-
-	odph_iplookup_table_impl *impl = (odph_iplookup_table_impl *)tbl;
+	odph_iplookup_table_impl *impl = (void *)tbl;
 	uint32_t ip = *((uint32_t *)key);
 	prefix_entry_t *entry = &impl->l1e[ip >> 16];
 	odp_buffer_t *buff = (odp_buffer_t *)buffer;
 
+	if ((tbl == NULL) || (key == NULL) || (buffer == NULL))
+		return -EINVAL;
+
 	if (entry == NULL) {
 		ODPH_DBG("failed to get L1 entry.\n");
 		return -1;
@@ -880,15 +879,15 @@  prefix_delete_iter(
 int
 odph_iplookup_table_remove_value(odph_table_t tbl, void *key)
 {
-	if ((tbl == NULL) || (key == NULL))
-		return -EINVAL;
-
-	odph_iplookup_table_impl *impl = (odph_iplookup_table_impl *)tbl;
+	odph_iplookup_table_impl *impl = (void *)tbl;
 	odph_iplookup_prefix_t *prefix = (odph_iplookup_prefix_t *)key;
 	uint32_t ip = prefix->ip;
 	uint8_t cidr = prefix->cidr;
 
-	if (prefix->cidr < 0)
+	if ((tbl == NULL) || (key == NULL))
+		return -EINVAL;
+
+	if (!prefix->cidr)
 		return -EINVAL;
 
 	prefix_entry_t *entry = &impl->l1e[ip >> 16];
diff --git a/helper/lineartable.c b/helper/lineartable.c
index 89179014..e1a396c1 100644
--- a/helper/lineartable.c
+++ b/helper/lineartable.c
@@ -41,9 +41,10 @@  typedef struct {
  */
 
 odph_table_t odph_linear_table_create(const char *name, uint32_t capacity,
-				      uint32_t ODP_IGNORED, uint32_t value_size)
+				      uint32_t un ODPH_UNUSED,
+				      uint32_t value_size)
 {
-	int idx;
+	uint32_t idx;
 	uint32_t node_num;
 	odp_shm_t shmem;
 	odph_linear_table_imp *tbl;
@@ -90,8 +91,10 @@  odph_table_t odph_linear_table_create(const char *name, uint32_t capacity,
 
 	/* initialize rwlock*/
 	for (idx = 0; idx < tbl->node_sum; idx++) {
-		odp_rwlock_t *lock = (odp_rwlock_t *)((char *)tbl->value_array
-				+ idx * tbl->value_size);
+		odp_rwlock_t *lock;
+
+		lock = (odp_rwlock_t *)(void *)((char *)tbl->value_array
+		       + idx * tbl->value_size);
 		odp_rwlock_init(lock);
 	}
 
@@ -106,7 +109,7 @@  int odph_linear_table_destroy(odph_table_t table)
 	odph_linear_table_imp *linear_tbl = NULL;
 
 	if (table != NULL) {
-		linear_tbl = (odph_linear_table_imp *)table;
+		linear_tbl = (odph_linear_table_imp *)(void *)table;
 
 		/* check magicword, make sure the memory is used by a table */
 		if (linear_tbl->magicword != ODPH_LINEAR_TABLE_MAGIC_WORD)
@@ -142,9 +145,10 @@  odph_table_t odph_linear_table_lookup(const char *name)
 }
 
 /* should make sure the input table exists and is available */
-int odph_lineartable_put_value(odph_table_t table, void *key, void *value)
+static int odph_lineartable_put_value(odph_table_t table,
+				      void *key, void *value)
 {
-	odph_linear_table_imp *tbl = (odph_linear_table_imp *)table;
+	odph_linear_table_imp *tbl;
 	uint32_t ikey = 0;
 	void *entry = NULL;
 	odp_rwlock_t *lock = NULL;
@@ -152,6 +156,7 @@  int odph_lineartable_put_value(odph_table_t table, void *key, void *value)
 	if (table == NULL || key == NULL || value == NULL)
 		return ODPH_FAIL;
 
+	tbl = (odph_linear_table_imp *)(void *)table;
 	ikey = *(uint32_t *)key;
 	if (ikey >= tbl->node_sum)
 		return ODPH_FAIL;
@@ -170,10 +175,11 @@  int odph_lineartable_put_value(odph_table_t table, void *key, void *value)
 }
 
 /* should make sure the input table exists and is available */
-int odph_lineartable_get_value(odph_table_t table, void *key, void *buffer,
-			       uint32_t buffer_size)
+static int odph_lineartable_get_value(odph_table_t table,
+				      void *key, void *buffer,
+				      uint32_t buffer_size ODPH_UNUSED)
 {
-	odph_linear_table_imp *tbl = (odph_linear_table_imp *)table;
+	odph_linear_table_imp *tbl;
 	uint32_t ikey = 0;
 	void *entry = NULL;
 	odp_rwlock_t *lock = NULL;
@@ -181,6 +187,7 @@  int odph_lineartable_get_value(odph_table_t table, void *key, void *buffer,
 	if (table == NULL || key == NULL || buffer == NULL)
 		return ODPH_FAIL;
 
+	tbl = (odph_linear_table_imp *)(void *)table;
 	ikey = *(uint32_t *)key;
 	if (ikey >= tbl->node_sum)
 		return ODPH_FAIL;
diff --git a/helper/threads.c b/helper/threads.c
index fe5d2bde..cb747e5b 100644
--- a/helper/threads.c
+++ b/helper/threads.c
@@ -419,7 +419,7 @@  int odph_parse_options(int argc, char *argv[],
 		{0, 0, 0, 0}
 		};
 
-	static char *helper_short_options = "";
+	static const char *helper_short_options = "";
 
 	/* defaults: */
 	helper_options.proc = false;