qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: qemu-devel@nongnu.org
Cc: Luiz Capitulino <lcapitul@redhat.com>, Fam Zheng <famz@redhat.com>
Subject: [Qemu-devel] [PATCH v2] monitor: print the invalid char in error message
Date: Tue, 20 Aug 2013 10:58:21 +0800	[thread overview]
Message-ID: <1376967501-23886-1-git-send-email-famz@redhat.com> (raw)

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

             reply	other threads:[~2013-08-20  2:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-20  2:58 Fam Zheng [this message]
2013-08-20  7:09 ` [Qemu-devel] [PATCH v2] monitor: print the invalid char in error message Markus Armbruster
2013-08-20 13:40 ` Eric Blake
2013-08-20 14:26 ` Luiz Capitulino

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1376967501-23886-1-git-send-email-famz@redhat.com \
    --to=famz@redhat.com \
    --cc=lcapitul@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).