From patchwork Fri Mar 6 11:05:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huawei Xie X-Patchwork-Id: 3913 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id B20355921; Fri, 6 Mar 2015 12:05:56 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 4E3F85677 for ; Fri, 6 Mar 2015 12:05:55 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP; 06 Mar 2015 03:05:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,352,1422950400"; d="scan'208";a="694850820" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga002.jf.intel.com with ESMTP; 06 Mar 2015 03:05:53 -0800 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id t26B5ppd007637; Fri, 6 Mar 2015 19:05:51 +0800 Received: from shecgisg003.sh.intel.com (localhost [127.0.0.1]) by shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t26B5m27027191; Fri, 6 Mar 2015 19:05:50 +0800 Received: (from hxie5@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id t26B5mPj027187; Fri, 6 Mar 2015 19:05:48 +0800 From: Huawei Xie To: dev@dpdk.org Date: Fri, 6 Mar 2015 19:05:43 +0800 Message-Id: <1425639943-27157-1-git-send-email-huawei.xie@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1425638358-26523-1-git-send-email-huawei.xie@intel.com> References: <1425638358-26523-1-git-send-email-huawei.xie@intel.com> Subject: [dpdk-dev] [PATCH] test whether file descriptor is valid before close it X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list 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" This avoids closing -1 in our case. Signed-off-by: Huawei Xie Acked-by: Changchun Ouyang Acked-by: Tetsuya Mukawa --- 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); }