From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1UpDkx-000181-Ms for mharc-qemu-trivial@gnu.org; Wed, 19 Jun 2013 04:28:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43624) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UpDku-000131-LO for qemu-trivial@nongnu.org; Wed, 19 Jun 2013 04:28:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UpDks-0005at-RC for qemu-trivial@nongnu.org; Wed, 19 Jun 2013 04:28:40 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:37595) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UpDko-0005ZE-N2; Wed, 19 Jun 2013 04:28:35 -0400 Received: from [192.168.88.2] (mjt.vpn.tls.msk.ru [192.168.177.99]) by isrv.corpit.ru (Postfix) with ESMTP id 189D141974; Wed, 19 Jun 2013 12:28:33 +0400 (MSK) Message-ID: <51C16BB0.7070206@msgid.tls.msk.ru> Date: Wed, 19 Jun 2013 12:28:32 +0400 From: Michael Tokarev Organization: Telecom Service, JSC User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:17.0) Gecko/17.0 Icedove/17.0 MIME-Version: 1.0 To: liguang References: <1371527137-16949-1-git-send-email-lig.fnst@cn.fujitsu.com> <1371527137-16949-3-git-send-email-lig.fnst@cn.fujitsu.com> In-Reply-To: <1371527137-16949-3-git-send-email-lig.fnst@cn.fujitsu.com> X-Enigmail-Version: 1.5.1 OpenPGP: id=804465C5 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 86.62.121.231 Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org Subject: Re: [Qemu-trivial] [PATCH v2 3/5] qemu-char: use bool in qemu_chr_open_socket X-BeenThere: qemu-trivial@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Jun 2013 08:28:42 -0000 18.06.2013 07:45, liguang wrote: > local variables is_* should be bool by usage, > and last parameter of qemu_opt_get_bool is bool, > so pass true/false for it. > > Signed-off-by: liguang > --- > qemu-char.c | 20 ++++++++++---------- > 1 files changed, 10 insertions(+), 10 deletions(-) > > diff --git a/qemu-char.c b/qemu-char.c > index 2c3cfe6..0d695e0 100644 > --- a/qemu-char.c > +++ b/qemu-char.c > @@ -2679,16 +2679,16 @@ 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); > + bool is_listen; > + bool is_waitconnect; > + bool do_nodelay; > + bool is_unix; > + bool is_telnet; > + > + is_listen = qemu_opt_get_bool(opts, "server", false); > + is_waitconnect = qemu_opt_get_bool(opts, "wait", true); > + is_telnet = qemu_opt_get_bool(opts, "telnet", false); > + do_nodelay = !qemu_opt_get_bool(opts, "delay", true); > is_unix = qemu_opt_get(opts, "path") != NULL; > if (!is_listen) > is_waitconnect = 0; So is is_waitconnect a booleand or integer? :) How about this (I'm unsure about the author anymore ): commit c5b775f85f5049d7315b8f8643a65ea1cc7107eb Author: liguang Date: Tue Jun 18 11:45:35 2013 +0800 qemu-char: use bool in qemu_chr_open_socket and simplify code a bit 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 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) { From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43588) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UpDkr-00012S-0N for qemu-devel@nongnu.org; Wed, 19 Jun 2013 04:28:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UpDkp-0005ZU-3T for qemu-devel@nongnu.org; Wed, 19 Jun 2013 04:28:36 -0400 Message-ID: <51C16BB0.7070206@msgid.tls.msk.ru> Date: Wed, 19 Jun 2013 12:28:32 +0400 From: Michael Tokarev MIME-Version: 1.0 References: <1371527137-16949-1-git-send-email-lig.fnst@cn.fujitsu.com> <1371527137-16949-3-git-send-email-lig.fnst@cn.fujitsu.com> In-Reply-To: <1371527137-16949-3-git-send-email-lig.fnst@cn.fujitsu.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [Qemu-trivial] [PATCH v2 3/5] qemu-char: use bool in qemu_chr_open_socket List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: liguang Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org 18.06.2013 07:45, liguang wrote: > local variables is_* should be bool by usage, > and last parameter of qemu_opt_get_bool is bool, > so pass true/false for it. > > Signed-off-by: liguang > --- > qemu-char.c | 20 ++++++++++---------- > 1 files changed, 10 insertions(+), 10 deletions(-) > > diff --git a/qemu-char.c b/qemu-char.c > index 2c3cfe6..0d695e0 100644 > --- a/qemu-char.c > +++ b/qemu-char.c > @@ -2679,16 +2679,16 @@ 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); > + bool is_listen; > + bool is_waitconnect; > + bool do_nodelay; > + bool is_unix; > + bool is_telnet; > + > + is_listen = qemu_opt_get_bool(opts, "server", false); > + is_waitconnect = qemu_opt_get_bool(opts, "wait", true); > + is_telnet = qemu_opt_get_bool(opts, "telnet", false); > + do_nodelay = !qemu_opt_get_bool(opts, "delay", true); > is_unix = qemu_opt_get(opts, "path") != NULL; > if (!is_listen) > is_waitconnect = 0; So is is_waitconnect a booleand or integer? :) How about this (I'm unsure about the author anymore ): commit c5b775f85f5049d7315b8f8643a65ea1cc7107eb Author: liguang Date: Tue Jun 18 11:45:35 2013 +0800 qemu-char: use bool in qemu_chr_open_socket and simplify code a bit 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 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) {