summaryrefslogtreecommitdiff
path: root/chardev
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2026-08-28 16:04:34 +0400
committerMarc-André Lureau <marcandre.lureau@redhat.com>2026-08-29 12:07:45 +0400
commitf3900cfb0cddd2fcc3b9db20f52f3755e6ed962f (patch)
tree6cf4fe4278f1e3237b8fb05725a3875e4ff3a5dc /chardev
parentbcf97f76064885730f491b63d4543b60c87c09fd (diff)
downloadqemu-f3900cfb0cddd2fcc3b9db20f52f3755e6ed962f.tar.gz
qemu-f3900cfb0cddd2fcc3b9db20f52f3755e6ed962f.zip
monitor: tighten monitor_printf*()
Rename monitor_printf->monitor_hmp_printf, monitor_vprintf-> monitor_hmp_vprintf, and monitor_printc->monitor_hmp_printc, changing the first parameter from Monitor * to MonitorHMP * to enforce type safety. The implementation is also simplified: monitor_hmp_vprintf now directly calls g_strdup_vprintf + monitor_puts, removing the virtual dispatch via moncls->vprintf. The dev_print() callbacks are temporarily using the MONITOR_HMP(mon) cast, they are fixed in the following commits. Early return in qemu_vprintf() if "hmp" is NULL, relying on monitor_hmp_vprintf() handling NULL case is a bit uncommon. Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-ID: <20260828-qemu-no-hmp-v5-37-9227de146347@redhat.com>
Diffstat (limited to 'chardev')
-rw-r--r--chardev/char-hmp-cmds.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/chardev/char-hmp-cmds.c b/chardev/char-hmp-cmds.c
index 71017fd2d1..fb0560054b 100644
--- a/chardev/char-hmp-cmds.c
+++ b/chardev/char-hmp-cmds.c
@@ -26,12 +26,11 @@
void hmp_info_chardev(MonitorHMP *hmp, const QDict *qdict)
{
- Monitor *mon = MONITOR(hmp);
ChardevInfoList *char_info, *info;
char_info = qmp_query_chardev(NULL);
for (info = char_info; info; info = info->next) {
- monitor_printf(mon, "%s: filename=%s\n", info->value->label,
+ monitor_hmp_printf(hmp, "%s: filename=%s\n", info->value->label,
info->value->filename);
}
@@ -51,7 +50,6 @@ void hmp_ringbuf_write(MonitorHMP *hmp, const QDict *qdict)
void hmp_ringbuf_read(MonitorHMP *hmp, const QDict *qdict)
{
- Monitor *mon = MONITOR(hmp);
uint32_t size = qdict_get_int(qdict, "size");
const char *chardev = qdict_get_str(qdict, "device");
char *data;
@@ -67,15 +65,15 @@ void hmp_ringbuf_read(MonitorHMP *hmp, const QDict *qdict)
unsigned char ch = data[i];
if (ch == '\\') {
- monitor_printf(mon, "\\\\");
+ monitor_hmp_printf(hmp, "\\\\");
} else if ((ch < 0x20 && ch != '\n' && ch != '\t') || ch == 0x7F) {
- monitor_printf(mon, "\\u%04X", ch);
+ monitor_hmp_printf(hmp, "\\u%04X", ch);
} else {
- monitor_printf(mon, "%c", ch);
+ monitor_hmp_printf(hmp, "%c", ch);
}
}
- monitor_printf(mon, "\n");
+ monitor_hmp_printf(hmp, "\n");
g_free(data);
}