From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40726) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VBg3z-0005Py-Sq for qemu-devel@nongnu.org; Tue, 20 Aug 2013 03:09:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VBg3t-0003fA-9a for qemu-devel@nongnu.org; Tue, 20 Aug 2013 03:09:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36096) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VBg3t-0003f3-28 for qemu-devel@nongnu.org; Tue, 20 Aug 2013 03:09:05 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r7K794ns013265 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 20 Aug 2013 03:09:04 -0400 From: Markus Armbruster References: <1376967501-23886-1-git-send-email-famz@redhat.com> Date: Tue, 20 Aug 2013 09:09:02 +0200 In-Reply-To: <1376967501-23886-1-git-send-email-famz@redhat.com> (Fam Zheng's message of "Tue, 20 Aug 2013 10:58:21 +0800") Message-ID: <8761v0bzzl.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v2] monitor: print the invalid char in error message List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: Luiz Capitulino , qemu-devel@nongnu.org Fam Zheng 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 > --- > 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