From patchwork Sat Jun 22 09:24:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 253402 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C6C5B2C0415 for ; Sat, 22 Jun 2013 19:30:47 +1000 (EST) Received: from localhost ([::1]:36580 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UqK9d-0008So-Tb for incoming@patchwork.ozlabs.org; Sat, 22 Jun 2013 05:30:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49773) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UqK6X-0003rV-Sl for qemu-devel@nongnu.org; Sat, 22 Jun 2013 05:27:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UqK6V-0006BC-8h for qemu-devel@nongnu.org; Sat, 22 Jun 2013 05:27:33 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:34318) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UqK6V-0006Al-0L for qemu-devel@nongnu.org; Sat, 22 Jun 2013 05:27:31 -0400 Received: from gandalf.tls.msk.ru (mjt.vpn.tls.msk.ru [192.168.177.99]) by isrv.corpit.ru (Postfix) with ESMTP id 5A07041E5D; Sat, 22 Jun 2013 13:27:30 +0400 (MSK) Received: by gandalf.tls.msk.ru (Postfix, from userid 1000) id F2018569; Sat, 22 Jun 2013 13:24:39 +0400 (MSK) From: Michael Tokarev To: Anthony Liguori Date: Sat, 22 Jun 2013 13:24:32 +0400 Message-Id: <1371893076-9643-14-git-send-email-mjt@msgid.tls.msk.ru> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1371893076-9643-1-git-send-email-mjt@msgid.tls.msk.ru> References: <1371893076-9643-1-git-send-email-mjt@msgid.tls.msk.ru> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 86.62.121.231 Cc: Michael Tokarev , qemu-devel@nongnu.org, liguang Subject: [Qemu-devel] [PULL 13/17] qemu-char: use bool in qemu_chr_open_socket and simplify code a bit X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: liguang Local variables is_* should be bool by usage. While at it, simplify the logic/code a bit. Signed-off-by: liguang Signed-off-by: Michael Tokarev --- qemu-char.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index 2c3cfe6..a030e6b 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -2679,19 +2679,12 @@ static CharDriverState *qemu_chr_open_socket(QemuOpts *opts) CharDriverState *chr = NULL; Error *local_err = NULL; int fd = -1; - int is_listen; - int is_waitconnect; - int do_nodelay; - int is_unix; - int is_telnet; - - is_listen = qemu_opt_get_bool(opts, "server", 0); - is_waitconnect = qemu_opt_get_bool(opts, "wait", 1); - is_telnet = qemu_opt_get_bool(opts, "telnet", 0); - do_nodelay = !qemu_opt_get_bool(opts, "delay", 1); - is_unix = qemu_opt_get(opts, "path") != NULL; - if (!is_listen) - is_waitconnect = 0; + + bool is_listen = qemu_opt_get_bool(opts, "server", false); + bool is_waitconnect = is_listen && qemu_opt_get_bool(opts, "wait", true); + bool is_telnet = qemu_opt_get_bool(opts, "telnet", false); + bool do_nodelay = !qemu_opt_get_bool(opts, "delay", true); + bool is_unix = qemu_opt_get(opts, "path") != NULL; if (is_unix) { if (is_listen) {