summaryrefslogtreecommitdiff
path: root/monitor.c
diff options
context:
space:
mode:
authorFam Zheng <famz@redhat.com>2013-08-20 10:58:21 +0800
committerLuiz Capitulino <lcapitulino@redhat.com>2013-08-20 11:52:00 -0400
commit277acfe8b38de35be8cb6e274678b5a7919c2d44 (patch)
tree9577722ae1bb0ecd9547c95f654b2a0e9a3f548d /monitor.c
parent3953e3a5d34fa7caffc3e32eae4270b2d810d966 (diff)
downloadqemu-277acfe8b38de35be8cb6e274678b5a7919c2d44.tar.gz
qemu-277acfe8b38de35be8cb6e274678b5a7919c2d44.tar.bz2
qemu-277acfe8b38de35be8cb6e274678b5a7919c2d44.zip
monitor: print the invalid char in error message
It's more friendly to print which char is invalid to user, especially when user tries to input a float value and expect the monitor to round it to int. Since we don't round float number when we look for a integer, telling which char is invalid is less confusing. Signed-off-by: Fam Zheng <famz@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/monitor.c b/monitor.c
index 5dc0aa97f5..da9c9a222b 100644
--- a/monitor.c
+++ b/monitor.c
@@ -3171,9 +3171,13 @@ static const MonitorDef monitor_defs[] = {
{ NULL },
};
-static void expr_error(Monitor *mon, const char *msg)
+static void expr_error(Monitor *mon, const char *fmt, ...)
{
- monitor_printf(mon, "%s\n", msg);
+ va_list ap;
+ va_start(ap, fmt);
+ monitor_vprintf(mon, fmt, ap);
+ monitor_printf(mon, "\n");
+ va_end(ap);
siglongjmp(expr_env, 1);
}
@@ -3291,7 +3295,7 @@ static int64_t expr_unary(Monitor *mon)
expr_error(mon, "number too large");
}
if (pch == p) {
- expr_error(mon, "invalid char in expression");
+ expr_error(mon, "invalid char '%c' in expression", *p);
}
pch = p;
while (qemu_isspace(*pch))