Skip to contentSkip to conversation

ring: use direct cast to objtype fixes build error

PATCH Applied Ed Czeck 3 participants 5 messages Apr 6, 2017

lore
Share & tools
lore

Ed Czeck

author
#0 lore raw

PATCH 1/1 ring: use direct cast to objtype fixes build error

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

---
 lib/librte_ring/rte_ring.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/librte_ring/rte_ring.h +2 -2
index 6642e18..7648cd8 100644
@@ -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]; \
Signature · 1 line
2.7.4
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Ed Czeck

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

#2 lore raw

2017-04-06 16:18, Olivier MATZ:

Quoted 6 lines · Ed Czeck
Quoted 5 lines

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 *);

Quoted 6 lines
Quoted 4 lines

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

Does this error happen only with C++?

Please could you give a Fixes line?

author
#3 lore raw

This error has been observed with g++ 4.8 and g++ 5.4

Fixes a6619414 ("ring: make struct and macros type agnostic")
Quoted 4 lines · Thomas Monjalon

Does this error happen only with C++?

Please could you give a Fixes line?

#4 lore raw
In reply to Olivier MATZ

2017-04-06 16:18, Olivier MATZ:

Quoted 6 lines · Ed Czeck
Quoted 5 lines

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 *);

Quoted 6 lines
Quoted 4 lines

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

Applied, thanks