提交 277acfe8 编写于 作者: F Fam Zheng 提交者: Luiz Capitulino

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: NFam Zheng <famz@redhat.com>
Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
Reviewed-by: NEric Blake <eblake@redhat.com>
Signed-off-by: NLuiz Capitulino <lcapitulino@redhat.com>
上级 3953e3a5
......@@ -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))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册