From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:59333) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hDvgC-0002gm-7r for qemu-devel@nongnu.org; Tue, 09 Apr 2019 14:41:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hDvgB-00021d-3p for qemu-devel@nongnu.org; Tue, 09 Apr 2019 14:41:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39284) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hDvgA-00020O-Ow for qemu-devel@nongnu.org; Tue, 09 Apr 2019 14:41:07 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3786C3078AB5 for ; Tue, 9 Apr 2019 18:41:05 +0000 (UTC) Date: Tue, 9 Apr 2019 19:41:02 +0100 From: "Dr. David Alan Gilbert" Message-ID: <20190409184101.GF2964@work-vm> References: <20190408083627.7479-1-armbru@redhat.com> <20190408083627.7479-16-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190408083627.7479-16-armbru@redhat.com> Subject: Re: [Qemu-devel] [PATCH 15/15] monitor: Simplify how -device/device_add print help List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org * Markus Armbruster (armbru@redhat.com) wrote: > Commit a95db58f210 added monitor_vfprintf() as an error_printf() > generalized from stderr to arbitrary streams, then used it wrapped in > helper out_printf() to print -device/device_add help to stdout. Use > qemu_printf() instead, and delete monitor_vfprintf() and out_printf(). > > Cc: Dr. David Alan Gilbert > Signed-off-by: Markus Armbruster (the 'monitor_vprintf vs monitor_vfprintf took a minute to notice) Reviewed-by: Dr. David Alan Gilbert > --- > include/monitor/monitor.h | 3 --- > monitor.c | 16 ++++------------ > qdev-monitor.c | 36 ++++++++++++++---------------------- > 3 files changed, 18 insertions(+), 37 deletions(-) > > diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h > index e4c3717454..316a168c41 100644 > --- a/include/monitor/monitor.h > +++ b/include/monitor/monitor.h > @@ -48,7 +48,4 @@ int monitor_fdset_dup_fd_add(int64_t fdset_id, int dup_fd); > void monitor_fdset_dup_fd_remove(int dup_fd); > int monitor_fdset_dup_fd_find(int dup_fd); > > -int monitor_vfprintf(FILE *stream, > - const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0); > - > #endif /* MONITOR_H */ > diff --git a/monitor.c b/monitor.c > index 7b4a78d798..10be8bdb86 100644 > --- a/monitor.c > +++ b/monitor.c > @@ -4541,23 +4541,15 @@ static void monitor_readline_flush(void *opaque) > monitor_flush(opaque); > } > > -/* > - * Print to current monitor if we have one, else to stream. > - */ > -int monitor_vfprintf(FILE *stream, const char *fmt, va_list ap) > -{ > - if (cur_mon && !monitor_cur_is_qmp()) { > - return monitor_vprintf(cur_mon, fmt, ap); > - } > - return vfprintf(stream, fmt, ap); > -} > - > /* > * Print to current monitor if we have one, else to stderr. > */ > int error_vprintf(const char *fmt, va_list ap) > { > - return monitor_vfprintf(stderr, fmt, ap); > + if (cur_mon && !monitor_cur_is_qmp()) { > + return monitor_vprintf(cur_mon, fmt, ap); > + } > + return vfprintf(stderr, fmt, ap); > } > > int error_vprintf_unless_qmp(const char *fmt, va_list ap) > diff --git a/qdev-monitor.c b/qdev-monitor.c > index d4320986a2..373b9ad445 100644 > --- a/qdev-monitor.c > +++ b/qdev-monitor.c > @@ -31,6 +31,7 @@ > #include "qemu/error-report.h" > #include "qemu/help_option.h" > #include "qemu/option.h" > +#include "qemu/qemu-print.h" > #include "sysemu/block-backend.h" > #include "migration/misc.h" > > @@ -104,31 +105,22 @@ static bool qdev_class_has_alias(DeviceClass *dc) > return (qdev_class_get_alias(dc) != NULL); > } > > -static void out_printf(const char *fmt, ...) > -{ > - va_list ap; > - > - va_start(ap, fmt); > - monitor_vfprintf(stdout, fmt, ap); > - va_end(ap); > -} > - > static void qdev_print_devinfo(DeviceClass *dc) > { > - out_printf("name \"%s\"", object_class_get_name(OBJECT_CLASS(dc))); > + qemu_printf("name \"%s\"", object_class_get_name(OBJECT_CLASS(dc))); > if (dc->bus_type) { > - out_printf(", bus %s", dc->bus_type); > + qemu_printf(", bus %s", dc->bus_type); > } > if (qdev_class_has_alias(dc)) { > - out_printf(", alias \"%s\"", qdev_class_get_alias(dc)); > + qemu_printf(", alias \"%s\"", qdev_class_get_alias(dc)); > } > if (dc->desc) { > - out_printf(", desc \"%s\"", dc->desc); > + qemu_printf(", desc \"%s\"", dc->desc); > } > if (!dc->user_creatable) { > - out_printf(", no-user"); > + qemu_printf(", no-user"); > } > - out_printf("\n"); > + qemu_printf("\n"); > } > > static void qdev_print_devinfos(bool show_no_user) > @@ -164,7 +156,7 @@ static void qdev_print_devinfos(bool show_no_user) > continue; > } > if (!cat_printed) { > - out_printf("%s%s devices:\n", i ? "\n" : "", cat_name[i]); > + qemu_printf("%s%s devices:\n", i ? "\n" : "", cat_name[i]); > cat_printed = true; > } > qdev_print_devinfo(dc); > @@ -286,20 +278,20 @@ int qdev_device_help(QemuOpts *opts) > } > > if (prop_list) { > - out_printf("%s options:\n", driver); > + qemu_printf("%s options:\n", driver); > } else { > - out_printf("There are no options for %s.\n", driver); > + qemu_printf("There are no options for %s.\n", driver); > } > for (prop = prop_list; prop; prop = prop->next) { > int len; > - out_printf(" %s=<%s>%n", prop->value->name, prop->value->type, &len); > + qemu_printf(" %s=<%s>%n", prop->value->name, prop->value->type, &len); > if (prop->value->has_description) { > if (len < 24) { > - out_printf("%*s", 24 - len, ""); > + qemu_printf("%*s", 24 - len, ""); > } > - out_printf(" - %s\n", prop->value->description); > + qemu_printf(" - %s\n", prop->value->description); > } else { > - out_printf("\n"); > + qemu_printf("\n"); > } > } > > -- > 2.17.2 > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.4 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,T_HK_NAME_DR, USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77A7EC10F0E for ; Tue, 9 Apr 2019 18:41:57 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 30E0820883 for ; Tue, 9 Apr 2019 18:41:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 30E0820883 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([127.0.0.1]:47595 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hDvgy-0002zY-DP for qemu-devel@archiver.kernel.org; Tue, 09 Apr 2019 14:41:56 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59333) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hDvgC-0002gm-7r for qemu-devel@nongnu.org; Tue, 09 Apr 2019 14:41:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hDvgB-00021d-3p for qemu-devel@nongnu.org; Tue, 09 Apr 2019 14:41:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39284) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hDvgA-00020O-Ow for qemu-devel@nongnu.org; Tue, 09 Apr 2019 14:41:07 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3786C3078AB5 for ; Tue, 9 Apr 2019 18:41:05 +0000 (UTC) Received: from work-vm (ovpn-117-233.ams2.redhat.com [10.36.117.233]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8168F600CD; Tue, 9 Apr 2019 18:41:04 +0000 (UTC) Date: Tue, 9 Apr 2019 19:41:02 +0100 From: "Dr. David Alan Gilbert" To: Markus Armbruster Message-ID: <20190409184101.GF2964@work-vm> References: <20190408083627.7479-1-armbru@redhat.com> <20190408083627.7479-16-armbru@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline In-Reply-To: <20190408083627.7479-16-armbru@redhat.com> User-Agent: Mutt/1.11.4 (2019-03-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 09 Apr 2019 18:41:05 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: Re: [Qemu-devel] [PATCH 15/15] monitor: Simplify how -device/device_add print help X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Message-ID: <20190409184102.K7sjDfefZiPnvohvsMTi6z4CipkgP8uAZMhB3jclE54@z> * Markus Armbruster (armbru@redhat.com) wrote: > Commit a95db58f210 added monitor_vfprintf() as an error_printf() > generalized from stderr to arbitrary streams, then used it wrapped in > helper out_printf() to print -device/device_add help to stdout. Use > qemu_printf() instead, and delete monitor_vfprintf() and out_printf(). > > Cc: Dr. David Alan Gilbert > Signed-off-by: Markus Armbruster (the 'monitor_vprintf vs monitor_vfprintf took a minute to notice) Reviewed-by: Dr. David Alan Gilbert > --- > include/monitor/monitor.h | 3 --- > monitor.c | 16 ++++------------ > qdev-monitor.c | 36 ++++++++++++++---------------------- > 3 files changed, 18 insertions(+), 37 deletions(-) > > diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h > index e4c3717454..316a168c41 100644 > --- a/include/monitor/monitor.h > +++ b/include/monitor/monitor.h > @@ -48,7 +48,4 @@ int monitor_fdset_dup_fd_add(int64_t fdset_id, int dup_fd); > void monitor_fdset_dup_fd_remove(int dup_fd); > int monitor_fdset_dup_fd_find(int dup_fd); > > -int monitor_vfprintf(FILE *stream, > - const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0); > - > #endif /* MONITOR_H */ > diff --git a/monitor.c b/monitor.c > index 7b4a78d798..10be8bdb86 100644 > --- a/monitor.c > +++ b/monitor.c > @@ -4541,23 +4541,15 @@ static void monitor_readline_flush(void *opaque) > monitor_flush(opaque); > } > > -/* > - * Print to current monitor if we have one, else to stream. > - */ > -int monitor_vfprintf(FILE *stream, const char *fmt, va_list ap) > -{ > - if (cur_mon && !monitor_cur_is_qmp()) { > - return monitor_vprintf(cur_mon, fmt, ap); > - } > - return vfprintf(stream, fmt, ap); > -} > - > /* > * Print to current monitor if we have one, else to stderr. > */ > int error_vprintf(const char *fmt, va_list ap) > { > - return monitor_vfprintf(stderr, fmt, ap); > + if (cur_mon && !monitor_cur_is_qmp()) { > + return monitor_vprintf(cur_mon, fmt, ap); > + } > + return vfprintf(stderr, fmt, ap); > } > > int error_vprintf_unless_qmp(const char *fmt, va_list ap) > diff --git a/qdev-monitor.c b/qdev-monitor.c > index d4320986a2..373b9ad445 100644 > --- a/qdev-monitor.c > +++ b/qdev-monitor.c > @@ -31,6 +31,7 @@ > #include "qemu/error-report.h" > #include "qemu/help_option.h" > #include "qemu/option.h" > +#include "qemu/qemu-print.h" > #include "sysemu/block-backend.h" > #include "migration/misc.h" > > @@ -104,31 +105,22 @@ static bool qdev_class_has_alias(DeviceClass *dc) > return (qdev_class_get_alias(dc) != NULL); > } > > -static void out_printf(const char *fmt, ...) > -{ > - va_list ap; > - > - va_start(ap, fmt); > - monitor_vfprintf(stdout, fmt, ap); > - va_end(ap); > -} > - > static void qdev_print_devinfo(DeviceClass *dc) > { > - out_printf("name \"%s\"", object_class_get_name(OBJECT_CLASS(dc))); > + qemu_printf("name \"%s\"", object_class_get_name(OBJECT_CLASS(dc))); > if (dc->bus_type) { > - out_printf(", bus %s", dc->bus_type); > + qemu_printf(", bus %s", dc->bus_type); > } > if (qdev_class_has_alias(dc)) { > - out_printf(", alias \"%s\"", qdev_class_get_alias(dc)); > + qemu_printf(", alias \"%s\"", qdev_class_get_alias(dc)); > } > if (dc->desc) { > - out_printf(", desc \"%s\"", dc->desc); > + qemu_printf(", desc \"%s\"", dc->desc); > } > if (!dc->user_creatable) { > - out_printf(", no-user"); > + qemu_printf(", no-user"); > } > - out_printf("\n"); > + qemu_printf("\n"); > } > > static void qdev_print_devinfos(bool show_no_user) > @@ -164,7 +156,7 @@ static void qdev_print_devinfos(bool show_no_user) > continue; > } > if (!cat_printed) { > - out_printf("%s%s devices:\n", i ? "\n" : "", cat_name[i]); > + qemu_printf("%s%s devices:\n", i ? "\n" : "", cat_name[i]); > cat_printed = true; > } > qdev_print_devinfo(dc); > @@ -286,20 +278,20 @@ int qdev_device_help(QemuOpts *opts) > } > > if (prop_list) { > - out_printf("%s options:\n", driver); > + qemu_printf("%s options:\n", driver); > } else { > - out_printf("There are no options for %s.\n", driver); > + qemu_printf("There are no options for %s.\n", driver); > } > for (prop = prop_list; prop; prop = prop->next) { > int len; > - out_printf(" %s=<%s>%n", prop->value->name, prop->value->type, &len); > + qemu_printf(" %s=<%s>%n", prop->value->name, prop->value->type, &len); > if (prop->value->has_description) { > if (len < 24) { > - out_printf("%*s", 24 - len, ""); > + qemu_printf("%*s", 24 - len, ""); > } > - out_printf(" - %s\n", prop->value->description); > + qemu_printf(" - %s\n", prop->value->description); > } else { > - out_printf("\n"); > + qemu_printf("\n"); > } > } > > -- > 2.17.2 > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK