From 092f1c2c77d1818a2534578379bd439699cc2296 Mon Sep 17 00:00:00 2001 From: Yuanhan Liu Date: Fri, 29 Apr 2016 11:48:08 +0800 Subject: [PATCH] vhost: declare backend with int type It's an fd; so define it as "int", which could also save the unncessary (int) case. Signed-off-by: Yuanhan Liu Tested-by: Rich Lane Acked-by: Rich Lane --- lib/librte_vhost/rte_virtio_net.h | 2 +- lib/librte_vhost/virtio-net.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/librte_vhost/rte_virtio_net.h b/lib/librte_vhost/rte_virtio_net.h index 600b20b406..4d25f7916b 100644 --- a/lib/librte_vhost/rte_virtio_net.h +++ b/lib/librte_vhost/rte_virtio_net.h @@ -85,7 +85,7 @@ struct vhost_virtqueue { struct vring_avail *avail; /**< Virtqueue available ring. */ struct vring_used *used; /**< Virtqueue used ring. */ uint32_t size; /**< Size of descriptor ring. */ - uint32_t backend; /**< Backend value to determine if device should started/stopped. */ + int backend; /**< Backend value to determine if device should started/stopped. */ uint16_t vhost_hlen; /**< Vhost header length (varies depending on RX merge buffers. */ volatile uint16_t last_used_idx; /**< Last index used on the available ring */ volatile uint16_t last_used_idx_res; /**< Used for multiple devices reserving buffers. */ diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c index f4695afd48..1a6259bd04 100644 --- a/lib/librte_vhost/virtio-net.c +++ b/lib/librte_vhost/virtio-net.c @@ -717,8 +717,8 @@ vhost_set_backend(struct vhost_device_ctx ctx, struct vhost_vring_file *file) * we add the device. */ if (!(dev->flags & VIRTIO_DEV_RUNNING)) { - if (((int)dev->virtqueue[VIRTIO_TXQ]->backend != VIRTIO_DEV_STOPPED) && - ((int)dev->virtqueue[VIRTIO_RXQ]->backend != VIRTIO_DEV_STOPPED)) { + if (dev->virtqueue[VIRTIO_TXQ]->backend != VIRTIO_DEV_STOPPED && + dev->virtqueue[VIRTIO_RXQ]->backend != VIRTIO_DEV_STOPPED) { return notify_ops->new_device(dev); } /* Otherwise we remove it. */ -- 2.20.1