qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 34/56] json: Don't pass null @tokens to json_par


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH 34/56] json: Don't pass null @tokens to json_parser_parse()
Date: Mon, 13 Aug 2018 10:32:09 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0

On 08/08/2018 07:03 AM, Markus Armbruster wrote:
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 <address@hidden>
---
  qobject/json-parser.c   |  4 ----
  qobject/json-streamer.c | 25 ++++++++++++-------------
  2 files changed, 12 insertions(+), 17 deletions(-)


Shorter and simpler.

Reviewed-by: Eric Blake <address@hidden>

+++ b/qobject/json-streamer.c
@@ -39,9 +39,9 @@ void json_message_process_token(JSONLexer *lexer, GString 
*input,
                                  JSONTokenType type, int x, int y)
  {
      JSONMessageParser *parser = container_of(lexer, JSONMessageParser, lexer);
+    QObject *json = NULL;
      Error *err = NULL;
      JSONToken *token;
-    QObject *json;

Why the churn in position?

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org



reply via email to

[Prev in Thread] Current Thread [Next in Thread]