[nginx] Access: simplified rule parser code.

Ruslan Ermilov ru at nginx.com
Mon May 15 14:21:16 UTC 2017


details:   http://hg.nginx.org/nginx/rev/72188d1bcab5
branches:  
changeset: 6996:72188d1bcab5
user:      Ruslan Ermilov <ru at nginx.com>
date:      Mon May 15 17:16:32 2017 +0300
description:
Access: simplified rule parser code.

diffstat:

 src/http/modules/ngx_http_access_module.c |  20 +++++++-------------
 src/stream/ngx_stream_access_module.c     |  20 +++++++-------------
 2 files changed, 14 insertions(+), 26 deletions(-)

diffs (76 lines):

diff -r eb5d119323d8 -r 72188d1bcab5 src/http/modules/ngx_http_access_module.c
--- a/src/http/modules/ngx_http_access_module.c	Wed May 03 15:15:56 2017 +0300
+++ b/src/http/modules/ngx_http_access_module.c	Mon May 15 17:16:32 2017 +0300
@@ -309,27 +309,21 @@ ngx_http_access_rule(ngx_conf_t *cf, ngx
     ngx_http_access_rule_un_t  *rule_un;
 #endif
 
+    all = 0;
     ngx_memzero(&cidr, sizeof(ngx_cidr_t));
 
     value = cf->args->elts;
 
-    all = (value[1].len == 3 && ngx_strcmp(value[1].data, "all") == 0);
-
-    if (!all) {
+    if (value[1].len == 3 && ngx_strcmp(value[1].data, "all") == 0) {
+        all = 1;
 
 #if (NGX_HAVE_UNIX_DOMAIN)
-
-        if (value[1].len == 5 && ngx_strcmp(value[1].data, "unix:") == 0) {
-            cidr.family = AF_UNIX;
-            rc = NGX_OK;
+    } else if (value[1].len == 5 && ngx_strcmp(value[1].data, "unix:") == 0) {
+        cidr.family = AF_UNIX;
+#endif
 
-        } else {
-            rc = ngx_ptocidr(&value[1], &cidr);
-        }
-
-#else
+    } else {
         rc = ngx_ptocidr(&value[1], &cidr);
-#endif
 
         if (rc == NGX_ERROR) {
             ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
diff -r eb5d119323d8 -r 72188d1bcab5 src/stream/ngx_stream_access_module.c
--- a/src/stream/ngx_stream_access_module.c	Wed May 03 15:15:56 2017 +0300
+++ b/src/stream/ngx_stream_access_module.c	Mon May 15 17:16:32 2017 +0300
@@ -299,27 +299,21 @@ ngx_stream_access_rule(ngx_conf_t *cf, n
     ngx_stream_access_rule_un_t  *rule_un;
 #endif
 
+    all = 0;
     ngx_memzero(&cidr, sizeof(ngx_cidr_t));
 
     value = cf->args->elts;
 
-    all = (value[1].len == 3 && ngx_strcmp(value[1].data, "all") == 0);
-
-    if (!all) {
+    if (value[1].len == 3 && ngx_strcmp(value[1].data, "all") == 0) {
+        all = 1;
 
 #if (NGX_HAVE_UNIX_DOMAIN)
-
-        if (value[1].len == 5 && ngx_strcmp(value[1].data, "unix:") == 0) {
-            cidr.family = AF_UNIX;
-            rc = NGX_OK;
+    } else if (value[1].len == 5 && ngx_strcmp(value[1].data, "unix:") == 0) {
+        cidr.family = AF_UNIX;
+#endif
 
-        } else {
-            rc = ngx_ptocidr(&value[1], &cidr);
-        }
-
-#else
+    } else {
         rc = ngx_ptocidr(&value[1], &cidr);
-#endif
 
         if (rc == NGX_ERROR) {
             ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,


More information about the nginx-devel mailing list