[PATCH 1/6] connect: remove get_port()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



get_port() is only used as a fallback when get_host_and_port() does not
return a port. But get_port() does the same search as
get_host_and_port(), except get_host_and_port() starts from the end of
the host, respecting square brackets for ipv6 addresses, and get_port(),
operating after get_host_and_port(), works on a modified host string
that has square brackes removed if there were any.

I cannot think of any legal host:port string that would not have a port
returned by get_host_and_port() *and* have one returned by get_port().
So just remove get_port().

Signed-off-by: Mike Hommey <mh@xxxxxxxxxxxx>
---
 connect.c | 19 -------------------
 1 file changed, 19 deletions(-)

diff --git a/connect.c b/connect.c
index c53f3f1..45308ef 100644
--- a/connect.c
+++ b/connect.c
@@ -571,22 +571,6 @@ static struct child_process *git_proxy_connect(int fd[2], char *host)
 	return proxy;
 }
 
-static char *get_port(char *host)
-{
-	char *end;
-	char *p = strchr(host, ':');
-
-	if (p) {
-		long port = strtol(p + 1, &end, 10);
-		if (end != p + 1 && *end == '\0' && 0 <= port && port < 65536) {
-			*p = '\0';
-			return p+1;
-		}
-	}
-
-	return NULL;
-}
-
 /*
  * Extract protocol and relevant parts from the specified connection URL.
  * The caller must free() the returned strings.
@@ -742,9 +726,6 @@ struct child_process *git_connect(int fd[2], const char *url,
 			transport_check_allowed("ssh");
 			get_host_and_port(&ssh_host, &port);
 
-			if (!port)
-				port = get_port(ssh_host);
-
 			if (flags & CONNECT_DIAG_URL) {
 				printf("Diag: url=%s\n", url ? url : "NULL");
 				printf("Diag: protocol=%s\n", prot_name(protocol));
-- 
2.8.1.16.g58dac65.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]