Eric Blake <ebl...@redhat.com> 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 <arm...@redhat.com> >> --- >> qobject/json-parser.c | 4 ---- >> qobject/json-streamer.c | 25 ++++++++++++------------- >> 2 files changed, 12 insertions(+), 17 deletions(-) >> > > Shorter and simpler. > > Reviewed-by: Eric Blake <ebl...@redhat.com> > >> +++ 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."