diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2008-01-29 10:33:34 +0000 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2008-01-29 10:33:34 +0000 |
commit | 8c69afd992d7cc6c2fc7dea59c3c2bd3f3c21f15 (patch) | |
tree | 998a337ecd57b737423a3793365519213f97da72 /libbb | |
parent | c882f341cec8451ee87af6746abb7208272d5b1a (diff) | |
download | busybox-8c69afd992d7cc6c2fc7dea59c3c2bd3f3c21f15.tar.gz |
- be C99 friendly. Anonymous unions are a GNU extension. This change is
size-neutral WRT -std=gnu99 and fixes several compilation errors for strict
C99 mode.
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/xconnect.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/libbb/xconnect.c b/libbb/xconnect.c index 91c12f4d3..03ae77329 100644 --- a/libbb/xconnect.c +++ b/libbb/xconnect.c @@ -99,13 +99,13 @@ int get_nport(const struct sockaddr *sa) void set_nport(len_and_sockaddr *lsa, unsigned port) { #if ENABLE_FEATURE_IPV6 - if (lsa->sa.sa_family == AF_INET6) { - lsa->sin6.sin6_port = port; + if (lsa->u.sa.sa_family == AF_INET6) { + lsa->u.sin6.sin6_port = port; return; } #endif - if (lsa->sa.sa_family == AF_INET) { - lsa->sin.sin_port = port; + if (lsa->u.sa.sa_family == AF_INET) { + lsa->u.sin.sin_port = port; return; } /* What? UNIX socket? IPX?? :) */ @@ -182,9 +182,9 @@ USE_FEATURE_IPV6(sa_family_t af,) } } #endif - r = xmalloc(offsetof(len_and_sockaddr, sa) + used_res->ai_addrlen); + r = xmalloc(offsetof(len_and_sockaddr, u.sa) + used_res->ai_addrlen); r->len = used_res->ai_addrlen; - memcpy(&r->sa, used_res->ai_addr, used_res->ai_addrlen); + memcpy(&r->u.sa, used_res->ai_addr, used_res->ai_addrlen); set_nport(r, htons(port)); ret: freeaddrinfo(result); @@ -246,9 +246,9 @@ int xsocket_type(len_and_sockaddr **lsap, USE_FEATURE_IPV6(int family,) int sock len = sizeof(struct sockaddr_in6); } #endif - lsa = xzalloc(offsetof(len_and_sockaddr, sa) + len); + lsa = xzalloc(offsetof(len_and_sockaddr, u.sa) + len); lsa->len = len; - lsa->sa.sa_family = family; + lsa->u.sa.sa_family = family; *lsap = lsa; return fd; } @@ -266,13 +266,13 @@ static int create_and_bind_or_die(const char *bindaddr, int port, int sock_type) if (bindaddr && bindaddr[0]) { lsa = xdotted2sockaddr(bindaddr, port); /* user specified bind addr dictates family */ - fd = xsocket(lsa->sa.sa_family, sock_type, 0); + fd = xsocket(lsa->u.sa.sa_family, sock_type, 0); } else { fd = xsocket_type(&lsa, USE_FEATURE_IPV6(AF_UNSPEC,) sock_type); set_nport(lsa, htons(port)); } setsockopt_reuseaddr(fd); - xbind(fd, &lsa->sa, lsa->len); + xbind(fd, &lsa->u.sa, lsa->len); free(lsa); return fd; } @@ -294,17 +294,17 @@ int create_and_connect_stream_or_die(const char *peer, int port) len_and_sockaddr *lsa; lsa = xhost2sockaddr(peer, port); - fd = xsocket(lsa->sa.sa_family, SOCK_STREAM, 0); + fd = xsocket(lsa->u.sa.sa_family, SOCK_STREAM, 0); setsockopt_reuseaddr(fd); - xconnect(fd, &lsa->sa, lsa->len); + xconnect(fd, &lsa->u.sa, lsa->len); free(lsa); return fd; } int xconnect_stream(const len_and_sockaddr *lsa) { - int fd = xsocket(lsa->sa.sa_family, SOCK_STREAM, 0); - xconnect(fd, &lsa->sa, lsa->len); + int fd = xsocket(lsa->u.sa.sa_family, SOCK_STREAM, 0); + xconnect(fd, &lsa->u.sa, lsa->len); return fd; } |