Re: [PATCH v1 01/10] monitor: expose monitor_puts to rest of code

2022-09-22 Thread Kevin Wolf
Am 21.09.2022 um 18:07 hat Alex Bennée geschrieben:
> 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);
> 
> It will be useful in following patches but for now convert all
> existing plain "%s" printfs to use the _puts api.
> 
> Signed-off-by: Alex Bennée 
> Reviewed-by: Richard Henderson 

Reviewed-by: Kevin Wolf 




Re: [PATCH v1 01/10] monitor: expose monitor_puts to rest of code

2022-09-21 Thread Markus Armbruster
Alex Bennée  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);
>
> It will be useful in following patches but for now convert all
> existing plain "%s" printfs to use the _puts api.
>
> Signed-off-by: Alex Bennée 
> Reviewed-by: Richard Henderson 

Reviewed-by: Markus Armbruster 




Re: [PATCH v1 01/10] monitor: expose monitor_puts to rest of code

2022-09-21 Thread Philippe Mathieu-Daudé via

On 21/9/22 18:07, 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);

It will be useful in following patches but for now convert all
existing plain "%s" printfs to use the _puts api.

Signed-off-by: Alex Bennée 
Reviewed-by: Richard Henderson 

---
v2
   - s/monitor_printf(mon, "%s"/monitor_puts(mon, /
---
  docs/devel/writing-monitor-commands.rst |  2 +-
  include/monitor/monitor.h   |  1 +
  monitor/monitor-internal.h  |  1 -
  block/monitor/block-hmp-cmds.c  | 10 +-
  hw/misc/mos6522.c   |  2 +-
  monitor/hmp-cmds.c  |  8 
  monitor/hmp.c   |  2 +-
  target/i386/helper.c|  2 +-
  8 files changed, 14 insertions(+), 14 deletions(-)


Reviewed-by: Philippe Mathieu-Daudé 



[PATCH v1 01/10] monitor: expose monitor_puts to rest of code

2022-09-21 Thread Alex Bennée
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);

It will be useful in following patches but for now convert all
existing plain "%s" printfs to use the _puts api.

Signed-off-by: Alex Bennée 
Reviewed-by: Richard Henderson 

---
v2
  - s/monitor_printf(mon, "%s"/monitor_puts(mon, /
---
 docs/devel/writing-monitor-commands.rst |  2 +-
 include/monitor/monitor.h   |  1 +
 monitor/monitor-internal.h  |  1 -
 block/monitor/block-hmp-cmds.c  | 10 +-
 hw/misc/mos6522.c   |  2 +-
 monitor/hmp-cmds.c  |  8 
 monitor/hmp.c   |  2 +-
 target/i386/helper.c|  2 +-
 8 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/docs/devel/writing-monitor-commands.rst 
b/docs/devel/writing-monitor-commands.rst
index 4aa2bb904d..2fefedcd98 100644
--- a/docs/devel/writing-monitor-commands.rst
+++ b/docs/devel/writing-monitor-commands.rst
@@ -716,7 +716,7 @@ message. Here's the implementation of the "info roms" HMP 
command::
  if (hmp_handle_error(mon, err)) {
  return;
  }
- monitor_printf(mon, "%s", info->human_readable_text);
+ monitor_puts(mon, info->human_readable_text);
  }
 
 Also, you have to add the function's prototype to the hmp.h file.
diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
index a4b40e8391..737e750670 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);
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
index bfb3c043a0..939a520d17 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -638,16 +638,16 @@ static void print_block_info(Monitor *mon, BlockInfo 
*info,
 assert(!info || !info->has_inserted || info->inserted == inserted);
 
 if (info && *info->device) {
-monitor_printf(mon, "%s", info->device);
+monitor_puts(mon, info->device);
 if (inserted && inserted->has_node_name) {
 monitor_printf(mon, " (%s)", inserted->node_name);
 }
 } else {
 assert(info || inserted);
-monitor_printf(mon, "%s",
-   inserted && inserted->has_node_name ? 
inserted->node_name
-   : info && info->has_qdev ? info->qdev
-   : "");
+monitor_puts(mon,
+ inserted && inserted->has_node_name ? inserted->node_name
+ : info && info->has_qdev ? info->qdev
+ : "");
 }
 
 if (inserted) {
diff --git a/hw/misc/mos6522.c b/hw/misc/mos6522.c
index f9e646350e..fe38c44426 100644
--- a/hw/misc/mos6522.c
+++ b/hw/misc/mos6522.c
@@ -595,7 +595,7 @@ void hmp_info_via(Monitor *mon, const QDict *qdict)
 if (hmp_handle_error(mon, err)) {
 return;
 }
-monitor_printf(mon, "%s", info->human_readable_text);
+monitor_puts(mon, info->human_readable_text);
 }
 
 static const MemoryRegionOps mos6522_ops = {
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index c6cd6f91dd..f90eea8d01 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -730,7 +730,7 @@ static void hmp_info_pci_device(Monitor *mon, const 
PciDeviceInfo *dev)
 monitor_printf(mon, "");
 
 if (dev->class_info->has_desc) {
-monitor_printf(mon, "%s", dev->class_info->desc);
+monitor_puts(mon, dev->class_info->desc);
 } else {
 monitor_printf(mon, "Class %04" PRId64, dev->class_info->q_class);
 }
@@ -2258,12 +2258,12 @@ static void print_stats_schema_value(Monitor *mon, 
StatsSchemaValue *value)
 if (unit && value->base == 10 &&
 value->exponent >= -18 && value->exponent <= 18 &&
 value->exponent % 3 == 0) {
-monitor_printf(mon, "%s", si_prefix(value->exponent));
+monitor_puts(mon, si_prefix(value->exponent));
 } else if (unit && value->base == 2 &&
value->exponent >= 0 && value->exponent <= 60 &&
value->exponent % 10 == 0) {
 
-