From: Amos Kong Date: Wed, 24 Mar 2010 15:12:05 +0000 (+0800) Subject: json-parser: Output the content of invalid keyword X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=c96c84a9ff4bc184cb1f6cc9771a550f3854ba59;p=qemu.git 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 Acked-by: Richard Henderson Signed-off-by: Aurelien Jarno --- diff --git a/json-parser.c b/json-parser.c index 579928f2ee..b55d76373e 100644 --- a/json-parser.c +++ b/json-parser.c @@ -12,6 +12,7 @@ */ #include +#include #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); } /**