Re: [lng-odp] [PATCH 1/2] helper: fix compilation with warnings

2017-01-20 Thread Mike Holmes
I think this needs a rebase, latest master has brought new issues with
the extra flags

 f2e960d :2016-12-29 - (HEAD -> master) configure.ac: helper: print
debug config option 
* de503c9 :2016-12-29 - helper: fix compilation with warnings 
* 3875d6e :2017-01-13 - (tag: v1.13.0.0, origin/master, origin/HEAD)
update API version number from v1.12.0.0 to v1.13.0.0 num_buckets; i++) {
^
cuckootable.c: In function ‘odph_cuckoo_table_get_value’:
cuckootable.c:656:55: error: unused parameter ‘buffer_size’
[-Werror=unused-parameter]
   odph_table_t tbl, void *key, void *buffer, uint32_t buffer_size)
   ^~~
iplookuptable.c: In function ‘odph_iplookup_table_create’:
iplookuptable.c:439:30: error: unused parameter ‘ODP_IGNORED_1’
[-Werror=unused-parameter]
   const char *name, uint32_t ODP_IGNORED_1,
  ^
iplookuptable.c:440:12: error: unused parameter ‘ODP_IGNORED_2’
[-Werror=unused-parameter]
   uint32_t ODP_IGNORED_2, uint32_t value_size)
^
iplookuptable.c: In function ‘odph_iplookup_table_get_value’:
iplookuptable.c:709:55: error: unused parameter ‘buffer_size’
[-Werror=unused-parameter]
   odph_table_t tbl, void *key, void *buffer, uint32_t buffer_size)
   ^~~
iplookuptable.c: In function ‘odph_iplookup_table_remove_value’:
iplookuptable.c:891:19: error: comparison is always false due to
limited range of data type [-Werror=type-limits]
  if (prefix->cidr < 0)
   ^
cc1: all warnings being treated as errors
cc1: all warnings being treated as errors



On 9 January 2017 at 13:37, Maxim Uvarov  wrote:
> On 01/09/17 21:10, Mike Holmes wrote:
>>
>>
>> On 29 December 2016 at 11:40, Maxim Uvarov > > wrote:
>>
>> After turning on lost CFLAGS for checking errors,
>> following things needs to be corrected to make code
>> compile.
>>
>>
>> Which cflags ? I looked in 2/2 and  assume it was debug print, but that
>> was not lost just hard wired to 1, was this a bug when debug print was = 0 ?
>>
>
> patch 2/2 passes all cflags to helper with:
> -AM_CFLAGS  = -I$(srcdir)/include
> +AM_CFLAGS += -I$(srcdir)/include
>
> with configured option -DODPH_DEBUG_PRINT=0
>
> but passing cflags triggers a lot of gcc warnings which we threat as
> errors. So patch 1 is needed before patch 2.
>
> Maxim.
>
>
>
>>
>> Signed-off-by: Maxim Uvarov > >
>> ---
>>  helper/chksum.c  |  4 ++--
>>  helper/hashtable.c   | 42 ++
>>  helper/lineartable.c | 27 +--
>>  helper/linux.c   |  2 +-
>>  4 files changed, 46 insertions(+), 29 deletions(-)
>>
>> diff --git a/helper/chksum.c b/helper/chksum.c
>> index b7eef67..f740618 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 = _hdr;
>> }
>>
>> -   addrs_ptr= (uint16_t *)_hdr_ptr->src_addr;
>> +   addrs_ptr= (uint16_t *)(void
>> *)_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/hashtable.c b/helper/hashtable.c
>> index 8bb1ae5..0b652b3 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
>> 

Re: [lng-odp] [PATCH 1/2] helper: fix compilation with warnings

2017-01-09 Thread Maxim Uvarov
On 01/09/17 21:10, Mike Holmes wrote:
> 
> 
> On 29 December 2016 at 11:40, Maxim Uvarov  > wrote:
> 
> After turning on lost CFLAGS for checking errors,
> following things needs to be corrected to make code
> compile.
> 
> 
> Which cflags ? I looked in 2/2 and  assume it was debug print, but that
> was not lost just hard wired to 1, was this a bug when debug print was = 0 ?
> 

patch 2/2 passes all cflags to helper with:
-AM_CFLAGS  = -I$(srcdir)/include
+AM_CFLAGS += -I$(srcdir)/include

with configured option -DODPH_DEBUG_PRINT=0

but passing cflags triggers a lot of gcc warnings which we threat as
errors. So patch 1 is needed before patch 2.

Maxim.



> 
> Signed-off-by: Maxim Uvarov  >
> ---
>  helper/chksum.c  |  4 ++--
>  helper/hashtable.c   | 42 ++
>  helper/lineartable.c | 27 +--
>  helper/linux.c   |  2 +-
>  4 files changed, 46 insertions(+), 29 deletions(-)
> 
> diff --git a/helper/chksum.c b/helper/chksum.c
> index b7eef67..f740618 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 = _hdr;
> }
> 
> -   addrs_ptr= (uint16_t *)_hdr_ptr->src_addr;
> +   addrs_ptr= (uint16_t *)(void
> *)_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/hashtable.c b/helper/hashtable.c
> index 8bb1ae5..0b652b3 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 

Re: [lng-odp] [PATCH 1/2] helper: fix compilation with warnings

2017-01-09 Thread Mike Holmes
On 29 December 2016 at 11:40, Maxim Uvarov  wrote:

> After turning on lost CFLAGS for checking errors,
> following things needs to be corrected to make code
> compile.
>

Which cflags ? I looked in 2/2 and  assume it was debug print, but that was
not lost just hard wired to 1, was this a bug when debug print was = 0 ?


> Signed-off-by: Maxim Uvarov 
> ---
>  helper/chksum.c  |  4 ++--
>  helper/hashtable.c   | 42 ++
>  helper/lineartable.c | 27 +--
>  helper/linux.c   |  2 +-
>  4 files changed, 46 insertions(+), 29 deletions(-)
>
> diff --git a/helper/chksum.c b/helper/chksum.c
> index b7eef67..f740618 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 = _hdr;
> }
>
> -   addrs_ptr= (uint16_t *)_hdr_ptr->src_addr;
> +   addrs_ptr= (uint16_t *)(void
> *)_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/hashtable.c b/helper/hashtable.c
> index 8bb1ae5..0b652b3 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
>

[lng-odp] [PATCH 1/2] helper: fix compilation with warnings

2016-12-29 Thread Maxim Uvarov
After turning on lost CFLAGS for checking errors,
following things needs to be corrected to make code
compile.

Signed-off-by: Maxim Uvarov 
---
 helper/chksum.c  |  4 ++--
 helper/hashtable.c   | 42 ++
 helper/lineartable.c | 27 +--
 helper/linux.c   |  2 +-
 4 files changed, 46 insertions(+), 29 deletions(-)

diff --git a/helper/chksum.c b/helper/chksum.c
index b7eef67..f740618 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 = _hdr;
}
 
-   addrs_ptr= (uint16_t *)_hdr_ptr->src_addr;
+   addrs_ptr= (uint16_t *)(void *)_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/hashtable.c b/helper/hashtable.c
index 8bb1ae5..0b652b3 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