- 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.
diff --git a/networking/ping.c b/networking/ping.c
index 0b33abf..382389d 100644
--- a/networking/ping.c
+++ b/networking/ping.c
@@ -209,7 +209,7 @@
alarm(5); /* give the host 5000ms to respond */
#if ENABLE_PING6
- if (lsa->sa.sa_family == AF_INET6)
+ if (lsa->u.sa.sa_family == AF_INET6)
ping6(lsa);
else
#endif
@@ -532,12 +532,12 @@
int sockopt;
pingsock = create_icmp_socket();
- pingaddr.sin = lsa->sin;
+ pingaddr.sin = lsa->u.sin;
if (source_lsa) {
if (setsockopt(pingsock, IPPROTO_IP, IP_MULTICAST_IF,
- &source_lsa->sa, source_lsa->len))
+ &source_lsa->u.sa, source_lsa->len))
bb_error_msg_and_die("can't set multicast source interface");
- xbind(pingsock, &source_lsa->sa, source_lsa->len);
+ xbind(pingsock, &source_lsa->u.sa, source_lsa->len);
}
if (opt_I)
setsockopt(pingsock, SOL_SOCKET, SO_BINDTODEVICE, opt_I, strlen(opt_I) + 1);
@@ -584,10 +584,10 @@
char control_buf[CMSG_SPACE(36)];
pingsock = create_icmp6_socket();
- pingaddr.sin6 = lsa->sin6;
+ pingaddr.sin6 = lsa->u.sin6;
/* untested whether "-I addr" really works for IPv6: */
if (source_lsa)
- xbind(pingsock, &source_lsa->sa, source_lsa->len);
+ xbind(pingsock, &source_lsa->u.sa, source_lsa->len);
if (opt_I)
setsockopt(pingsock, SOL_SOCKET, SO_BINDTODEVICE, opt_I, strlen(opt_I) + 1);
@@ -670,12 +670,12 @@
printf("PING %s (%s)", hostname, dotted);
if (source_lsa) {
printf(" from %s",
- xmalloc_sockaddr2dotted_noport(&source_lsa->sa));
+ xmalloc_sockaddr2dotted_noport(&source_lsa->u.sa));
}
printf(": %d data bytes\n", datalen);
#if ENABLE_PING6
- if (lsa->sa.sa_family == AF_INET6)
+ if (lsa->u.sa.sa_family == AF_INET6)
ping6(lsa);
else
#endif
@@ -720,11 +720,11 @@
lsa = xhost_and_af2sockaddr(hostname, 0, AF_INET);
#endif
- if (source_lsa && source_lsa->sa.sa_family != lsa->sa.sa_family)
+ if (source_lsa && source_lsa->u.sa.sa_family != lsa->u.sa.sa_family)
/* leaking it here... */
source_lsa = NULL;
- dotted = xmalloc_sockaddr2dotted_noport(&lsa->sa);
+ dotted = xmalloc_sockaddr2dotted_noport(&lsa->u.sa);
ping(lsa);
pingstats(0);
return EXIT_SUCCESS;