Received: from eggs.gnu.org ([2001:4830:134:3::10]:54679) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1NR2-00060X-VQ for qemu-devel@nongnu.org; Mon, 31 Oct 2016 21:00:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1NQz-0002nZ-2x for qemu-devel@nongnu.org; Mon, 31 Oct 2016 21:00:17 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:33463 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c1NQy-0002nR-Sn for qemu-devel@nongnu.org; Mon, 31 Oct 2016 21:00:13 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id uA10wqSH028676 for ; Mon, 31 Oct 2016 21:00:12 -0400 Received: from e19.ny.us.ibm.com (e19.ny.us.ibm.com [129.33.205.209]) by mx0a-001b2d01.pphosted.com with ESMTP id 26eg9csnvv-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 31 Oct 2016 21:00:12 -0400 Received: from localhost by e19.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 31 Oct 2016 21:00:11 -0400 From: Michael Roth Date: Mon, 31 Oct 2016 19:59:48 -0500 In-Reply-To: <1477961990-20899-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1477961990-20899-1-git-send-email-mdroth@linux.vnet.ibm.com> Message-Id: <1477961990-20899-4-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PULL for-2.8 3/5] qga: drop unnecessary GA_CHANNEL_UNIX_LISTEN checks List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, Stefan Hajnoczi From: Stefan Hajnoczi Throughout the code there are c->listen_channel checks which manage the listen socket file descriptor (waiting for accept(2), closing the file descriptor, etc). These checks are currently preceded by explicit c->method == GA_CHANNEL_UNIX_LISTEN checks. Explicit GA_CHANNEL_UNIX_LISTEN checks are not necessary since serial channel types do not create the listen channel (c->listen_channel). As more listen channel types are added, explicitly checking all of them becomes messy. Rely on c->listen_channel to determine whether or not a listen socket file descriptor is used. Signed-off-by: Stefan Hajnoczi Reviewed-by: Michael Roth Signed-off-by: Michael Roth --- qga/channel-posix.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/qga/channel-posix.c b/qga/channel-posix.c index bf32158..579891d 100644 --- a/qga/channel-posix.c +++ b/qga/channel-posix.c @@ -61,7 +61,6 @@ static void ga_channel_listen_add(GAChannel *c, int listen_fd, bool create) static void ga_channel_listen_close(GAChannel *c) { - g_assert(c->method == GA_CHANNEL_UNIX_LISTEN); g_assert(c->listen_channel); g_io_channel_shutdown(c->listen_channel, true, NULL); g_io_channel_unref(c->listen_channel); @@ -77,7 +76,7 @@ static void ga_channel_client_close(GAChannel *c) g_io_channel_shutdown(c->client_channel, true, NULL); g_io_channel_unref(c->client_channel); c->client_channel = NULL; - if (c->method == GA_CHANNEL_UNIX_LISTEN && c->listen_channel) { + if (c->listen_channel) { ga_channel_listen_add(c, 0, false); } } @@ -255,8 +254,7 @@ GAChannel *ga_channel_new(GAChannelMethod method, const gchar *path, void ga_channel_free(GAChannel *c) { - if (c->method == GA_CHANNEL_UNIX_LISTEN - && c->listen_channel) { + if (c->listen_channel) { ga_channel_listen_close(c); } if (c->client_channel) { -- 1.9.1