diff options
author | Markus Armbruster | 2017-02-28 22:26:54 +0100 |
---|---|---|
committer | Markus Armbruster | 2017-03-07 16:07:47 +0100 |
commit | 99dbfd1db1110f579f47b40155b9bf750d2cd6ad (patch) | |
tree | 8916e2a33a9a7c53f72fbff8f7df6d0fb61a74f2 /qobject | |
parent | qapi: Factor out common qobject_input_get_keyval() (diff) | |
download | qemu-99dbfd1db1110f579f47b40155b9bf750d2cd6ad.tar.gz qemu-99dbfd1db1110f579f47b40155b9bf750d2cd6ad.tar.xz qemu-99dbfd1db1110f579f47b40155b9bf750d2cd6ad.zip |
qobject: Propagate parse errors through qobject_from_jsonv()
The next few commits will put the errors to use where appropriate.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <1488317230-26248-9-git-send-email-armbru@redhat.com>
Diffstat (limited to 'qobject')
-rw-r--r-- | qobject/qjson.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/qobject/qjson.c b/qobject/qjson.c index 9a0de89079..339c9f7de2 100644 --- a/qobject/qjson.c +++ b/qobject/qjson.c @@ -12,6 +12,7 @@ */ #include "qemu/osdep.h" +#include "qapi/error.h" #include "qapi/qmp/json-lexer.h" #include "qapi/qmp/json-parser.h" #include "qapi/qmp/json-streamer.h" @@ -24,15 +25,17 @@ typedef struct JSONParsingState JSONMessageParser parser; va_list *ap; QObject *result; + Error *err; } JSONParsingState; static void parse_json(JSONMessageParser *parser, GQueue *tokens) { JSONParsingState *s = container_of(parser, JSONParsingState, parser); - s->result = json_parser_parse(tokens, s->ap); + + s->result = json_parser_parse_err(tokens, s->ap, &s->err); } -QObject *qobject_from_jsonv(const char *string, va_list *ap) +QObject *qobject_from_jsonv(const char *string, va_list *ap, Error **errp) { JSONParsingState state = {}; @@ -43,12 +46,13 @@ QObject *qobject_from_jsonv(const char *string, va_list *ap) json_message_parser_flush(&state.parser); json_message_parser_destroy(&state.parser); + error_propagate(errp, state.err); return state.result; } QObject *qobject_from_json(const char *string) { - return qobject_from_jsonv(string, NULL); + return qobject_from_jsonv(string, NULL, NULL); } /* @@ -61,7 +65,7 @@ QObject *qobject_from_jsonf(const char *string, ...) va_list ap; va_start(ap, string); - obj = qobject_from_jsonv(string, &ap); + obj = qobject_from_jsonv(string, &ap, NULL); va_end(ap); assert(obj != NULL); |