[dpdk-dev] ring: use direct cast to objtype fixes build error

Message ID 1491487187-19577-1-git-send-email-ed.czeck@atomicrules.com (mailing list archive)
State Accepted, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Ed Czeck April 6, 2017, 1:59 p.m. UTC
  build error:
include/rte_ring.h:459:22: error: invalid conversion from ‘void*’
to ‘void**’ [-fpermissive]
  ENQUEUE_PTRS(r, &r[1], prod_head, obj_table, n, void *);

Implicit casts of void* to void** are considered warnings in some
compilers.  E.g. g++ version 5.8.  Cast directly to object types

Signed-off-by: Ed Czeck <ed.czeck@atomicrules.com>
---
 lib/librte_ring/rte_ring.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Olivier Matz April 6, 2017, 2:18 p.m. UTC | #1
On Thu,  6 Apr 2017 09:59:47 -0400, Ed Czeck <ed.czeck@atomicrules.com> wrote:
> build error:
> include/rte_ring.h:459:22: error: invalid conversion from ‘void*’
> to ‘void**’ [-fpermissive]
>   ENQUEUE_PTRS(r, &r[1], prod_head, obj_table, n, void *);
> 
> Implicit casts of void* to void** are considered warnings in some
> compilers.  E.g. g++ version 5.8.  Cast directly to object types
> 
> Signed-off-by: Ed Czeck <ed.czeck@atomicrules.com>

Acked-by: Olivier Matz <olivier.matz@6wind.com>
  
Thomas Monjalon April 6, 2017, 2:25 p.m. UTC | #2
2017-04-06 16:18, Olivier MATZ:
> On Thu,  6 Apr 2017 09:59:47 -0400, Ed Czeck <ed.czeck@atomicrules.com> wrote:
> > build error:
> > include/rte_ring.h:459:22: error: invalid conversion from ‘void*’
> > to ‘void**’ [-fpermissive]
> >   ENQUEUE_PTRS(r, &r[1], prod_head, obj_table, n, void *);
> > 
> > Implicit casts of void* to void** are considered warnings in some
> > compilers.  E.g. g++ version 5.8.  Cast directly to object types
> > 
> > Signed-off-by: Ed Czeck <ed.czeck@atomicrules.com>
> 
> Acked-by: Olivier Matz <olivier.matz@6wind.com>

Does this error happen only with C++?

Please could you give a Fixes line?
  
Ed Czeck April 6, 2017, 3:16 p.m. UTC | #3
This error has been observed with g++ 4.8 and g++ 5.4

Fixes: a6619414 ("ring: make struct and macros type agnostic")


On Thu, Apr 6, 2017 at 10:25 AM, Thomas Monjalon <thomas.monjalon@6wind.com>
wrote:
>
> Does this error happen only with C++?
>
> Please could you give a Fixes line?
  
Thomas Monjalon April 6, 2017, 3:40 p.m. UTC | #4
2017-04-06 16:18, Olivier MATZ:
> On Thu,  6 Apr 2017 09:59:47 -0400, Ed Czeck <ed.czeck@atomicrules.com> wrote:
> > build error:
> > include/rte_ring.h:459:22: error: invalid conversion from ‘void*’
> > to ‘void**’ [-fpermissive]
> >   ENQUEUE_PTRS(r, &r[1], prod_head, obj_table, n, void *);
> > 
> > Implicit casts of void* to void** are considered warnings in some
> > compilers.  E.g. g++ version 5.8.  Cast directly to object types
> > 
> > Signed-off-by: Ed Czeck <ed.czeck@atomicrules.com>
> 
> Acked-by: Olivier Matz <olivier.matz@6wind.com>

Applied, thanks
  

Patch

diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h
index 6642e18..7648cd8 100644
--- a/lib/librte_ring/rte_ring.h
+++ b/lib/librte_ring/rte_ring.h
@@ -290,7 +290,7 @@  void rte_ring_dump(FILE *f, const struct rte_ring *r);
 	unsigned int i; \
 	const uint32_t size = (r)->size; \
 	uint32_t idx = prod_head & (r)->mask; \
-	obj_type *ring = (void *)ring_start; \
+	obj_type *ring = (obj_type *)ring_start; \
 	if (likely(idx + n < size)) { \
 		for (i = 0; i < (n & ((~(unsigned)0x3))); i+=4, idx+=4) { \
 			ring[idx] = obj_table[i]; \
@@ -321,7 +321,7 @@  void rte_ring_dump(FILE *f, const struct rte_ring *r);
 	unsigned int i; \
 	uint32_t idx = cons_head & (r)->mask; \
 	const uint32_t size = (r)->size; \
-	obj_type *ring = (void *)ring_start; \
+	obj_type *ring = (obj_type *)ring_start; \
 	if (likely(idx + n < size)) { \
 		for (i = 0; i < (n & (~(unsigned)0x3)); i+=4, idx+=4) {\
 			obj_table[i] = ring[idx]; \