numam-dpdk/lib/vhost
Maxime Coquelin 4226aa9cac vhost: fix build with GCC 12
This patch fixes a compilation issue met with GCC 12 on
LoongArch64:

In function ‘mbuf_to_desc’,
    inlined from ‘vhost_enqueue_async_packed’
    inlined from ‘virtio_dev_rx_async_packed’
    inlined from ‘virtio_dev_rx_async_submit_packed’
lib/vhost/virtio_net.c:1159:18: error:
        ‘buf_vec[0].buf_addr’ may be used uninitialized
 1159 |         buf_addr = buf_vec[vec_idx].buf_addr;
      |         ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
lib/vhost/virtio_net.c: In function ‘virtio_dev_rx_async_submit_packed’:
lib/vhost/virtio_net.c:1834:27: note: ‘buf_vec’ declared here
 1834 |         struct buf_vector buf_vec[BUF_VECTOR_MAX];
      |                           ^~~~~~~

It happens because the compiler assumes that 'size'
variable in vhost_enqueue_async_packed could wrap to 0 since
'size' is uint32_t and pkt->pkt_len too.

In practice, it would never happen since 'pkt->pkt_len' is
unlikely to be close to UINT32_MAX, but let's just change
'size' to uint64_t to make the compiler happy without
having to add runtime checks.

This patch also fixes similar patterns in three other
places, including one that also produces similar build
issue on ARM64 in vhost_enqueue_single_packed().

Fixes: 873e8dad6f ("vhost: support packed ring in async datapath")
Cc: stable@dpdk.org

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
Tested-by: Amit Prakash Shukla <amitprakashs@marvell.com>
2022-10-06 12:18:09 +02:00
..
fd_man.c lib: remove unneeded header includes 2022-02-22 13:10:39 +01:00
fd_man.h lib: remove unneeded header includes 2022-02-22 13:10:39 +01:00
iotlb.c vhost: reduce memory footprint when IOMMU is disabled 2022-09-29 10:13:22 +02:00
iotlb.h vhost: stop using mempool for IOTLB cache 2022-09-15 17:56:24 +02:00
meson.build vhost: integrate dmadev in asynchronous data-path 2022-02-10 15:59:17 +01:00
rte_vdpa.h vhost: add missing C++ guards 2022-02-22 14:47:49 +01:00
rte_vhost_async.h vhost: support clear in-flight packets for async dequeue 2022-06-17 15:19:57 +02:00
rte_vhost_crypto.h cryptodev: rework session framework 2022-10-04 22:04:59 +02:00
rte_vhost.h vhost: remove deprecated helpers 2022-09-29 10:13:22 +02:00
socket.c vhost: reduce memory footprint when IOMMU is disabled 2022-09-29 10:13:22 +02:00
vdpa_driver.h vhost: get vDPA device type 2022-06-01 11:50:10 +02:00
vdpa.c dev: hide device object 2022-09-23 16:14:34 +02:00
version.map vhost: remove deprecated helpers 2022-09-29 10:13:22 +02:00
vhost_crypto.c cryptodev: rework session framework 2022-10-04 22:04:59 +02:00
vhost_user.c vhost: use dedicated variable for message result 2022-09-29 10:13:22 +02:00
vhost_user.h vhost: remove unneeded header includes 2022-06-21 16:46:57 +02:00
vhost.c vhost: reduce memory footprint when IOMMU is disabled 2022-09-29 10:13:22 +02:00
vhost.h vhost: reduce memory footprint when IOMMU is disabled 2022-09-29 10:13:22 +02:00
virtio_crypto.h lib: remove librte_ prefix from directory names 2021-04-21 14:04:09 +02:00
virtio_net.c vhost: fix build with GCC 12 2022-10-06 12:18:09 +02:00