From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49760) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1buyMU-000237-Dg for qemu-devel@nongnu.org; Fri, 14 Oct 2016 05:01:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1buyMS-0006IC-5a for qemu-devel@nongnu.org; Fri, 14 Oct 2016 05:01:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58504) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1buyMR-0006Hz-Vi for qemu-devel@nongnu.org; Fri, 14 Oct 2016 05:01:04 -0400 From: Stefan Hajnoczi Date: Fri, 14 Oct 2016 10:00:54 +0100 Message-Id: <1476435656-3100-3-git-send-email-stefanha@redhat.com> In-Reply-To: <1476435656-3100-1-git-send-email-stefanha@redhat.com> References: <1476435656-3100-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PATCH v2 2/4] 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: Michael Roth , 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 --- 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) { -- 2.7.4