qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [Qemu-trivial] [PATCH v2 3/5] qemu-char: use bool in qe


From: Michael Tokarev
Subject: Re: [Qemu-devel] [Qemu-trivial] [PATCH v2 3/5] qemu-char: use bool in qemu_chr_open_socket
Date: Wed, 19 Jun 2013 12:28:32 +0400
User-agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:17.0) Gecko/17.0 Icedove/17.0

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 <address@hidden>
> ---
>  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 <address@hidden>
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 <address@hidden>
    Signed-off-by: Michael Tokarev <address@hidden>

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) {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]