From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pablo de Lara Subject: [PATCH] examples/vhost: fix strict aliasing error on gcc 4.4.7 Date: Tue, 8 Dec 2015 11:23:55 +0000 Message-ID: <1449573835-149947-1-git-send-email-pablo.de.lara.guarch@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable To: dev@dpdk.org Return-path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 4B9EC69C8 for ; Tue, 8 Dec 2015 12:24:01 +0100 (CET) List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "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 =E2=80=98new_device=E2=80= =99: /tmp/dpdk-tmp/x86_64-native-linuxapp-gcc/include/rte_ring.h:740: error: dereferencing pointer =E2=80=98mbuf.486=E2=80=99 does break strict-al= iasing 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 =E2=80=98({anonymous})=E2=80=99 does break stri= ct-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 Signed-off-by: Pablo de Lara --- 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 =3D NULL; + void *obj =3D NULL; + struct rte_mbuf *mbuf; struct vpool *vpool; hpa_type addr_type; struct vhost_dev *vdev =3D (struct vhost_dev *)dev->priv; @@ -1500,7 +1501,8 @@ attach_rxmbuf_zcp(struct virtio_net *dev) } } while (unlikely(phys_addr =3D=3D 0)); =20 - rte_ring_sc_dequeue(vpool->ring, (void **)&mbuf); + rte_ring_sc_dequeue(vpool->ring, (void **)&obj); + mbuf =3D (struct rte_mbuf *)obj; if (unlikely(mbuf =3D=3D 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; } =20 @@ -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 =3D NULL; + void *obj =3D NULL; + struct rte_mbuf *mbuf; unsigned len, ret, offset =3D 0; struct vpool *vpool; uint16_t vlan_tag =3D (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, =20 /* Allocate an mbuf and populate the structure. */ vpool =3D &vpool_array[MAX_QUEUES + vmdq_rx_q]; - rte_ring_sc_dequeue(vpool->ring, (void **)&mbuf); + rte_ring_sc_dequeue(vpool->ring, (void **)&obj); + mbuf =3D (struct rte_mbuf *) obj; if (unlikely(mbuf =3D=3D NULL)) { struct vhost_virtqueue *vq =3D dev->virtqueue[VIRTIO_TXQ]; RTE_LOG(ERR, VHOST_DATA, --=20 2.5.0