diff options
author | Amos Kong <akong@redhat.com> | 2010-03-24 23:12:05 +0800 |
---|---|---|
committer | Aurelien Jarno <aurelien@aurel32.net> | 2010-03-27 13:51:01 +0100 |
commit | c96c84a9ff4bc184cb1f6cc9771a550f3854ba59 (patch) | |
tree | 3c98d06e4c915eb68b6e0ede2bb4010ae7631ce3 | |
parent | 57e69b7d4e270883c7b7adb9c5993bb42e13a5ea (diff) | |
download | hqemu-c96c84a9ff4bc184cb1f6cc9771a550f3854ba59.zip hqemu-c96c84a9ff4bc184cb1f6cc9771a550f3854ba59.tar.gz |
json-parser: Output the content of invalid keyword
When input some invalid word 'unknowcmd' through QMP port, qemu outputs
this error message:
"parse error: invalid keyword `%s'"
This patch makes qemu output the content of invalid keyword, like:
"parse error: invalid keyword `unknowcmd'"
Signed-off-by: Amos Kong <akong@redhat.com>
Acked-by: Richard Henderson <rth@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
-rw-r--r-- | json-parser.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/json-parser.c b/json-parser.c index 579928f..b55d763 100644 --- a/json-parser.c +++ b/json-parser.c @@ -12,6 +12,7 @@ */ #include <stdbool.h> +#include <stdarg.h> #include "qemu-common.h" #include "qstring.h" @@ -93,7 +94,12 @@ static int token_is_escape(QObject *obj, const char *value) */ static void parse_error(JSONParserContext *ctxt, QObject *token, const char *msg, ...) { - fprintf(stderr, "parse error: %s\n", msg); + va_list ap; + va_start(ap, msg); + fprintf(stderr, "parse error: "); + vfprintf(stderr, msg, ap); + fprintf(stderr, "\n"); + va_end(ap); } /** |