Commit Diff


commit - 6568f0aa4b5fbbbb938dc9e31e3d6232fb5e6a6e
commit + 275b5ade3a9d9c9850dd0e6f3129bdd58e4a3756
blob - 494266302771918d3735d165c8cf705f14b63094
blob + dfb47996e8b7eaac5442189c1f90ca704f69906f
--- gotwebd/sockets.c
+++ gotwebd/sockets.c
@@ -75,7 +75,6 @@ void	 sockets_rlimit(int);
 int	 sockets_dispatch_gotwebd(int, struct privsep_proc *, struct imsg *);
 int	 sockets_unix_socket_listen(struct privsep *, struct socket *);
 int	 sockets_create_socket(struct addresslist *, in_port_t);
-int	 sockets_socket_af(struct sockaddr_storage *, in_port_t);
 int	 sockets_accept_reserve(int, struct sockaddr *, socklen_t *, int,
 	    volatile int *);
 
@@ -290,33 +289,6 @@ done:
 	return (sock);
 }
 
-int
-sockets_socket_af(struct sockaddr_storage *ss, in_port_t port)
-{
-	switch (ss->ss_family) {
-	case AF_INET:
-		((struct sockaddr_in *)ss)->sin_port = port;
-/* TA: Iffy... */
-#ifndef __linux__
-		((struct sockaddr_in *)ss)->sin_len =
-		    sizeof(struct sockaddr_in);
-#endif
-		break;
-	case AF_INET6:
-		((struct sockaddr_in6 *)ss)->sin6_port = port;
-/* TA: Iffy... */
-#ifndef __linux__
-		((struct sockaddr_in6 *)ss)->sin6_len =
-		    sizeof(struct sockaddr_in6);
-#endif
-		break;
-	default:
-		return -1;
-	}
-
-	return 0;
-}
-
 void
 sockets_launch(void)
 {
@@ -569,8 +541,15 @@ sockets_create_socket(struct addresslist *al, in_port_
 	hints.ai_flags |= AI_PASSIVE;
 
 	TAILQ_FOREACH(a, al, entry) {
-		if (sockets_socket_af(&a->ss, port) == -1) {
-			log_warnx("%s: sockets_socket_af", __func__);
+		switch (a->ss.ss_family) {
+		case AF_INET:
+			((struct sockaddr_in *)(&a->ss))->sin_port = port;
+			break;
+		case AF_INET6:
+			((struct sockaddr_in6 *)(&a->ss))->sin6_port = port;
+			break;
+		default:
+			log_warnx("%s: unknown address family", __func__);
 			goto fail;
 		}