aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2011-01-20 12:13:23 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2011-01-20 12:13:23 +0100
commitdd169e84683aa7be3604d491f1c34ab657973365 (patch)
tree58e29fb6c65452a5e50224f1e3b83de73de29812
parentb3b6c8bdf23d30c57d92458f1aac93ce84bf81a7 (diff)
downloadbusybox-w32-dd169e84683aa7be3604d491f1c34ab657973365.tar.gz
busybox-w32-dd169e84683aa7be3604d491f1c34ab657973365.tar.bz2
busybox-w32-dd169e84683aa7be3604d491f1c34ab657973365.zip
eliminate aliasing warnings in traceroute.c and udhcp/socket.c
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/traceroute.c3
-rw-r--r--networking/udhcp/socket.c25
2 files changed, 16 insertions, 12 deletions
diff --git a/networking/traceroute.c b/networking/traceroute.c
index c18fba8d0..82bb0118c 100644
--- a/networking/traceroute.c
+++ b/networking/traceroute.c
@@ -751,7 +751,8 @@ print(int read_len, const struct sockaddr *from, const struct sockaddr *to)
751 } else 751 } else
752#endif 752#endif
753 { 753 {
754 read_len -= ((struct ip*)recv_pkt)->ip_hl << 2; 754 struct ip *ip4packet = (struct ip*)recv_pkt;
755 read_len -= ip4packet->ip_hl << 2;
755 } 756 }
756 printf(" %d bytes to %s", read_len, ina); 757 printf(" %d bytes to %s", read_len, ina);
757 free(ina); 758 free(ina);
diff --git a/networking/udhcp/socket.c b/networking/udhcp/socket.c
index 0ed7ad1c6..39f1cec54 100644
--- a/networking/udhcp/socket.c
+++ b/networking/udhcp/socket.c
@@ -36,42 +36,45 @@
36 36
37int FAST_FUNC udhcp_read_interface(const char *interface, int *ifindex, uint32_t *nip, uint8_t *mac) 37int FAST_FUNC udhcp_read_interface(const char *interface, int *ifindex, uint32_t *nip, uint8_t *mac)
38{ 38{
39 /* char buffer instead of bona-fide struct avoids aliasing warning */
40 char ifr_buf[sizeof(struct ifreq)];
41 struct ifreq *const ifr = (void *)ifr_buf;
42
39 int fd; 43 int fd;
40 struct ifreq ifr;
41 struct sockaddr_in *our_ip; 44 struct sockaddr_in *our_ip;
42 45
43 memset(&ifr, 0, sizeof(ifr)); 46 memset(ifr, 0, sizeof(*ifr));
44 fd = xsocket(AF_INET, SOCK_RAW, IPPROTO_RAW); 47 fd = xsocket(AF_INET, SOCK_RAW, IPPROTO_RAW);
45 48
46 ifr.ifr_addr.sa_family = AF_INET; 49 ifr->ifr_addr.sa_family = AF_INET;
47 strncpy_IFNAMSIZ(ifr.ifr_name, interface); 50 strncpy_IFNAMSIZ(ifr->ifr_name, interface);
48 if (nip) { 51 if (nip) {
49 if (ioctl_or_perror(fd, SIOCGIFADDR, &ifr, 52 if (ioctl_or_perror(fd, SIOCGIFADDR, ifr,
50 "is interface %s up and configured?", interface) 53 "is interface %s up and configured?", interface)
51 ) { 54 ) {
52 close(fd); 55 close(fd);
53 return -1; 56 return -1;
54 } 57 }
55 our_ip = (struct sockaddr_in *) &ifr.ifr_addr; 58 our_ip = (struct sockaddr_in *) &ifr->ifr_addr;
56 *nip = our_ip->sin_addr.s_addr; 59 *nip = our_ip->sin_addr.s_addr;
57 log1("IP %s", inet_ntoa(our_ip->sin_addr)); 60 log1("IP %s", inet_ntoa(our_ip->sin_addr));
58 } 61 }
59 62
60 if (ifindex) { 63 if (ifindex) {
61 if (ioctl_or_warn(fd, SIOCGIFINDEX, &ifr) != 0) { 64 if (ioctl_or_warn(fd, SIOCGIFINDEX, ifr) != 0) {
62 close(fd); 65 close(fd);
63 return -1; 66 return -1;
64 } 67 }
65 log1("Adapter index %d", ifr.ifr_ifindex); 68 log1("Adapter index %d", ifr->ifr_ifindex);
66 *ifindex = ifr.ifr_ifindex; 69 *ifindex = ifr->ifr_ifindex;
67 } 70 }
68 71
69 if (mac) { 72 if (mac) {
70 if (ioctl_or_warn(fd, SIOCGIFHWADDR, &ifr) != 0) { 73 if (ioctl_or_warn(fd, SIOCGIFHWADDR, ifr) != 0) {
71 close(fd); 74 close(fd);
72 return -1; 75 return -1;
73 } 76 }
74 memcpy(mac, ifr.ifr_hwaddr.sa_data, 6); 77 memcpy(mac, ifr->ifr_hwaddr.sa_data, 6);
75 log1("MAC %02x:%02x:%02x:%02x:%02x:%02x", 78 log1("MAC %02x:%02x:%02x:%02x:%02x:%02x",
76 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); 79 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
77 } 80 }