[nginx] Removed a surplus condition from ngx_parse_inet6_url().

Valentin Bartenev vbart at nginx.com
Wed May 11 15:01:18 UTC 2016


details:   http://hg.nginx.org/nginx/rev/19a54ba76c04
branches:  
changeset: 6534:19a54ba76c04
user:      Ruslan Ermilov <ru at nginx.com>
date:      Wed May 11 17:55:30 2016 +0300
description:
Removed a surplus condition from ngx_parse_inet6_url().

No functional changes, since the condition was always true.

diffstat:

 src/core/ngx_inet.c |  67 +++++++++++++++++++++++++---------------------------
 1 files changed, 32 insertions(+), 35 deletions(-)

diffs (88 lines):

diff -r b358d670c654 -r 19a54ba76c04 src/core/ngx_inet.c
--- a/src/core/ngx_inet.c	Wed May 11 17:55:20 2016 +0300
+++ b/src/core/ngx_inet.c	Wed May 11 17:55:30 2016 +0300
@@ -843,52 +843,49 @@ ngx_parse_inet6_url(ngx_pool_t *pool, ng
         return NGX_ERROR;
     }
 
-    if (last - p) {
+    port = p + 1;
 
-        port = p + 1;
+    uri = ngx_strlchr(port, last, '/');
 
-        uri = ngx_strlchr(port, last, '/');
-
-        if (uri) {
-            if (u->listen || !u->uri_part) {
-                u->err = "invalid host";
-                return NGX_ERROR;
-            }
-
-            u->uri.len = last - uri;
-            u->uri.data = uri;
-
-            last = uri;
+    if (uri) {
+        if (u->listen || !u->uri_part) {
+            u->err = "invalid host";
+            return NGX_ERROR;
         }
 
-        if (port < last) {
-            if (*port != ':') {
-                u->err = "invalid host";
-                return NGX_ERROR;
-            }
+        u->uri.len = last - uri;
+        u->uri.data = uri;
 
-            port++;
+        last = uri;
+    }
 
-            len = last - port;
+    if (port < last) {
+        if (*port != ':') {
+            u->err = "invalid host";
+            return NGX_ERROR;
+        }
 
-            n = ngx_atoi(port, len);
+        port++;
 
-            if (n < 1 || n > 65535) {
-                u->err = "invalid port";
-                return NGX_ERROR;
-            }
+        len = last - port;
 
-            u->port = (in_port_t) n;
-            sin6->sin6_port = htons((in_port_t) n);
+        n = ngx_atoi(port, len);
 
-            u->port_text.len = len;
-            u->port_text.data = port;
+        if (n < 1 || n > 65535) {
+            u->err = "invalid port";
+            return NGX_ERROR;
+        }
 
-        } else {
-            u->no_port = 1;
-            u->port = u->default_port;
-            sin6->sin6_port = htons(u->default_port);
-        }
+        u->port = (in_port_t) n;
+        sin6->sin6_port = htons((in_port_t) n);
+
+        u->port_text.len = len;
+        u->port_text.data = port;
+
+    } else {
+        u->no_port = 1;
+        u->port = u->default_port;
+        sin6->sin6_port = htons(u->default_port);
     }
 
     len = p - host;



More information about the nginx-devel mailing list