[njs] Style and small miscellaneous fixes.

Igor Sysoev igor at sysoev.ru
Wed Nov 9 12:07:51 UTC 2016


details:   http://hg.nginx.org/njs/rev/7a42d1e83ae2
branches:  
changeset: 245:7a42d1e83ae2
user:      Igor Sysoev <igor at sysoev.ru>
date:      Wed Nov 09 15:04:40 2016 +0300
description:
Style and small miscellaneous fixes.

diffstat:

 njs/njs_disassembler.c      |   2 +-
 njs/njs_string.c            |   3 +--
 njs/njs_vm.c                |  14 +++++++-------
 njs/njs_vm.h                |   3 ++-
 njs/test/njs_unit_test.c    |   3 ++-
 nxt/nxt_rbtree.c            |  11 +++--------
 nxt/nxt_utf8.h              |   1 -
 nxt/test/random_unit_test.c |   2 +-
 8 files changed, 17 insertions(+), 22 deletions(-)

diffs (157 lines):

diff -r c8862eb2eb94 -r 7a42d1e83ae2 njs/njs_disassembler.c
--- a/njs/njs_disassembler.c	Wed Nov 09 14:34:32 2016 +0300
+++ b/njs/njs_disassembler.c	Wed Nov 09 15:04:40 2016 +0300
@@ -151,7 +151,7 @@ njs_disassembler(njs_vm_t *vm)
     code = vm->code->start;
     n = vm->code->items;
 
