[njs] Removed unnecessary NULL checks introduced in 0a2a0b5a74f4.

Alexander Borisov alexander.borisov at nginx.com
Thu May 6 13:18:36 UTC 2021


details:   https://hg.nginx.org/njs/rev/5563f2cbce5b
branches:  
changeset: 1634:5563f2cbce5b
user:      Alexander Borisov <alexander.borisov at nginx.com>
date:      Thu May 06 16:07:06 2021 +0300
description:
Removed unnecessary NULL checks introduced in 0a2a0b5a74f4.

Found by Coverity (CID 1478008).

diffstat:

 src/njs_variable.c |  10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diffs (34 lines):

diff -r a0bb54faa1b2 -r 5563f2cbce5b src/njs_variable.c
--- a/src/njs_variable.c	Thu May 06 16:07:05 2021 +0300
+++ b/src/njs_variable.c	Thu May 06 16:07:06 2021 +0300
@@ -437,7 +437,7 @@ njs_variable_closure(njs_vm_t *vm, njs_v
     njs_index_t               index, prev_index, *idx;
     njs_level_type_t          type;
     njs_rbtree_node_t         *rb_node;
-    njs_parser_scope_t        **p, *root;
+    njs_parser_scope_t        **p;
     njs_parser_rbtree_node_t  *parse_node, ref_node;
 #define NJS_VAR_MAX_DEPTH     32
     njs_parser_scope_t        *list[NJS_VAR_MAX_DEPTH];
@@ -482,18 +482,16 @@ njs_variable_closure(njs_vm_t *vm, njs_v
             }
         }
 
-        root = njs_function_scope(scope);
-
-        if (type != NJS_LEVEL_CLOSURE && root == scope) {
+        if (type != NJS_LEVEL_CLOSURE) {
             /* Create new closure for scope. */
 
-            index = njs_scope_index(root->type, root->closures->items,
+            index = njs_scope_index(scope->type, scope->closures->items,
                                     NJS_LEVEL_CLOSURE, var->type);
             if (njs_slow_path(index == NJS_INDEX_ERROR)) {
                 return NJS_INDEX_ERROR;
             }
 
-            idx = njs_arr_add(root->closures);
+            idx = njs_arr_add(scope->closures);
             if (njs_slow_path(idx == NULL)) {
                 return NJS_INDEX_ERROR;
             }


More information about the nginx-devel mailing list