changeset 6996:72188d1bcab5

Access: simplified rule parser code.
author Ruslan Ermilov <ru@nginx.com>
date Mon, 15 May 2017 17:16:32 +0300
parents eb5d119323d8
children df1a62c83b1b
files src/http/modules/ngx_http_access_module.c src/stream/ngx_stream_access_module.c
diffstat 2 files changed, 14 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/src/http/modules/ngx_http_access_module.c
+++ b/src/http/modules/ngx_http_access_module.c
@@ -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,
--- a/src/stream/ngx_stream_access_module.c
+++ b/src/stream/ngx_stream_access_module.c
@@ -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,