-    while(n != 0) {
+    while (n != 0) {
         njs_disassemble(code->start, code->end);
         code++;
         n--;
diff -r c8862eb2eb94 -r 7a42d1e83ae2 njs/njs_string.c
--- a/njs/njs_string.c	Wed Nov 09 14:34:32 2016 +0300
+++ b/njs/njs_string.c	Wed Nov 09 15:04:40 2016 +0300
@@ -607,7 +607,6 @@ njs_string_prototype_concat(njs_vm_t *vm
     }
 
     for (i = 0; i < nargs; i++) {
-
         if (!njs_is_string(&args[i])) {
             vm->frame->trap_scratch.data.u.value = &args[i];
 
@@ -3210,7 +3209,7 @@ static const njs_object_prop_t  njs_stri
         .type = NJS_METHOD,
         .name = njs_string("match"),
         .value = njs_native_function(njs_string_prototype_match, 0,
-                     NJS_STRING_ARG, NJS_REGEXP_ARG),
+                     NJS_STRING_OBJECT_ARG, NJS_REGEXP_ARG),
     },
 
     {
diff -r c8862eb2eb94 -r 7a42d1e83ae2 njs/njs_vm.c
--- a/njs/njs_vm.c	Wed Nov 09 14:34:32 2016 +0300
+++ b/njs/njs_vm.c	Wed Nov 09 15:04:40 2016 +0300
@@ -79,10 +79,10 @@ static njs_ret_t njs_object_property_que
 static njs_ret_t njs_method_private_copy(njs_vm_t *vm,
     njs_property_query_t *pq);
 static nxt_noinline uint32_t njs_integer_value(double num);
-static nxt_noinline njs_ret_t njs_values_equal(njs_value_t *val1,
-    njs_value_t *val2);
-static nxt_noinline njs_ret_t njs_values_compare(njs_value_t *val1,
-    njs_value_t *val2);
+static nxt_noinline njs_ret_t njs_values_equal(const njs_value_t *val1,
+    const njs_value_t *val2);
+static nxt_noinline njs_ret_t njs_values_compare(const njs_value_t *val1,
+    const njs_value_t *val2);
 static njs_object_t *njs_function_new_object(njs_vm_t *vm, njs_value_t *value);
 static njs_ret_t njs_vmcode_method_call(njs_vm_t *vm, njs_value_t *object,
     njs_value_t *value);
@@ -1879,7 +1879,7 @@ njs_vmcode_not_equal(njs_vm_t *vm, njs_v
 
 
 static nxt_noinline njs_ret_t
-njs_values_equal(njs_value_t *val1, njs_value_t *val2)
+njs_values_equal(const njs_value_t *val1, const njs_value_t *val2)
 {
     /* Void and null are equal and not comparable with anything else. */
     if (njs_is_null_or_void(val1)) {
@@ -1967,7 +1967,7 @@ njs_vmcode_greater_or_equal(njs_vm_t *vm
  */
 
 static nxt_noinline njs_ret_t
-njs_values_compare(njs_value_t *val1, njs_value_t *val2)
+njs_values_compare(const njs_value_t *val1, const njs_value_t *val2)
 {
     if (nxt_fast_path(njs_is_numeric(val1) || njs_is_numeric(val2))) {
 
@@ -2030,7 +2030,7 @@ njs_vmcode_strict_not_equal(njs_vm_t *vm
 
 
 nxt_noinline nxt_bool_t
-njs_values_strict_equal(njs_value_t *val1, njs_value_t *val2)
+njs_values_strict_equal(const njs_value_t *val1, const njs_value_t *val2)
 {
     size_t        size;
     const u_char  *start1, *start2;
diff -r c8862eb2eb94 -r 7a42d1e83ae2 njs/njs_vm.h
--- a/njs/njs_vm.h	Wed Nov 09 14:34:32 2016 +0300
+++ b/njs/njs_vm.h	Wed Nov 09 15:04:40 2016 +0300
@@ -1007,7 +1007,8 @@ njs_ret_t njs_vmcode_catch(njs_vm_t *vm,
 njs_ret_t njs_vmcode_finally(njs_vm_t *vm, njs_value_t *invld,
     njs_value_t *retval);
 
-nxt_bool_t njs_values_strict_equal(njs_value_t *val1, njs_value_t *val2);
+nxt_bool_t njs_values_strict_equal(const njs_value_t *val1,
+    const njs_value_t *val2);
 
 njs_ret_t njs_normalize_args(njs_vm_t *vm, njs_value_t *args,
     uint8_t *args_types, nxt_uint_t nargs);
diff -r c8862eb2eb94 -r 7a42d1e83ae2 njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c	Wed Nov 09 14:34:32 2016 +0300
+++ b/njs/test/njs_unit_test.c	Wed Nov 09 15:04:40 2016 +0300
@@ -6218,10 +6218,11 @@ main(int argc, char **argv)
         "fibo(32).length");
 
     static nxt_str_t  fibo_bytes = nxt_string(
+        "var a = '\\x80'.toBytes();"
         "function fibo(n) {"
         "    if (n > 1)"
         "        return fibo(n - 1) + fibo(n - 2)"
-        "    return '\\x80'.toBytes()"
+        "    return a"
         "}"
         "fibo(32).length");
 
diff -r c8862eb2eb94 -r 7a42d1e83ae2 nxt/nxt_rbtree.c
--- a/nxt/nxt_rbtree.c	Wed Nov 09 14:34:32 2016 +0300
+++ b/nxt/nxt_rbtree.c	Wed Nov 09 15:04:40 2016 +0300
@@ -17,7 +17,8 @@
 
 
 static void nxt_rbtree_insert_fixup(nxt_rbtree_node_t *node);
-static void nxt_rbtree_delete_fixup(nxt_rbtree_t *tree, nxt_rbtree_node_t *node);
+static void nxt_rbtree_delete_fixup(nxt_rbtree_t *tree,
+    nxt_rbtree_node_t *node);
 nxt_inline void nxt_rbtree_left_rotate(nxt_rbtree_node_t *node);
 nxt_inline void nxt_rbtree_right_rotate(nxt_rbtree_node_t *node);
 nxt_inline void nxt_rbtree_parent_relink(nxt_rbtree_node_t *subst,
@@ -28,13 +29,7 @@ nxt_inline void nxt_rbtree_parent_relink
 #define NXT_RBTREE_RED    1
 
 
-#define nxt_rbtree_set_callback_type(tree, type)                               \
-    (tree)->sentinel.spare = type
-
-#define nxt_rbtree_has_insertion_callback(tree)                                \
-    ((tree)->sentinel.spare != 0)
-
-#define nxt_rbtree_comparison_callback(tree)                                   \
+#define nxt_rbtree_comparison_callback(tree)                                  \
     ((nxt_rbtree_compare_t) (tree)->sentinel.right)
 
 
diff -r c8862eb2eb94 -r 7a42d1e83ae2 nxt/nxt_utf8.h
--- a/nxt/nxt_utf8.h	Wed Nov 09 14:34:32 2016 +0300
+++ b/nxt/nxt_utf8.h	Wed Nov 09 15:04:40 2016 +0300
@@ -76,7 +76,6 @@ nxt_utf8_prev(const u_char *p)
 }
 
 
-
 #define nxt_utf8_size(u)                                                      \
     ((u < 0x80) ? 1 : ((u < 0x0800) ? 2 : ((u < 0x10000) ? 3 : 4)))
 
diff -r c8862eb2eb94 -r 7a42d1e83ae2 nxt/test/random_unit_test.c
--- a/nxt/test/random_unit_test.c	Wed Nov 09 14:34:32 2016 +0300
+++ b/nxt/test/random_unit_test.c	Wed Nov 09 15:04:40 2016 +0300
@@ -15,7 +15,7 @@
 
 
 static nxt_int_t
-random_unit_test()
+random_unit_test(void)
 {
     nxt_uint_t    n;
     nxt_random_t  r;



More information about the nginx-devel mailing list