diff mbox

[dpdk-dev] test whether file descriptor is valid before close it

Message ID 1425639943-27157-1-git-send-email-huawei.xie@intel.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Huawei Xie March 6, 2015, 11:05 a.m. UTC
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

Ouyang Changchun March 9, 2015, 1:32 a.m. UTC | #1
> -----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>
Tetsuya Mukawa March 9, 2015, 2:23 a.m. UTC | #2
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>
Thomas Monjalon March 9, 2015, 8:34 a.m. UTC | #3
> > 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
diff mbox

Patch

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);
 }