From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43284) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VBoWN-0008Oc-Lh for qemu-devel@nongnu.org; Tue, 20 Aug 2013 12:11:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VBoWH-0002Wz-Li for qemu-devel@nongnu.org; Tue, 20 Aug 2013 12:11:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40816) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VBoWH-0002Wj-FG for qemu-devel@nongnu.org; Tue, 20 Aug 2013 12:10:57 -0400 From: Luiz Capitulino Date: Tue, 20 Aug 2013 12:10:40 -0400 Message-Id: <1377015041-6567-11-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1377015041-6567-1-git-send-email-lcapitulino@redhat.com> References: <1377015041-6567-1-git-send-email-lcapitulino@redhat.com> Subject: [Qemu-devel] [PULL 10/11] monitor: print the invalid char in error message List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: qemu-devel@nongnu.org From: 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 Reviewed-by: Markus Armbruster Reviewed-by: Eric Blake Signed-off-by: Luiz Capitulino --- 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.1.4