monitor: expose monitor_puts to rest of code
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 <alex.bennee@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <20220929114231.583801-33-alex.bennee@linaro.org>
This commit is contained in:
parent
3cc70a9994
commit
bf0c50d4aa
@ -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
|
||||
: "<anonymous>");
|
||||
monitor_puts(mon,
|
||||
inserted && inserted->has_node_name ? inserted->node_name
|
||||
: info && info->has_qdev ? info->qdev
|
||||
: "<anonymous>");
|
||||
}
|
||||
|
||||
if (inserted) {
|
||||
|
@ -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.
|
||||
|
@ -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 = {
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
||||
monitor_printf(mon, "%s", iec_binary_prefix(value->exponent));
|
||||
monitor_puts(mon, iec_binary_prefix(value->exponent));
|
||||
} else if (value->exponent) {
|
||||
/* Use exponential notation and write the unit's English name */
|
||||
monitor_printf(mon, "* %d^%d%s",
|
||||
@ -2273,7 +2273,7 @@ static void print_stats_schema_value(Monitor *mon, StatsSchemaValue *value)
|
||||
}
|
||||
|
||||
if (value->has_unit) {
|
||||
monitor_printf(mon, "%s", unit ? unit : StatsUnit_str(value->unit));
|
||||
monitor_puts(mon, unit ? unit : StatsUnit_str(value->unit));
|
||||
}
|
||||
|
||||
/* Print bucket size for linear histograms */
|
||||
|
@ -1094,7 +1094,7 @@ static void hmp_info_human_readable_text(Monitor *mon,
|
||||
return;
|
||||
}
|
||||
|
||||
monitor_printf(mon, "%s", info->human_readable_text);
|
||||
monitor_puts(mon, info->human_readable_text);
|
||||
}
|
||||
|
||||
static void handle_hmp_command_exec(Monitor *mon,
|
||||
|
@ -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);
|
||||
|
@ -415,7 +415,7 @@ static void do_inject_x86_mce(CPUState *cs, run_on_cpu_data data)
|
||||
if (need_reset) {
|
||||
emit_guest_memory_failure(MEMORY_FAILURE_ACTION_RESET, ar,
|
||||
recursive);
|
||||
monitor_printf(params->mon, "%s", msg);
|
||||
monitor_puts(params->mon, msg);
|
||||
qemu_log_mask(CPU_LOG_RESET, "%s\n", msg);
|
||||
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user