qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2] monitor: print the invalid char in error mes


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH v2] monitor: print the invalid char in error message
Date: Tue, 20 Aug 2013 09:09:02 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)

Fam Zheng <address@hidden> 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 <address@hidden>
> ---
>  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 <address@hidden>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]