* [Qemu-devel] [PATCH v2] monitor: print the invalid char in error message
@ 2013-08-20 2:58 Fam Zheng
2013-08-20 7:09 ` Markus Armbruster
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Fam Zheng @ 2013-08-20 2:58 UTC (permalink / raw)
To: qemu-devel; +Cc: Luiz Capitulino, Fam Zheng
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>
---
monitor.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/monitor.c b/monitor.c
index 5dc0aa9..da9c9a2 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))
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v2] monitor: print the invalid char in error message
2013-08-20 2:58 [Qemu-devel] [PATCH v2] monitor: print the invalid char in error message Fam Zheng
@ 2013-08-20 7:09 ` Markus Armbruster
2013-08-20 13:40 ` Eric Blake
2013-08-20 14:26 ` Luiz Capitulino
2 siblings, 0 replies; 4+ messages in thread
From: Markus Armbruster @ 2013-08-20 7:09 UTC (permalink / raw)
To: Fam Zheng; +Cc: Luiz Capitulino, qemu-devel
Fam Zheng <famz@redhat.com> writes:
> 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>
> ---
> monitor.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/monitor.c b/monitor.c
> index 5dc0aa9..da9c9a2 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))
The user is still left guessing *where* the error is. But it's an
incremental improvement.
Reviewed-by: Markus Armbruster <armbru@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v2] monitor: print the invalid char in error message
2013-08-20 2:58 [Qemu-devel] [PATCH v2] monitor: print the invalid char in error message Fam Zheng
2013-08-20 7:09 ` Markus Armbruster
@ 2013-08-20 13:40 ` Eric Blake
2013-08-20 14:26 ` Luiz Capitulino
2 siblings, 0 replies; 4+ messages in thread
From: Eric Blake @ 2013-08-20 13:40 UTC (permalink / raw)
To: Fam Zheng; +Cc: Luiz Capitulino, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 781 bytes --]
On 08/19/2013 08:58 PM, Fam Zheng wrote:
> 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.
Including a sample of the error message issued before and after this
patch as part of the commit message is helpful, but not enough for me to
require a respin.
>
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
> monitor.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 621 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH v2] monitor: print the invalid char in error message
2013-08-20 2:58 [Qemu-devel] [PATCH v2] monitor: print the invalid char in error message Fam Zheng
2013-08-20 7:09 ` Markus Armbruster
2013-08-20 13:40 ` Eric Blake
@ 2013-08-20 14:26 ` Luiz Capitulino
2 siblings, 0 replies; 4+ messages in thread
From: Luiz Capitulino @ 2013-08-20 14:26 UTC (permalink / raw)
To: Fam Zheng; +Cc: Luiz Capitulino, qemu-devel
On Tue, 20 Aug 2013 10:58:21 +0800
Fam Zheng <famz@redhat.com> wrote:
> 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>
Applied to the qmp branch, thanks.
> ---
> monitor.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/monitor.c b/monitor.c
> index 5dc0aa9..da9c9a2 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))
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-08-20 14:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-20 2:58 [Qemu-devel] [PATCH v2] monitor: print the invalid char in error message Fam Zheng
2013-08-20 7:09 ` Markus Armbruster
2013-08-20 13:40 ` Eric Blake
2013-08-20 14:26 ` Luiz Capitulino
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).