qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 13/54] char: use error_report()


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH 13/54] char: use error_report()
Date: Wed, 4 Jan 2017 16:04:53 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1

On 12/12/2016 04:42 PM, Marc-André Lureau wrote:
> Prefer error_report() over fprintf(stderr..)
> 
> Signed-off-by: Marc-André Lureau <address@hidden>
> ---
>  qemu-char.c | 27 +++++++++++++++------------
>  1 file changed, 15 insertions(+), 12 deletions(-)
> 
> @@ -4130,17 +4130,20 @@ Chardev *qemu_chr_new_from_opts(QemuOpts *opts,
>      }
>  
>      if (is_help_option(qemu_opt_get(opts, "backend"))) {
> -        fprintf(stderr, "Available chardev backend types:\n");
> +        GString *str = g_string_new("");
>          for (i = 0; i < ARRAY_SIZE(backends); i++) {
>              cd = backends[i];
>              if (cd) {
> -                fprintf(stderr, "%s\n", ChardevBackendKind_lookup[cd->kind]);
> +                g_string_append_printf(str, "\n%s", 
> ChardevBackendKind_lookup[cd->kind]);
>                  if (cd->alias) {
> -                    fprintf(stderr, "%s\n", cd->alias);
> +                    g_string_append_printf(str, "\n%s", cd->alias);
>                  }
>              }
>          }
> -        exit(!is_help_option(qemu_opt_get(opts, "backend")));
> +
> +        error_report("Available chardev backend types: %s", str->str);
> +        g_string_free(str, true);
> +        exit(0);

I suppose the g_string_free() could be elided due to the pending exit(),
but it's fine to keep it for lint purposes.  Nice simplification of the
error status.

>      }
>  
>      if (id == NULL) {
> @@ -4255,8 +4258,8 @@ Chardev *qemu_chr_new(const char *label, const char 
> *filename)
>              qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_REPLAY);
>          }
>          if (qemu_chr_replay(chr) && chr->driver->chr_ioctl) {
> -            fprintf(stderr,
> -                    "Replay: ioctl is not supported for serial devices 
> yet\n");
> +            error_report("Replay: ioctl is not supported "
> +                         "for serial devices yet");
>          }
>          replay_register_char_driver(chr);

Rather gross that we print the message but plow on anyways, but that's
not this patch's problem.

Reviewed-by: Eric Blake <address@hidden>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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