[njs] Fixed various clang static analyzer warnings.

Dmitry Volyntsev xeioex at nginx.com
Mon Nov 19 13:30:51 UTC 2018


details:   http://hg.nginx.org/njs/rev/2b18ef4e86d1
branches:  
changeset: 659:2b18ef4e86d1
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Mon Nov 19 16:30:35 2018 +0300
description:
Fixed various clang static analyzer warnings.

In njs_object_keys_array() function.

diffstat:

 njs/njs_object.c |  20 ++------------------
 1 files changed, 2 insertions(+), 18 deletions(-)

diffs (39 lines):

diff -r 76e139b439ad -r 2b18ef4e86d1 njs/njs_object.c
--- a/njs/njs_object.c	Thu Nov 15 20:31:35 2018 +0300
+++ b/njs/njs_object.c	Mon Nov 19 16:30:35 2018 +0300
@@ -959,33 +959,17 @@ njs_object_keys_array(njs_vm_t *vm, cons
 
     n = 0;
 
-    switch (value->type) {
-    case NJS_ARRAY:
+    if (array != NULL) {
         for (i = 0; i < length; i++) {
             if (njs_is_valid(&array->start[i])) {
                 njs_uint32_to_string(&keys->start[n++], i);
             }
         }
 
-        break;
-
-    case NJS_STRING:
-    case NJS_OBJECT_STRING:
-        if (value->type == NJS_OBJECT_STRING) {
-            string = &value->data.u.object_value->value;
-
-        } else {
-            string = (njs_value_t *) value;
-        }
-
+    } else if (length != 0) {
         for (i = 0; i < length; i++) {
             njs_uint32_to_string(&keys->start[n++], i);
         }
-
-        break;
-
-    default:
-        break;
     }
 
     if (nxt_fast_path(hash != NULL)) {


More information about the nginx-devel mailing list