mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 04:13:53 -06:00
json: Don't pass null @tokens to json_parser_parse()
json_parser_parse() normally returns the QObject on success. Except it returns null when its @tokens argument is null. Its only caller json_message_process_token() passes null @tokens when emitting a lexical error. The call is a rather opaque way to say json = NULL then. Simplify matters by lifting the assignment to json out of the emit path: initialize json to null, set it to the value of json_parser_parse() when there's no lexical error. Drop the special case from json_parser_parse(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180823164025.12553-36-armbru@redhat.com>
This commit is contained in:
parent
62815d85ae
commit
ff281a272f
2 changed files with 12 additions and 17 deletions
|
@ -546,10 +546,6 @@ QObject *json_parser_parse(GQueue *tokens, va_list *ap, Error **errp)
|
|||
JSONParserContext ctxt = { .buf = tokens };
|
||||
QObject *result;
|
||||
|
||||
if (!tokens) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
result = parse_value(&ctxt, ap);
|
||||
|
||||
error_propagate(errp, ctxt.err);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue