[PATCH v1 06/15] monitor: expose monitor_puts to rest of code

Alex Bennée posted 15 patches 3 years, 10 months ago
Maintainers: Richard Henderson <richard.henderson@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>, Alexandre Iooss <erdnaxe@crans.org>, Mahmoud Mandour <ma.mandourr@gmail.com>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, Markus Armbruster <armbru@redhat.com>, Cleber Rosa <crosa@redhat.com>, "Philippe Mathieu-Daudé" <f4bug@amsat.org>, Wainer dos Santos Moschetta <wainersm@redhat.com>, Beraldo Leal <bleal@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, Stefan Hajnoczi <stefanha@redhat.com>
[PATCH v1 06/15] monitor: expose monitor_puts to rest of code
Posted by Alex Bennée 3 years, 10 months ago
This helps us construct strings elsewhere before echoing to the
monitor. It avoids having to jump through hoops like:

  monitor_printf(mon, "%s", s->str);

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 include/monitor/monitor.h  | 1 +
 monitor/monitor-internal.h | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
index cc4cc6c6ad..8e291a2588 100644
--- a/include/monitor/monitor.h
+++ b/include/monitor/monitor.h
@@ -31,6 +31,7 @@ void monitor_resume(Monitor *mon);
 int monitor_get_fd(Monitor *mon, const char *fdname, Error **errp);
 int monitor_fd_param(Monitor *mon, const char *fdname, Error **errp);
 
+int monitor_puts(Monitor *mon, const char *str);
 int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap)
     G_GNUC_PRINTF(2, 0);
 int monitor_printf(Monitor *mon, const char *fmt, ...) G_GNUC_PRINTF(2, 3);
diff --git a/monitor/monitor-internal.h b/monitor/monitor-internal.h
index caa2e90ef2..a2cdbbf646 100644
--- a/monitor/monitor-internal.h
+++ b/monitor/monitor-internal.h
@@ -174,7 +174,6 @@ extern int mon_refcount;
 
 extern HMPCommand hmp_cmds[];
 
-int monitor_puts(Monitor *mon, const char *str);
 void monitor_data_init(Monitor *mon, bool is_qmp, bool skip_flush,
                        bool use_io_thread);
 void monitor_data_destroy(Monitor *mon);
-- 
2.30.2


Re: [PATCH v1 06/15] monitor: expose monitor_puts to rest of code
Posted by Markus Armbruster 3 years, 9 months ago
Alex Bennée <alex.bennee@linaro.org> writes:

> This helps us construct strings elsewhere before echoing to the
> monitor. It avoids having to jump through hoops like:
>
>   monitor_printf(mon, "%s", s->str);
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

There's just one caller other than monitor_vprintf().  Even if you add a
few more, I'm not sure keeping it in the interface is worthwhile.

If we conclude it is, then this patch should come with a conversion of
existing uses of monitor_printf(MON, "%s", STR) to monitor_puts(MON,
STR).

If we conclude it isn't, switch the lone caller to monitor_printf() and
make monitor_puts() static in monitor.c.
Re: [PATCH v1 06/15] monitor: expose monitor_puts to rest of code
Posted by Richard Henderson 3 years, 10 months ago
On 4/8/22 09:47, Alex Bennée wrote:
> This helps us construct strings elsewhere before echoing to the
> monitor. It avoids having to jump through hoops like:
> 
>    monitor_printf(mon, "%s", s->str);
> 
> Signed-off-by: Alex Bennée<alex.bennee@linaro.org>
> ---
>   include/monitor/monitor.h  | 1 +
>   monitor/monitor-internal.h | 1 -
>   2 files changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~