[dpdk-dev] test whether file descriptor is valid before close it
Commit Message
This avoids closing -1 in our case.
Signed-off-by: Huawei Xie <huawei.xie@intel.com>
---
lib/librte_vhost/virtio-net.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
Comments
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Huawei Xie
> Sent: Friday, March 6, 2015 7:06 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH] test whether file descriptor is valid before close
> it
>
> This avoids closing -1 in our case.
>
> Signed-off-by: Huawei Xie <huawei.xie@intel.com>
Acked-by: Changchun Ouyang <changchun.ouyang@intel.com>
On 2015/03/06 20:05, Huawei Xie wrote:
> This avoids closing -1 in our case.
>
> Signed-off-by: Huawei Xie <huawei.xie@intel.com>
> ---
> lib/librte_vhost/virtio-net.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c
> index 6917fcf..4672e67 100644
> --- a/lib/librte_vhost/virtio-net.c
> +++ b/lib/librte_vhost/virtio-net.c
> @@ -185,13 +185,13 @@ cleanup_device(struct virtio_net *dev)
> }
>
> /* Close any event notifiers opened by device. */
> - if (dev->virtqueue[VIRTIO_RXQ]->callfd)
> + if ((int)dev->virtqueue[VIRTIO_RXQ]->callfd >= 0)
> close((int)dev->virtqueue[VIRTIO_RXQ]->callfd);
> - if (dev->virtqueue[VIRTIO_RXQ]->kickfd)
> + if ((int)dev->virtqueue[VIRTIO_RXQ]->kickfd >= 0)
> close((int)dev->virtqueue[VIRTIO_RXQ]->kickfd);
> - if (dev->virtqueue[VIRTIO_TXQ]->callfd)
> + if ((int)dev->virtqueue[VIRTIO_TXQ]->callfd >= 0)
> close((int)dev->virtqueue[VIRTIO_TXQ]->callfd);
> - if (dev->virtqueue[VIRTIO_TXQ]->kickfd)
> + if ((int)dev->virtqueue[VIRTIO_TXQ]->kickfd >= 0)
> close((int)dev->virtqueue[VIRTIO_TXQ]->kickfd);
> }
>
Acked-by: Tetsuya Mukawa <mukawa@igel.co.jp>
> > This avoids closing -1 in our case.
> >
> > Signed-off-by: Huawei Xie <huawei.xie@intel.com>
>
> Acked-by: Changchun Ouyang <changchun.ouyang@intel.com>
Applied, thanks
@@ -185,13 +185,13 @@ cleanup_device(struct virtio_net *dev)
}
/* Close any event notifiers opened by device. */
- if (dev->virtqueue[VIRTIO_RXQ]->callfd)
+ if ((int)dev->virtqueue[VIRTIO_RXQ]->callfd >= 0)
close((int)dev->virtqueue[VIRTIO_RXQ]->callfd);
- if (dev->virtqueue[VIRTIO_RXQ]->kickfd)
+ if ((int)dev->virtqueue[VIRTIO_RXQ]->kickfd >= 0)
close((int)dev->virtqueue[VIRTIO_RXQ]->kickfd);
- if (dev->virtqueue[VIRTIO_TXQ]->callfd)
+ if ((int)dev->virtqueue[VIRTIO_TXQ]->callfd >= 0)
close((int)dev->virtqueue[VIRTIO_TXQ]->callfd);
- if (dev->virtqueue[VIRTIO_TXQ]->kickfd)
+ if ((int)dev->virtqueue[VIRTIO_TXQ]->kickfd >= 0)
close((int)dev->virtqueue[VIRTIO_TXQ]->kickfd);
}