Access: simplified rule parser code.
diff --git a/src/http/modules/ngx_http_access_module.c b/src/http/modules/ngx_http_access_module.c
index c553e46..7355de9 100644
--- a/src/http/modules/ngx_http_access_module.c
+++ b/src/http/modules/ngx_http_access_module.c
@@ -309,28 +309,22 @@
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 {
- rc = ngx_ptocidr(&value[1], &cidr);
- }
-
-#else
- rc = ngx_ptocidr(&value[1], &cidr);
+ } 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);
+
if (rc == NGX_ERROR) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"invalid parameter \"%V\"", &value[1]);
diff --git a/src/stream/ngx_stream_access_module.c b/src/stream/ngx_stream_access_module.c
index 1745cdf..a3020d4 100644
--- a/src/stream/ngx_stream_access_module.c
+++ b/src/stream/ngx_stream_access_module.c
@@ -299,28 +299,22 @@
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 {
- rc = ngx_ptocidr(&value[1], &cidr);
- }
-
-#else
- rc = ngx_ptocidr(&value[1], &cidr);
+ } 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);
+
if (rc == NGX_ERROR) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"invalid parameter \"%V\"", &value[1]);