From: Alexander Borisov Date: Mon, 1 Jun 2020 15:09:28 +0000 (+0300) Subject: Removed unnecessary NULL checks introduced in 86f55a7dc4a4. X-Git-Url: http://git.kaiwu.me/postgresql/log/contrib/postgres_fdw/static/gitweb.js?a=commitdiff_plain;h=78f3b62cb4794d8f314be3402540ccda24685953;p=njs.git Removed unnecessary NULL checks introduced in 86f55a7dc4a4. Found by Clang static analyzer. --- diff --git a/src/njs_parser.c b/src/njs_parser.c index 3d0dd278..20343510 100644 --- a/src/njs_parser.c +++ b/src/njs_parser.c @@ -1929,7 +1929,7 @@ njs_parser_property_definition_after(njs_parser_t *parser, proto_init = 0; - if (property != NULL && property->index != NJS_TOKEN_OPEN_BRACKET + if (property->index != NJS_TOKEN_OPEN_BRACKET && njs_is_string(&property->u.value)) { njs_string_get(&property->u.value, &name); @@ -3891,18 +3891,12 @@ njs_parser_coalesce_expression(njs_parser_t *parser, njs_lexer_token_t *token, return njs_parser_stack_pop(parser); } - if (node != NULL) { - type = node->token_type; + type = node->token_type; - if (parser->lexer->prev_type != NJS_TOKEN_CLOSE_PARENTHESIS - && (type == NJS_TOKEN_LOGICAL_OR || type == NJS_TOKEN_LOGICAL_AND)) - { - njs_parser_syntax_error(parser, "Either \"??\" or \"%s\" " - "expression must be parenthesized", - (type == NJS_TOKEN_LOGICAL_OR) ? "||" - : "&&"); - return NJS_DONE; - } + if (parser->lexer->prev_type != NJS_TOKEN_CLOSE_PARENTHESIS + && (type == NJS_TOKEN_LOGICAL_OR || type == NJS_TOKEN_LOGICAL_AND)) + { + return njs_parser_failed(parser); } njs_lexer_consume_token(parser->lexer, 1); diff --git a/src/test/njs_unit_test.c b/src/test/njs_unit_test.c index 358dbd08..438a414b 100644 --- a/src/test/njs_unit_test.c +++ b/src/test/njs_unit_test.c @@ -1344,8 +1344,7 @@ static njs_unit_test_t njs_test[] = njs_str("false") }, { njs_str("1 && 1 ?? true"), - njs_str("SyntaxError: Either \"??\" or \"&&\" expression " - "must be parenthesized in 1") }, + njs_str("SyntaxError: Unexpected token \"??\" in 1") }, { njs_str("null ?? 0 || 1"), njs_str("SyntaxError: Unexpected token \"||\" in 1") },