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: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH 34/56] json: Don't pass null @tokens to json_parser_parse()
Date: Tue, 14 Aug 2018 08:17:49 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Eric Blake <address@hidden> writes:

> 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?

I like to put declarations with initializers before declarations without
initializers.  ObMovieQuote: "it's a symbol of my individuality, and my
belief in personal freedom."



reply via email to

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