From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55728) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UpSfe-000863-Je for qemu-devel@nongnu.org; Wed, 19 Jun 2013 20:24:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UpSfd-0000si-Jt for qemu-devel@nongnu.org; Wed, 19 Jun 2013 20:24:14 -0400 From: li guang In-Reply-To: <51C16BB0.7070206@msgid.tls.msk.ru> References: <1371527137-16949-1-git-send-email-lig.fnst@cn.fujitsu.com> <1371527137-16949-3-git-send-email-lig.fnst@cn.fujitsu.com> <51C16BB0.7070206@msgid.tls.msk.ru> Date: Thu, 20 Jun 2013 08:21:39 +0800 Message-ID: <1371687699.31705.60.camel@liguang.fnst.cn.fujitsu.com> Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" 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: Michael Tokarev Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org =E5=9C=A8 2013-06-19=E4=B8=89=E7=9A=84 12:28 +0400=EF=BC=8CMichael Tokarev= =E5=86=99=E9=81=93=EF=BC=9A > 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. > >=20 > > Signed-off-by: liguang > > --- > > qemu-char.c | 20 ++++++++++---------- > > 1 files changed, 10 insertions(+), 10 deletions(-) > >=20 > > 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(Qe= muOpts *opts) > > CharDriverState *chr =3D NULL; > > Error *local_err =3D NULL; > > int fd =3D -1; > > - int is_listen; > > - int is_waitconnect; > > - int do_nodelay; > > - int is_unix; > > - int is_telnet; > > - > > - is_listen =3D qemu_opt_get_bool(opts, "server", 0); > > - is_waitconnect =3D qemu_opt_get_bool(opts, "wait", 1); > > - is_telnet =3D qemu_opt_get_bool(opts, "telnet", 0); > > - do_nodelay =3D !qemu_opt_get_bool(opts, "delay", 1); > > + bool is_listen; > > + bool is_waitconnect; > > + bool do_nodelay; > > + bool is_unix; > > + bool is_telnet; > > + > > + is_listen =3D qemu_opt_get_bool(opts, "server", false); > > + is_waitconnect =3D qemu_opt_get_bool(opts, "wait", true); > > + is_telnet =3D qemu_opt_get_bool(opts, "telnet", false); > > + do_nodelay =3D !qemu_opt_get_bool(opts, "delay", true); > > is_unix =3D qemu_opt_get(opts, "path") !=3D NULL; > > if (!is_listen) > > is_waitconnect =3D 0; >=20 > So is is_waitconnect a booleand or integer? :) Oh, I'm so lazy to find more... following is fine for me. Thanks! >=20 > How about this (I'm unsure about the author anymore ): >=20 > commit c5b775f85f5049d7315b8f8643a65ea1cc7107eb > Author: liguang > Date: Tue Jun 18 11:45:35 2013 +0800 >=20 > qemu-char: use bool in qemu_chr_open_socket and simplify code a bit >=20 > Local variables is_* should be bool by usage. > While at it, simplify the logic/code a bit. >=20 > Signed-off-by: liguang > Signed-off-by: Michael Tokarev >=20 > 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(Qemu= Opts *opts) > CharDriverState *chr =3D NULL; > Error *local_err =3D NULL; > int fd =3D -1; > - int is_listen; > - int is_waitconnect; > - int do_nodelay; > - int is_unix; > - int is_telnet; > - > - is_listen =3D qemu_opt_get_bool(opts, "server", 0); > - is_waitconnect =3D qemu_opt_get_bool(opts, "wait", 1); > - is_telnet =3D qemu_opt_get_bool(opts, "telnet", 0); > - do_nodelay =3D !qemu_opt_get_bool(opts, "delay", 1); > - is_unix =3D qemu_opt_get(opts, "path") !=3D NULL; > - if (!is_listen) > - is_waitconnect =3D 0; > + > + bool is_listen =3D qemu_opt_get_bool(opts, "server", false); > + bool is_waitconnect =3D is_listen && qemu_opt_get_bool(opts, "wait",= true); > + bool is_telnet =3D qemu_opt_get_bool(opts, "telnet", false); > + bool do_nodelay =3D !qemu_opt_get_bool(opts, "delay", true); > + bool is_unix =3D qemu_opt_get(opts, "path") !=3D NULL; >=20 > if (is_unix) { > if (is_listen) { >=20