On 12/12/2016 04:42 PM, Marc-André Lureau wrote: > Prefer error_report() over fprintf(stderr..) > > Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com> > --- > 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 <ebl...@redhat.com> -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature