All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] examples/vhost: fix strict aliasing error on gcc 4.4.7
@ 2015-12-08 11:23 Pablo de Lara
  2015-12-09  9:12 ` Xie, Huawei
  2015-12-09  9:39 ` [PATCH v2] " Pablo de Lara
  0 siblings, 2 replies; 14+ messages in thread
From: Pablo de Lara @ 2015-12-08 11:23 UTC (permalink / raw)
  To: dev

Fixes following error on gcc 4.4.7:

make: Entering directory `/tmp/dpdk-tmp/examples/vhost'
  CC main.o
cc1: warnings being treated as errors
/tmp/dpdk-tmp/examples/vhost/main.c: In function ‘new_device’:
/tmp/dpdk-tmp/x86_64-native-linuxapp-gcc/include/rte_ring.h:740: error:
    dereferencing pointer ‘mbuf.486’ does break strict-aliasing rules
/tmp/dpdk-tmp/examples/vhost/main.c:1503: note: initialized from here
...
/tmp/dpdk-tmp/examples/vhost/main.c:1503: note: initialized from here
/tmp/dpdk-tmp/x86_64-native-linuxapp-gcc/include/rte_ring.h:740: error:
    dereferencing pointer ‘({anonymous})’ does break strict-aliasing rules
/tmp/dpdk-tmp/examples/vhost/main.c:1804: note: initialized from here
make[1]: *** [main.o] Error 1

Fixes: d19533e8 ("examples/vhost: copy old vhost example")

Reported-by: Qian Xu <qian.q.xu@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 examples/vhost/main.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index dc3a012..4adbf32 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -1449,7 +1449,8 @@ attach_rxmbuf_zcp(struct virtio_net *dev)
 	uint64_t buff_addr, phys_addr;
 	struct vhost_virtqueue *vq;
 	struct vring_desc *desc;
-	struct rte_mbuf *mbuf = NULL;
+	void *obj = NULL;
+	struct rte_mbuf *mbuf;
 	struct vpool *vpool;
 	hpa_type addr_type;
 	struct vhost_dev *vdev = (struct vhost_dev *)dev->priv;
@@ -1500,7 +1501,8 @@ attach_rxmbuf_zcp(struct virtio_net *dev)
 		}
 	} while (unlikely(phys_addr == 0));
 
-	rte_ring_sc_dequeue(vpool->ring, (void **)&mbuf);
+	rte_ring_sc_dequeue(vpool->ring, (void **)&obj);
+	mbuf = (struct rte_mbuf *)obj;
 	if (unlikely(mbuf == NULL)) {
 		LOG_DEBUG(VHOST_DATA,
 			"(%"PRIu64") in attach_rxmbuf_zcp: "
@@ -1517,7 +1519,7 @@ attach_rxmbuf_zcp(struct virtio_net *dev)
 			"size required: %d\n",
 			dev->device_fh, desc->len, desc_idx, vpool->buf_size);
 		put_desc_to_used_list_zcp(vq, desc_idx);
-		rte_ring_sp_enqueue(vpool->ring, (void *)mbuf);
+		rte_ring_sp_enqueue(vpool->ring, obj);
 		return;
 	}
 
@@ -1789,7 +1791,8 @@ virtio_tx_route_zcp(struct virtio_net *dev, struct rte_mbuf *m,
 {
 	struct mbuf_table *tx_q;
 	struct rte_mbuf **m_table;
-	struct rte_mbuf *mbuf = NULL;
+	void *obj = NULL;
+	struct rte_mbuf *mbuf;
 	unsigned len, ret, offset = 0;
 	struct vpool *vpool;
 	uint16_t vlan_tag = (uint16_t)vlan_tags[(uint16_t)dev->device_fh];
@@ -1801,7 +1804,8 @@ virtio_tx_route_zcp(struct virtio_net *dev, struct rte_mbuf *m,
 
 	/* Allocate an mbuf and populate the structure. */
 	vpool = &vpool_array[MAX_QUEUES + vmdq_rx_q];
-	rte_ring_sc_dequeue(vpool->ring, (void **)&mbuf);
+	rte_ring_sc_dequeue(vpool->ring, (void **)&obj);
+	mbuf = (struct rte_mbuf *) obj;
 	if (unlikely(mbuf == NULL)) {
 		struct vhost_virtqueue *vq = dev->virtqueue[VIRTIO_TXQ];
 		RTE_LOG(ERR, VHOST_DATA,
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH] examples/vhost: fix strict aliasing error on gcc 4.4.7
  2015-12-08 11:23 [PATCH] examples/vhost: fix strict aliasing error on gcc 4.4.7 Pablo de Lara
@ 2015-12-09  9:12 ` Xie, Huawei
  2015-12-09  9:39 ` [PATCH v2] " Pablo de Lara
  1 sibling, 0 replies; 14+ messages in thread
From: Xie, Huawei @ 2015-12-09  9:12 UTC (permalink / raw)
  To: De Lara Guarch, Pablo, dev@dpdk.org

On 12/8/2015 7:24 PM, De Lara Guarch, Pablo wrote:
> Fixes following error on gcc 4.4.7:
>
> make: Entering directory `/tmp/dpdk-tmp/examples/vhost'
>   CC main.o
> cc1: warnings being treated as errors
> /tmp/dpdk-tmp/examples/vhost/main.c: In function ‘new_device’:
> /tmp/dpdk-tmp/x86_64-native-linuxapp-gcc/include/rte_ring.h:740: error:
>     dereferencing pointer ‘mbuf.486’ does break strict-aliasing rules
> /tmp/dpdk-tmp/examples/vhost/main.c:1503: note: initialized from here
> ...
> /tmp/dpdk-tmp/examples/vhost/main.c:1503: note: initialized from here
> /tmp/dpdk-tmp/x86_64-native-linuxapp-gcc/include/rte_ring.h:740: error:
>     dereferencing pointer ‘({anonymous})’ does break strict-aliasing rules
> /tmp/dpdk-tmp/examples/vhost/main.c:1804: note: initialized from here
> make[1]: *** [main.o] Error 1
>
> Fixes: d19533e8 ("examples/vhost: copy old vhost example")
>
> Reported-by: Qian Xu <qian.q.xu@intel.com>
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> ---
>  examples/vhost/main.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
>
[...]
>  
> -	rte_ring_sc_dequeue(vpool->ring, (void **)&mbuf);
> +	rte_ring_sc_dequeue(vpool->ring, (void **)&obj);
> +	mbuf = (struct rte_mbuf *)obj;
Is rte_ring_sc_dequeue(vpool->ring, &obj) enough? Applied to the later
enqueue as well.
>  	if (unlikely(mbuf == NULL)) {
[...]
> -		rte_ring_sp_enqueue(vpool->ring, (void *)mbuf);
> +		rte_ring_sp_enqueue(vpool->ring, obj);
>  		return;
>  	}
>  
> @@ -1789,7 +1791,8 @@ virtio_tx_route_zcp(struct virtio_net *dev, struct rte_mbuf *m,
>  {
>  	
[...]
>  	vpool = &vpool_array[MAX_QUEUES + vmdq_rx_q];
> -	rte_ring_sc_dequeue(vpool->ring, (void **)&mbuf);
> +	rte_ring_sc_dequeue(vpool->ring, (void **)&obj);
> +	mbuf = (struct rte_mbuf *) obj;
>  	if (unlikely(mbuf == NULL)) {
>  		struct vhost_virtqueue *vq = dev->virtqueue[VIRTIO_TXQ];
>  		RTE_LOG(ERR, VHOST_DATA,


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2] examples/vhost: fix strict aliasing error on gcc 4.4.7
  2015-12-08 11:23 [PATCH] examples/vhost: fix strict aliasing error on gcc 4.4.7 Pablo de Lara
  2015-12-09  9:12 ` Xie, Huawei
@ 2015-12-09  9:39 ` Pablo de Lara
  2015-12-09 10:32   ` Bruce Richardson
                     ` (2 more replies)
  1 sibling, 3 replies; 14+ messages in thread
From: Pablo de Lara @ 2015-12-09  9:39 UTC (permalink / raw)
  To: dev

From: "De Lara Guarch, Pablo" <pablo.de.lara.guarch@intel.com>

Fixes following error on gcc 4.4.7:

make: Entering directory `/tmp/dpdk-tmp/examples/vhost'
  CC main.o
cc1: warnings being treated as errors
/tmp/dpdk-tmp/examples/vhost/main.c: In function ‘new_device’:
/tmp/dpdk-tmp/x86_64-native-linuxapp-gcc/include/rte_ring.h:740: error:
    dereferencing pointer ‘mbuf.486’ does break strict-aliasing rules
/tmp/dpdk-tmp/examples/vhost/main.c:1503: note: initialized from here
...
/tmp/dpdk-tmp/examples/vhost/main.c:1503: note: initialized from here
/tmp/dpdk-tmp/x86_64-native-linuxapp-gcc/include/rte_ring.h:740: error:
    dereferencing pointer ‘({anonymous})’ does break strict-aliasing rules
/tmp/dpdk-tmp/examples/vhost/main.c:1804: note: initialized from here
make[1]: *** [main.o] Error 1

Fixes: d19533e8 ("examples/vhost: copy old vhost example")

Reported-by: Qian Xu <qian.q.xu@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
Changes in v2:
- Remove unnecessary casting

 examples/vhost/main.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index dc3a012..2000a3a 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -1449,7 +1449,8 @@ attach_rxmbuf_zcp(struct virtio_net *dev)
 	uint64_t buff_addr, phys_addr;
 	struct vhost_virtqueue *vq;
 	struct vring_desc *desc;
-	struct rte_mbuf *mbuf = NULL;
+	void *obj = NULL;
+	struct rte_mbuf *mbuf;
 	struct vpool *vpool;
 	hpa_type addr_type;
 	struct vhost_dev *vdev = (struct vhost_dev *)dev->priv;
@@ -1500,7 +1501,8 @@ attach_rxmbuf_zcp(struct virtio_net *dev)
 		}
 	} while (unlikely(phys_addr == 0));
 
-	rte_ring_sc_dequeue(vpool->ring, (void **)&mbuf);
+	rte_ring_sc_dequeue(vpool->ring, &obj);
+	mbuf = (struct rte_mbuf *)obj;
 	if (unlikely(mbuf == NULL)) {
 		LOG_DEBUG(VHOST_DATA,
 			"(%"PRIu64") in attach_rxmbuf_zcp: "
@@ -1517,7 +1519,7 @@ attach_rxmbuf_zcp(struct virtio_net *dev)
 			"size required: %d\n",
 			dev->device_fh, desc->len, desc_idx, vpool->buf_size);
 		put_desc_to_used_list_zcp(vq, desc_idx);
-		rte_ring_sp_enqueue(vpool->ring, (void *)mbuf);
+		rte_ring_sp_enqueue(vpool->ring, obj);
 		return;
 	}
 
@@ -1789,7 +1791,8 @@ virtio_tx_route_zcp(struct virtio_net *dev, struct rte_mbuf *m,
 {
 	struct mbuf_table *tx_q;
 	struct rte_mbuf **m_table;
-	struct rte_mbuf *mbuf = NULL;
+	void *obj = NULL;
+	struct rte_mbuf *mbuf;
 	unsigned len, ret, offset = 0;
 	struct vpool *vpool;
 	uint16_t vlan_tag = (uint16_t)vlan_tags[(uint16_t)dev->device_fh];
@@ -1801,7 +1804,8 @@ virtio_tx_route_zcp(struct virtio_net *dev, struct rte_mbuf *m,
 
 	/* Allocate an mbuf and populate the structure. */
 	vpool = &vpool_array[MAX_QUEUES + vmdq_rx_q];
-	rte_ring_sc_dequeue(vpool->ring, (void **)&mbuf);
+	rte_ring_sc_dequeue(vpool->ring, &obj);
+	mbuf = (struct rte_mbuf *)obj;
 	if (unlikely(mbuf == NULL)) {
 		struct vhost_virtqueue *vq = dev->virtqueue[VIRTIO_TXQ];
 		RTE_LOG(ERR, VHOST_DATA,
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH v2] examples/vhost: fix strict aliasing error on gcc 4.4.7
  2015-12-09  9:39 ` [PATCH v2] " Pablo de Lara
@ 2015-12-09 10:32   ` Bruce Richardson
  2015-12-09 10:45   ` Xie, Huawei
  2015-12-09 11:09   ` [PATCH v3] " Pablo de Lara
  2 siblings, 0 replies; 14+ messages in thread
From: Bruce Richardson @ 2015-12-09 10:32 UTC (permalink / raw)
  To: Pablo de Lara; +Cc: dev

On Wed, Dec 09, 2015 at 09:39:59AM +0000, Pablo de Lara wrote:
> From: "De Lara Guarch, Pablo" <pablo.de.lara.guarch@intel.com>
> 
> Fixes following error on gcc 4.4.7:
> 
> make: Entering directory `/tmp/dpdk-tmp/examples/vhost'
>   CC main.o
> cc1: warnings being treated as errors
> /tmp/dpdk-tmp/examples/vhost/main.c: In function ‘new_device’:
> /tmp/dpdk-tmp/x86_64-native-linuxapp-gcc/include/rte_ring.h:740: error:
>     dereferencing pointer ‘mbuf.486’ does break strict-aliasing rules
> /tmp/dpdk-tmp/examples/vhost/main.c:1503: note: initialized from here
> ...
> /tmp/dpdk-tmp/examples/vhost/main.c:1503: note: initialized from here
> /tmp/dpdk-tmp/x86_64-native-linuxapp-gcc/include/rte_ring.h:740: error:
>     dereferencing pointer ‘({anonymous})’ does break strict-aliasing rules
> /tmp/dpdk-tmp/examples/vhost/main.c:1804: note: initialized from here
> make[1]: *** [main.o] Error 1
> 
> Fixes: d19533e8 ("examples/vhost: copy old vhost example")
> 
> Reported-by: Qian Xu <qian.q.xu@intel.com>
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> ---
> Changes in v2:
> - Remove unnecessary casting

You've remove some, but not all unnecessary casting. You don't need a cast when
assigning void * to any other type, so you can remove the mbuf casts too.

/Bruce

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2] examples/vhost: fix strict aliasing error on gcc 4.4.7
  2015-12-09  9:39 ` [PATCH v2] " Pablo de Lara
  2015-12-09 10:32   ` Bruce Richardson
@ 2015-12-09 10:45   ` Xie, Huawei
  2015-12-09 10:52     ` De Lara Guarch, Pablo
  2015-12-09 11:09   ` [PATCH v3] " Pablo de Lara
  2 siblings, 1 reply; 14+ messages in thread
From: Xie, Huawei @ 2015-12-09 10:45 UTC (permalink / raw)
  To: De Lara Guarch, Pablo, dev@dpdk.org

On 12/9/2015 5:40 PM, De Lara Guarch, Pablo wrote:
> From: "De Lara Guarch, Pablo" <pablo.de.lara.guarch@intel.com>
>
> Fixes following error on gcc 4.4.7:
>
> make: Entering directory `/tmp/dpdk-tmp/examples/vhost'
>   CC main.o
> cc1: warnings being treated as errors
> /tmp/dpdk-tmp/examples/vhost/main.c: In function ‘new_device’:
> /tmp/dpdk-tmp/x86_64-native-linuxapp-gcc/include/rte_ring.h:740: error:
>     dereferencing pointer ‘mbuf.486’ does break strict-aliasing rules
> /tmp/dpdk-tmp/examples/vhost/main.c:1503: note: initialized from here
> ...
> /tmp/dpdk-tmp/examples/vhost/main.c:1503: note: initialized from here
> /tmp/dpdk-tmp/x86_64-native-linuxapp-gcc/include/rte_ring.h:740: error:
>     dereferencing pointer ‘({anonymous})’ does break strict-aliasing rules
> /tmp/dpdk-tmp/examples/vhost/main.c:1804: note: initialized from here
> make[1]: *** [main.o] Error 1
>
> Fixes: d19533e8 ("examples/vhost: copy old vhost example")
>
> Reported-by: Qian Xu <qian.q.xu@intel.com>
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Huawei Xie <huawei.xie@intel.com>



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v2] examples/vhost: fix strict aliasing error on gcc 4.4.7
  2015-12-09 10:45   ` Xie, Huawei
@ 2015-12-09 10:52     ` De Lara Guarch, Pablo
  0 siblings, 0 replies; 14+ messages in thread
From: De Lara Guarch, Pablo @ 2015-12-09 10:52 UTC (permalink / raw)
  To: Xie, Huawei, dev@dpdk.org

Hi Huawei,

> -----Original Message-----
> From: Xie, Huawei
> Sent: Wednesday, December 09, 2015 10:45 AM
> To: De Lara Guarch, Pablo; dev@dpdk.org
> Cc: yuanhan.liu@linux.intel.com
> Subject: Re: [PATCH v2] examples/vhost: fix strict aliasing error on gcc 4.4.7
> 
> On 12/9/2015 5:40 PM, De Lara Guarch, Pablo wrote:
> > From: "De Lara Guarch, Pablo" <pablo.de.lara.guarch@intel.com>
> >
> > Fixes following error on gcc 4.4.7:
> >
> > make: Entering directory `/tmp/dpdk-tmp/examples/vhost'
> >   CC main.o
> > cc1: warnings being treated as errors
> > /tmp/dpdk-tmp/examples/vhost/main.c: In function 'new_device':
> > /tmp/dpdk-tmp/x86_64-native-linuxapp-gcc/include/rte_ring.h:740:
> error:
> >     dereferencing pointer 'mbuf.486' does break strict-aliasing rules
> > /tmp/dpdk-tmp/examples/vhost/main.c:1503: note: initialized from here
> > ...
> > /tmp/dpdk-tmp/examples/vhost/main.c:1503: note: initialized from here
> > /tmp/dpdk-tmp/x86_64-native-linuxapp-gcc/include/rte_ring.h:740:
> error:
> >     dereferencing pointer '({anonymous})' does break strict-aliasing rules
> > /tmp/dpdk-tmp/examples/vhost/main.c:1804: note: initialized from here
> > make[1]: *** [main.o] Error 1
> >
> > Fixes: d19533e8 ("examples/vhost: copy old vhost example")
> >
> > Reported-by: Qian Xu <qian.q.xu@intel.com>
> > Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> Acked-by: Huawei Xie <huawei.xie@intel.com>
> 

I am going to send a v3 for this patch, removing the other casting that Bruce mentioned.
I will pre-ack it, unless you have any concerns.

Thanks,
Pablo

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v3] examples/vhost: fix strict aliasing error on gcc 4.4.7
  2015-12-09  9:39 ` [PATCH v2] " Pablo de Lara
  2015-12-09 10:32   ` Bruce Richardson
  2015-12-09 10:45   ` Xie, Huawei
@ 2015-12-09 11:09   ` Pablo de Lara
  2015-12-09 12:20     ` [PATCH v4] Fixes following error on gcc 4.4.7: Pablo de Lara
  2 siblings, 1 reply; 14+ messages in thread
From: Pablo de Lara @ 2015-12-09 11:09 UTC (permalink / raw)
  To: dev

From: "De Lara Guarch, Pablo" <pablo.de.lara.guarch@intel.com>

Fixes following error on gcc 4.4.7:

make: Entering directory `/tmp/dpdk-tmp/examples/vhost'
  CC main.o
cc1: warnings being treated as errors
/tmp/dpdk-tmp/examples/vhost/main.c: In function ‘new_device’:
/tmp/dpdk-tmp/x86_64-native-linuxapp-gcc/include/rte_ring.h:740: error:
    dereferencing pointer ‘mbuf.486’ does break strict-aliasing rules
/tmp/dpdk-tmp/examples/vhost/main.c:1503: note: initialized from here
...
/tmp/dpdk-tmp/examples/vhost/main.c:1503: note: initialized from here
/tmp/dpdk-tmp/x86_64-native-linuxapp-gcc/include/rte_ring.h:740: error:
    dereferencing pointer ‘({anonymous})’ does break strict-aliasing rules
/tmp/dpdk-tmp/examples/vhost/main.c:1804: note: initialized from here
make[1]: *** [main.o] Error 1

Fixes: d19533e8 ("examples/vhost: copy old vhost example")

Reported-by: Qian Xu <qian.q.xu@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Huawei Xie <huawei.xie@intel.com>
---
Changes in v3:
- Remove even more unnecessary castings

Changes in v2:
- Remove unnecessary casting

 examples/vhost/main.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index dc3a012..b30f1bd 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -1449,7 +1449,8 @@ attach_rxmbuf_zcp(struct virtio_net *dev)
 	uint64_t buff_addr, phys_addr;
 	struct vhost_virtqueue *vq;
 	struct vring_desc *desc;
-	struct rte_mbuf *mbuf = NULL;
+	void *obj = NULL;
+	struct rte_mbuf *mbuf;
 	struct vpool *vpool;
 	hpa_type addr_type;
 	struct vhost_dev *vdev = (struct vhost_dev *)dev->priv;
@@ -1500,7 +1501,8 @@ attach_rxmbuf_zcp(struct virtio_net *dev)
 		}
 	} while (unlikely(phys_addr == 0));
 
-	rte_ring_sc_dequeue(vpool->ring, (void **)&mbuf);
+	rte_ring_sc_dequeue(vpool->ring, &obj);
+	mbuf = obj;
 	if (unlikely(mbuf == NULL)) {
 		LOG_DEBUG(VHOST_DATA,
 			"(%"PRIu64") in attach_rxmbuf_zcp: "
@@ -1517,7 +1519,7 @@ attach_rxmbuf_zcp(struct virtio_net *dev)
 			"size required: %d\n",
 			dev->device_fh, desc->len, desc_idx, vpool->buf_size);
 		put_desc_to_used_list_zcp(vq, desc_idx);
-		rte_ring_sp_enqueue(vpool->ring, (void *)mbuf);
+		rte_ring_sp_enqueue(vpool->ring, obj);
 		return;
 	}
 
@@ -1789,7 +1791,8 @@ virtio_tx_route_zcp(struct virtio_net *dev, struct rte_mbuf *m,
 {
 	struct mbuf_table *tx_q;
 	struct rte_mbuf **m_table;
-	struct rte_mbuf *mbuf = NULL;
+	void *obj = NULL;
+	struct rte_mbuf *mbuf;
 	unsigned len, ret, offset = 0;
 	struct vpool *vpool;
 	uint16_t vlan_tag = (uint16_t)vlan_tags[(uint16_t)dev->device_fh];
@@ -1801,7 +1804,8 @@ virtio_tx_route_zcp(struct virtio_net *dev, struct rte_mbuf *m,
 
 	/* Allocate an mbuf and populate the structure. */
 	vpool = &vpool_array[MAX_QUEUES + vmdq_rx_q];
-	rte_ring_sc_dequeue(vpool->ring, (void **)&mbuf);
+	rte_ring_sc_dequeue(vpool->ring, &obj);
+	mbuf = obj;
 	if (unlikely(mbuf == NULL)) {
 		struct vhost_virtqueue *vq = dev->virtqueue[VIRTIO_TXQ];
 		RTE_LOG(ERR, VHOST_DATA,
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v4] Fixes following error on gcc 4.4.7:
  2015-12-09 11:09   ` [PATCH v3] " Pablo de Lara
@ 2015-12-09 12:20     ` Pablo de Lara
  2015-12-09 13:28       ` Xie, Huawei
  2015-12-09 14:26       ` [PATCH v5] examples/vhost: fix strict aliasing error on gcc 4.4.7 Pablo de Lara
  0 siblings, 2 replies; 14+ messages in thread
From: Pablo de Lara @ 2015-12-09 12:20 UTC (permalink / raw)
  To: dev

make: Entering directory `/tmp/dpdk-tmp/examples/vhost'
  CC main.o
cc1: warnings being treated as errors
/tmp/dpdk-tmp/examples/vhost/main.c: In function ‘new_device’:
/tmp/dpdk-tmp/x86_64-native-linuxapp-gcc/include/rte_ring.h:740: error:
    dereferencing pointer ‘mbuf.486’ does break strict-aliasing rules
/tmp/dpdk-tmp/examples/vhost/main.c:1503: note: initialized from here
...
/tmp/dpdk-tmp/examples/vhost/main.c:1503: note: initialized from here
/tmp/dpdk-tmp/x86_64-native-linuxapp-gcc/include/rte_ring.h:740: error:
    dereferencing pointer ‘({anonymous})’ does break strict-aliasing rules
/tmp/dpdk-tmp/examples/vhost/main.c:1804: note: initialized from here
make[1]: *** [main.o] Error 1

Fixes: d19533e8 ("examples/vhost: copy old vhost example")

Reported-by: Qian Xu <qian.q.xu@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
Changes in v4:
- Simplify patch, just casting to void *, without using new variables

Changes in v3:
- Remove even more unnecessary castings

Changes in v2:
- Remove unnecessary casting

 examples/vhost/main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index dc3a012..f3c50c5 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -1500,7 +1500,7 @@ attach_rxmbuf_zcp(struct virtio_net *dev)
 		}
 	} while (unlikely(phys_addr == 0));
 
