All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Dr . David Alan Gilbert" <dgilbert@redhat.com>
Subject: [Qemu-devel] [PATCH v2 15/15] monitor: Simplify how -device/device_add print help
Date: Thu, 11 Apr 2019 16:52:56 +0200	[thread overview]
Message-ID: <20190411145256.8614-16-armbru@redhat.com> (raw)
In-Reply-To: <20190411145256.8614-1-armbru@redhat.com>

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 <dgilbert@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
 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

  parent reply	other threads:[~2019-04-11 14:53 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-11 14:52 [Qemu-devel] [PATCH v2 00/15] Clean up use of error_printf() Markus Armbruster
2019-04-11 14:52 ` [Qemu-devel] [PATCH v2 01/15] qemu-img: Use error_vreport() in error_exit() Markus Armbruster
2019-04-11 14:52   ` Markus Armbruster
2019-04-11 14:52 ` [Qemu-devel] [PATCH v2 02/15] block/ssh: Do not report read/write/flush errors to the user Markus Armbruster
2019-04-11 14:52   ` Markus Armbruster
2019-04-11 14:52 ` [Qemu-devel] [PATCH v2 03/15] char-pty: Drop "char device redirected to" message Markus Armbruster
2019-04-11 15:22   ` Paolo Bonzini
2019-04-11 15:37     ` Markus Armbruster
2019-04-11 15:37       ` Markus Armbruster
2019-04-17 18:09       ` Markus Armbruster
2019-04-17 18:09         ` Markus Armbruster
2019-04-11 15:23   ` Peter Krempa
2019-04-11 15:23     ` Peter Krempa
2019-04-11 14:52 ` [Qemu-devel] [PATCH v2 04/15] loader-fit: Wean off error_printf() Markus Armbruster
2019-04-11 14:52   ` Markus Armbruster
2019-04-11 14:52 ` [Qemu-devel] [PATCH v2 05/15] mips/boston: Report errors with error_report(), not error_printf() Markus Armbruster
2019-04-11 14:52   ` Markus Armbruster
2019-04-11 14:52 ` [Qemu-devel] [PATCH v2 06/15] pci: Report fatal " Markus Armbruster
2019-04-11 14:52   ` Markus Armbruster
2019-04-11 14:52 ` [Qemu-devel] [PATCH v2 07/15] hpet: Report warnings with warn_report(), " Markus Armbruster
2019-04-11 14:52   ` Markus Armbruster
2019-04-11 14:52 ` [Qemu-devel] [PATCH v2 08/15] vfio: " Markus Armbruster
2019-04-11 14:52 ` [Qemu-devel] [PATCH v2 09/15] s390x/kvm: " Markus Armbruster
2019-04-11 14:52 ` [Qemu-devel] [PATCH v2 10/15] vl: Make -machine $TYPE, help and -accel help print to stdout Markus Armbruster
2019-04-11 14:52 ` [Qemu-devel] [PATCH v2 11/15] monitor error: Make printf()-like functions return a value Markus Armbruster
2019-04-11 14:52 ` [Qemu-devel] [PATCH v2 12/15] qemu-print: New qemu_printf(), qemu_vprintf() etc Markus Armbruster
2019-04-11 14:52 ` [Qemu-devel] [PATCH v2 13/15] blockdev: Make -drive format=help print to stdout Markus Armbruster
2019-04-11 14:52   ` Markus Armbruster
2019-04-11 14:52 ` [Qemu-devel] [PATCH v2 14/15] char: Make -chardev help " Markus Armbruster
2019-04-11 14:52 ` Markus Armbruster [this message]
2019-04-17 18:11 ` [Qemu-devel] [PATCH v2 14.5/15] char-pty: Print "char device redirected" message " Markus Armbruster
2019-04-17 18:21   ` no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190411145256.8614-16-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.