httpd: sendfile support
[oweals/busybox.git] / networking / traceroute.c
index 9fc15d3900dd94cd3d7cb1f9676074dc67d87f14..20f304d53a842586846d79569abcdaa2147897b4 100644 (file)
@@ -397,8 +397,8 @@ ifaddrlist(struct IFADDRLIST **ipaddrp)
        ) {
                if (errno == EINVAL)
                        bb_error_msg_and_die(
-                           "SIOCGIFCONF: ifreq struct too small (%d bytes)",
-                           IFREQ_BUFSIZE * sizeof(ibuf[0]));
+                           "SIOCGIFCONF: ifreq struct too small (%u bytes)",
+                           (unsigned)(IFREQ_BUFSIZE * sizeof(ibuf[0])));
                bb_perror_msg_and_die("SIOCGIFCONF");
        }
        ifrp = ibuf;
@@ -445,8 +445,8 @@ ifaddrlist(struct IFADDRLIST **ipaddrp)
                if (strchr(al->device, ':') != NULL)
                        continue;
 #endif
-               if (ioctl(fd, SIOCGIFADDR, (char *)&ifr) < 0)
-                       bb_perror_msg_and_die("SIOCGIFADDR: %s", al->device);
+               ioctl_or_perror_and_die(fd, SIOCGIFADDR, (char *)&ifr,
+                               "SIOCGIFADDR: %s", al->device);
 
                addr_sin = (struct sockaddr_in *)&ifr.ifr_addr;
                al->addr = addr_sin->sin_addr.s_addr;
@@ -700,7 +700,7 @@ send_probe(int seq, int ttl)
 static inline const char *
 pr_type(unsigned char t)
 {
-       static const char * const ttab[] = {
+       static const char *const ttab[] = {
        "Echo Reply",   "ICMP 1",       "ICMP 2",       "Dest Unreachable",
        "Source Quench", "Redirect",    "ICMP 6",       "ICMP 7",
        "Echo",         "Router Advert", "Router Solicit", "Time Exceeded",
@@ -802,22 +802,20 @@ packet_ok(unsigned char *buf, int cc, struct sockaddr_in *from, int seq)
  * numeric value, otherwise try for symbolic name.
  */
 static inline void
-inetname(struct sockaddr_in *from)
+print_inetname(struct sockaddr_in *from)
 {
-       const char *n = NULL;
        const char *ina;
-       char name[257];
 
-       if (!nflag && from->sin_addr.s_addr != INADDR_ANY) {
-               if (INET_rresolve(name, sizeof(name), from, 0x4000,
-                                               0xffffffff) >= 0)
-                       n = name;
-       }
        ina = inet_ntoa(from->sin_addr);
        if (nflag)
                printf(" %s", ina);
-       else
+       else {
+               char *n = NULL;
+               if (from->sin_addr.s_addr != INADDR_ANY)
+                       n = xmalloc_sockaddr2host_noport((struct sockaddr*)from, sizeof(*from));
                printf(" %s (%s)", (n ? n : ina), ina);
+               free(n);
+       }
 }
 
 static inline void
@@ -830,7 +828,7 @@ print(unsigned char *buf, int cc, struct sockaddr_in *from)
        hlen = ip->ip_hl << 2;
        cc -= hlen;
 
-       inetname(from);
+       print_inetname(from);
 #if ENABLE_FEATURE_TRACEROUTE_VERBOSE
        if (verbose)
                printf(" %d bytes to %s", cc, inet_ntoa(ip->ip_dst));