-	rte_ring_sc_dequeue(vpool->ring, (void **)&mbuf);
+	rte_ring_sc_dequeue(vpool->ring, (void *)mbuf);
 	if (unlikely(mbuf == NULL)) {
 		LOG_DEBUG(VHOST_DATA,
 			"(%"PRIu64") in attach_rxmbuf_zcp: "
@@ -1801,7 +1801,7 @@ virtio_tx_route_zcp(struct virtio_net *dev, struct rte_mbuf *m,
 
 	/* Allocate an mbuf and populate the structure. */
 	vpool = &vpool_array[MAX_QUEUES + vmdq_rx_q];
-	rte_ring_sc_dequeue(vpool->ring, (void **)&mbuf);
+	rte_ring_sc_dequeue(vpool->ring, (void *)mbuf);
 	if (unlikely(mbuf == NULL)) {
 		struct vhost_virtqueue *vq = dev->virtqueue[VIRTIO_TXQ];
 		RTE_LOG(ERR, VHOST_DATA,
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH v4] Fixes following error on gcc 4.4.7:
  2015-12-09 12:20     ` [PATCH v4] Fixes following error on gcc 4.4.7: Pablo de Lara
@ 2015-12-09 13:28       ` Xie, Huawei
  2015-12-09 14:01         ` De Lara Guarch, Pablo
  2015-12-09 14:26       ` [PATCH v5] examples/vhost: fix strict aliasing error on gcc 4.4.7 Pablo de Lara
  1 sibling, 1 reply; 14+ messages in thread
From: Xie, Huawei @ 2015-12-09 13:28 UTC (permalink / raw)
  To: De Lara Guarch, Pablo, dev@dpdk.org

On 12/9/2015 8:20 PM, De Lara Guarch, Pablo wrote:
> make: Entering directory `/tmp/dpdk-tmp/examples/vhost'
>   CC main.o
[...]
> -	rte_ring_sc_dequeue(vpool->ring, (void **)&mbuf);
> +	rte_ring_sc_dequeue(vpool->ring, (void *)mbuf);
Here we are expecting the address of &mbuf, not mbuf, which is NULL.
>  	if (unlikely(mbuf == NULL)) {
>  		LOG_DEBUG(VHOST_DATA,
>  			"(%"PRIu64") in attach_rxmbuf_zcp: "
> @@ -1801,7 +1801,7 @@ virtio_tx_route_zcp(struct virtio_net *dev, struct rte_mbuf *m,
>  
>  	/* Allocate an mbuf and populate the structure. */
>  	vpool = &vpool_array[MAX_QUEUES + vmdq_rx_q];
> -	rte_ring_sc_dequeue(vpool->ring, (void **)&mbuf);
> +	rte_ring_sc_dequeue(vpool->ring, (void *)mbuf);
Same as above.
>  	if (unlikely(mbuf == NULL)) {
>  		struct vhost_virtqueue *vq = dev->virtqueue[VIRTIO_TXQ];
>  		RTE_LOG(ERR, VHOST_DATA,


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v4] Fixes following error on gcc 4.4.7:
  2015-12-09 13:28       ` Xie, Huawei
@ 2015-12-09 14:01         ` De Lara Guarch, Pablo
  2015-12-09 14:12           ` Xie, Huawei
  0 siblings, 1 reply; 14+ messages in thread
From: De Lara Guarch, Pablo @ 2015-12-09 14:01 UTC (permalink / raw)
  To: Xie, Huawei, dev@dpdk.org



> -----Original Message-----
> From: Xie, Huawei
> Sent: Wednesday, December 09, 2015 1:29 PM
> To: De Lara Guarch, Pablo; dev@dpdk.org
> Cc: yuanhan.liu@linux.intel.com
> Subject: Re: [PATCH v4] Fixes following error on gcc 4.4.7:
> 
> On 12/9/2015 8:20 PM, De Lara Guarch, Pablo wrote:
> > make: Entering directory `/tmp/dpdk-tmp/examples/vhost'
> >   CC main.o
> [...]
> > -	rte_ring_sc_dequeue(vpool->ring, (void **)&mbuf);
> > +	rte_ring_sc_dequeue(vpool->ring, (void *)mbuf);
> Here we are expecting the address of &mbuf, not mbuf, which is NULL.
> >  	if (unlikely(mbuf == NULL)) {
> >  		LOG_DEBUG(VHOST_DATA,
> >  			"(%"PRIu64") in attach_rxmbuf_zcp: "
> > @@ -1801,7 +1801,7 @@ virtio_tx_route_zcp(struct virtio_net *dev,
> struct rte_mbuf *m,
> >
> >  	/* Allocate an mbuf and populate the structure. */
> >  	vpool = &vpool_array[MAX_QUEUES + vmdq_rx_q];
> > -	rte_ring_sc_dequeue(vpool->ring, (void **)&mbuf);
> > +	rte_ring_sc_dequeue(vpool->ring, (void *)mbuf);
> Same as above.
> >  	if (unlikely(mbuf == NULL)) {
> >  		struct vhost_virtqueue *vq = dev->virtqueue[VIRTIO_TXQ];
> >  		RTE_LOG(ERR, VHOST_DATA,

Right, I will revert to v3 (and fix the title as well, sorry about that).

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v4] Fixes following error on gcc 4.4.7:
  2015-12-09 14:01         ` De Lara Guarch, Pablo
@ 2015-12-09 14:12           ` Xie, Huawei
  0 siblings, 0 replies; 14+ messages in thread
From: Xie, Huawei @ 2015-12-09 14:12 UTC (permalink / raw)
  To: De Lara Guarch, Pablo, dev@dpdk.org

On 12/9/2015 10:01 PM, De Lara Guarch, Pablo wrote:
>
>> -----Original Message-----
>> From: Xie, Huawei
>> Sent: Wednesday, December 09, 2015 1:29 PM
>> To: De Lara Guarch, Pablo; dev@dpdk.org
>> Cc: yuanhan.liu@linux.intel.com
>> Subject: Re: [PATCH v4] Fixes following error on gcc 4.4.7:
>>
>> On 12/9/2015 8:20 PM, De Lara Guarch, Pablo wrote:
>>> make: Entering directory `/tmp/dpdk-tmp/examples/vhost'
>>>   CC main.o
>> [...]
>>> -	rte_ring_sc_dequeue(vpool->ring, (void **)&mbuf);
>>> +	rte_ring_sc_dequeue(vpool->ring, (void *)mbuf);
>> Here we are expecting the address of &mbuf, not mbuf, which is NULL.
>>>  	if (unlikely(mbuf == NULL)) {
>>>  		LOG_DEBUG(VHOST_DATA,
>>>  			"(%"PRIu64") in attach_rxmbuf_zcp: "
>>> @@ -1801,7 +1801,7 @@ virtio_tx_route_zcp(struct virtio_net *dev,
>> struct rte_mbuf *m,
>>>  	/* Allocate an mbuf and populate the structure. */
>>>  	vpool = &vpool_array[MAX_QUEUES + vmdq_rx_q];
>>> -	rte_ring_sc_dequeue(vpool->ring, (void **)&mbuf);
>>> +	rte_ring_sc_dequeue(vpool->ring, (void *)mbuf);
>> Same as above.
>>>  	if (unlikely(mbuf == NULL)) {
>>>  		struct vhost_virtqueue *vq = dev->virtqueue[VIRTIO_TXQ];
>>>  		RTE_LOG(ERR, VHOST_DATA,
> Right, I will revert to v3 (and fix the title as well, sorry about that).
Actually we could try defining mbufs[1], and use (void **)mbufs as
parameter, like in examples/qos_sched to save a variable, but weird it
failed. For the time being, this fix is OK.
Another thing is would you fix examples/ip_pipeline as well?
>


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v5] examples/vhost: fix strict aliasing error on gcc 4.4.7
  2015-12-09 12:20     ` [PATCH v4] Fixes following error on gcc 4.4.7: Pablo de Lara
  2015-12-09 13:28       ` Xie, Huawei
@ 2015-12-09 14:26       ` Pablo de Lara
  2015-12-09 14:33         ` Xie, Huawei
  1 sibling, 1 reply; 14+ messages in thread
From: Pablo de Lara @ 2015-12-09 14:26 UTC (permalink / raw)
  To: dev

From: "De Lara Guarch, Pablo" <pablo.de.lara.guarch@intel.com>

Fixes following error on gcc 4.4.7:

make: Entering directory `/tmp/dpdk-tmp/examples/vhost'
  CC main.o
cc1: warnings being treated as errors
/tmp/dpdk-tmp/examples/vhost/main.c: In function ‘new_device’:
/tmp/dpdk-tmp/x86_64-native-linuxapp-gcc/include/rte_ring.h:740: error:
    dereferencing pointer ‘mbuf.486’ does break strict-aliasing rules
/tmp/dpdk-tmp/examples/vhost/main.c:1503: note: initialized from here
...
/tmp/dpdk-tmp/examples/vhost/main.c:1503: note: initialized from here
/tmp/dpdk-tmp/x86_64-native-linuxapp-gcc/include/rte_ring.h:740: error:
    dereferencing pointer ‘({anonymous})’ does break strict-aliasing rules
/tmp/dpdk-tmp/examples/vhost/main.c:1804: note: initialized from here
make[1]: *** [main.o] Error 1

Fixes: d19533e8 ("examples/vhost: copy old vhost example")

Reported-by: Qian Xu <qian.q.xu@intel.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
Changes in v5:
- Revert to v3 and fix the title

Changes in v4:
- Simplify patch, just casting to void *, without using new variables

Changes in v3:
- Remove even more unnecessary castings

Changes in v2:
- Remove unnecessary casting

 examples/vhost/main.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index dc3a012..b30f1bd 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -1449,7 +1449,8 @@ attach_rxmbuf_zcp(struct virtio_net *dev)
 	uint64_t buff_addr, phys_addr;
 	struct vhost_virtqueue *vq;
 	struct vring_desc *desc;
-	struct rte_mbuf *mbuf = NULL;
+	void *obj = NULL;
+	struct rte_mbuf *mbuf;
 	struct vpool *vpool;
 	hpa_type addr_type;
 	struct vhost_dev *vdev = (struct vhost_dev *)dev->priv;
@@ -1500,7 +1501,8 @@ attach_rxmbuf_zcp(struct virtio_net *dev)
 		}
 	} while (unlikely(phys_addr == 0));
 
-	rte_ring_sc_dequeue(vpool->ring, (void **)&mbuf);
+	rte_ring_sc_dequeue(vpool->ring, &obj);
+	mbuf = obj;
 	if (unlikely(mbuf == NULL)) {
 		LOG_DEBUG(VHOST_DATA,
 			"(%"PRIu64") in attach_rxmbuf_zcp: "
@@ -1517,7 +1519,7 @@ attach_rxmbuf_zcp(struct virtio_net *dev)
 			"size required: %d\n",
 			dev->device_fh, desc->len, desc_idx, vpool->buf_size);
 		put_desc_to_used_list_zcp(vq, desc_idx);
-		rte_ring_sp_enqueue(vpool->ring, (void *)mbuf);
+		rte_ring_sp_enqueue(vpool->ring, obj);
 		return;
 	}
 
@@ -1789,7 +1791,8 @@ virtio_tx_route_zcp(struct virtio_net *dev, struct rte_mbuf *m,
 {
 	struct mbuf_table *tx_q;
 	struct rte_mbuf **m_table;
-	struct rte_mbuf *mbuf = NULL;
+	void *obj = NULL;
+	struct rte_mbuf *mbuf;
 	unsigned len, ret, offset = 0;
 	struct vpool *vpool;
 	uint16_t vlan_tag = (uint16_t)vlan_tags[(uint16_t)dev->device_fh];
@@ -1801,7 +1804,8 @@ virtio_tx_route_zcp(struct virtio_net *dev, struct rte_mbuf *m,
 
 	/* Allocate an mbuf and populate the structure. */
 	vpool = &vpool_array[MAX_QUEUES + vmdq_rx_q];
-	rte_ring_sc_dequeue(vpool->ring, (void **)&mbuf);
+	rte_ring_sc_dequeue(vpool->ring, &obj);
+	mbuf = obj;
 	if (unlikely(mbuf == NULL)) {
 		struct vhost_virtqueue *vq = dev->virtqueue[VIRTIO_TXQ];
 		RTE_LOG(ERR, VHOST_DATA,
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH v5] examples/vhost: fix strict aliasing error on gcc 4.4.7
  2015-12-09 14:26       ` [PATCH v5] examples/vhost: fix strict aliasing error on gcc 4.4.7 Pablo de Lara
@ 2015-12-09 14:33         ` Xie, Huawei
  2015-12-09 20:54           ` Thomas Monjalon
  0 siblings, 1 reply; 14+ messages in thread
From: Xie, Huawei @ 2015-12-09 14:33 UTC (permalink / raw)
  To: De Lara Guarch, Pablo, dev@dpdk.org

On 12/9/2015 10:27 PM, De Lara Guarch, Pablo wrote:
> From: "De Lara Guarch, Pablo" <pablo.de.lara.guarch@intel.com>
>
> Fixes following error on gcc 4.4.7:
>
> make: Entering directory `/tmp/dpdk-tmp/examples/vhost'
>   CC main.o
> cc1: warnings being treated as errors
> /tmp/dpdk-tmp/examples/vhost/main.c: In function ‘new_device’:
> /tmp/dpdk-tmp/x86_64-native-linuxapp-gcc/include/rte_ring.h:740: error:
>     dereferencing pointer ‘mbuf.486’ does break strict-aliasing rules
> /tmp/dpdk-tmp/examples/vhost/main.c:1503: note: initialized from here
> ...
> /tmp/dpdk-tmp/examples/vhost/main.c:1503: note: initialized from here
> /tmp/dpdk-tmp/x86_64-native-linuxapp-gcc/include/rte_ring.h:740: error:
>     dereferencing pointer ‘({anonymous})’ does break strict-aliasing rules
> /tmp/dpdk-tmp/examples/vhost/main.c:1804: note: initialized from here
> make[1]: *** [main.o] Error 1
>
> Fixes: d19533e8 ("examples/vhost: copy old vhost example")
>
> Reported-by: Qian Xu <qian.q.xu@intel.com>
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Huawei Xie <huawei.xie@intel.com>


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v5] examples/vhost: fix strict aliasing error on gcc 4.4.7
  2015-12-09 14:33         ` Xie, Huawei
@ 2015-12-09 20:54           ` Thomas Monjalon
  0 siblings, 0 replies; 14+ messages in thread
From: Thomas Monjalon @ 2015-12-09 20:54 UTC (permalink / raw)
  To: De Lara Guarch, Pablo; +Cc: dev

2015-12-09 14:33, Xie, Huawei:
> On 12/9/2015 10:27 PM, De Lara Guarch, Pablo wrote:
> > From: "De Lara Guarch, Pablo" <pablo.de.lara.guarch@intel.com>
> >
> > Fixes following error on gcc 4.4.7:
> >
> > make: Entering directory `/tmp/dpdk-tmp/examples/vhost'
> >   CC main.o
> > cc1: warnings being treated as errors
> > /tmp/dpdk-tmp/examples/vhost/main.c: In function ‘new_device’:
> > /tmp/dpdk-tmp/x86_64-native-linuxapp-gcc/include/rte_ring.h:740: error:
> >     dereferencing pointer ‘mbuf.486’ does break strict-aliasing rules
> > /tmp/dpdk-tmp/examples/vhost/main.c:1503: note: initialized from here
> > ...
> > /tmp/dpdk-tmp/examples/vhost/main.c:1503: note: initialized from here
> > /tmp/dpdk-tmp/x86_64-native-linuxapp-gcc/include/rte_ring.h:740: error:
> >     dereferencing pointer ‘({anonymous})’ does break strict-aliasing rules
> > /tmp/dpdk-tmp/examples/vhost/main.c:1804: note: initialized from here
> > make[1]: *** [main.o] Error 1
> >
> > Fixes: d19533e8 ("examples/vhost: copy old vhost example")
> >
> > Reported-by: Qian Xu <qian.q.xu@intel.com>
> > Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> Acked-by: Huawei Xie <huawei.xie@intel.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2015-12-09 20:55 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-08 11:23 [PATCH] examples/vhost: fix strict aliasing error on gcc 4.4.7 Pablo de Lara
2015-12-09  9:12 ` Xie, Huawei
2015-12-09  9:39 ` [PATCH v2] " Pablo de Lara
2015-12-09 10:32   ` Bruce Richardson
2015-12-09 10:45   ` Xie, Huawei
2015-12-09 10:52     ` De Lara Guarch, Pablo
2015-12-09 11:09   ` [PATCH v3] " Pablo de Lara
2015-12-09 12:20     ` [PATCH v4] Fixes following error on gcc 4.4.7: Pablo de Lara
2015-12-09 13:28       ` Xie, Huawei
2015-12-09 14:01         ` De Lara Guarch, Pablo
2015-12-09 14:12           ` Xie, Huawei
2015-12-09 14:26       ` [PATCH v5] examples/vhost: fix strict aliasing error on gcc 4.4.7 Pablo de Lara
2015-12-09 14:33         ` Xie, Huawei
2015-12-09 20:54           ` Thomas Monjalon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.