Ignore return status of all printf calls consistently, merge
subsequent ones where appropiate, do not memset unneeded dst structure,
simplify/unify option checks, use err not perror, break lines at 80
chars, remove unnecessary parentheses, avoid unobvious integer divsion,
make usage format string and output look alike.

Feedback/OK?

Index: ping.c
===================================================================
RCS file: /cvs/src/sbin/ping/ping.c,v
retrieving revision 1.218
diff -u -p -r1.218 ping.c
--- ping.c      22 Feb 2017 13:43:35 -0000      1.218
+++ ping.c      13 Jun 2017 16:35:03 -0000
@@ -182,10 +182,10 @@ int ident;                        /* process id to 
identify o
int v6flag = 0;                 /* are we ping6? */

/* counters */
-int64_t npackets;              /* max packets to transmit */
+int64_t npackets;              /* max # of packets to transmit */
int64_t nreceived;              /* # of packets we got back */
-int64_t nrepeats;              /* number of duplicates */
-int64_t ntransmitted;          /* sequence # for outbound packets = #sent */
+int64_t nrepeats;              /* # of duplicates */
+int64_t ntransmitted;          /* sequence # for outbound packets = # sent */
int64_t nmissedmax = 1;         /* max value of ntransmitted - nreceived - 1 */
struct timeval interval = {1, 0}; /* interval between packets */

@@ -208,34 +208,34 @@ volatile sig_atomic_t seenalrm;
volatile sig_atomic_t seenint;
volatile sig_atomic_t seeninfo;

-void                    fill(char *, char *);
-void                    summary(void);
-void                    onsignal(int);
-void                    retransmit(int);
-int                     pinger(int);
-const char             *pr_addr(struct sockaddr *, socklen_t);
-void                    pr_pack(u_char *, int, struct msghdr *);
-__dead void             usage(void);
+void            fill(char *, char *);
+void            summary(void);
+void            onsignal(int);
+void            retransmit(int);
+int             pinger(int);
+const char     *pr_addr(struct sockaddr *, socklen_t);
+void            pr_pack(u_char *, int, struct msghdr *);
+__dead void     usage(void);

/* IPv4 specific functions */
-void                    pr_ipopt(int, u_char *);
-int                     in_cksum(u_short *, int);
-void                    pr_icmph(struct icmp *);
-void                    pr_retip(struct ip *);
-void                    pr_iph(struct ip *);
+void            pr_ipopt(int, u_char *);
+int             in_cksum(u_short *, int);
+void            pr_icmph(struct icmp *);
+void            pr_retip(struct ip *);
+void            pr_iph(struct ip *);
#ifndef SMALL
-int                     map_tos(char *, int *);
+int             map_tos(char *, int *);
#endif  /* SMALL */

/* IPv6 specific functions */
-int                     get_hoplim(struct msghdr *);
-int                     get_pathmtu(struct msghdr *, struct sockaddr_in6 *);
-void                    pr_icmph6(struct icmp6_hdr *, u_char *);
-void                    pr_iph6(struct ip6_hdr *);
-void                    pr_exthdrs(struct msghdr *);
-void                    pr_ip6opt(void *);
-void                    pr_rthdr(void *);
-void                    pr_retip6(struct ip6_hdr *, u_char *);
+int             get_hoplim(struct msghdr *);
+int             get_pathmtu(struct msghdr *, struct sockaddr_in6 *);
+void            pr_icmph6(struct icmp6_hdr *, u_char *);
+void            pr_iph6(struct ip6_hdr *);
+void            pr_exthdrs(struct msghdr *);
+void            pr_ip6opt(void *);
+void            pr_rthdr(void *);
+void            pr_retip6(struct ip6_hdr *, u_char *);

int
main(int argc, char *argv[])
@@ -434,8 +434,10 @@ main(int argc, char *argv[])
        if (argc != 1)
                usage();

-       memset(&dst4, 0, sizeof(dst4));
-       memset(&dst6, 0, sizeof(dst6));
+       if (v6flag)
+               memset(&dst6, 0, sizeof(dst6));
+       else
+               memset(&dst4, 0, sizeof(dst4));

        target = *argv;

@@ -562,17 +564,17 @@ main(int argc, char *argv[])
                (void)setsockopt(s, SOL_SOCKET, SO_DEBUG, &optval,
                    sizeof(optval));

-       if ((options & F_FLOOD) && (options & F_INTERVAL))
+       if (options & (F_FLOOD | F_INTERVAL))
                errx(1, "-f and -i options are incompatible");

-       if ((options & F_FLOOD) && (options & (F_AUD_RECV | F_AUD_MISS)))
+       if (options & (F_FLOOD | F_AUD_RECV | F_AUD_MISS))
                warnx("No audible output for flood pings");

        if (datalen >= sizeof(struct payload))       /* can we time transfer */
                timing = 1;

        if (v6flag) {
-               /* in F_VERBOSE case, we may get non-echoreply packets*/
+               /* in F_VERBOSE case, we may get non-echoreply packets */
                if (options & F_VERBOSE && datalen < 2048) /* XXX 2048? */
                        packlen = 2048 + IP6LEN + ECHOLEN + EXTRA;
                else
@@ -621,7 +623,7 @@ main(int argc, char *argv[])
                 * let the kernel pass extension headers of incoming packets,
                 * for privileged socket options
                 */
-               if ((options & F_VERBOSE) != 0) {
+               if (options & F_VERBOSE) {
                        int opton = 1;

                        if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVHOPOPTS,
@@ -696,7 +698,7 @@ main(int argc, char *argv[])
                                options |= F_HDRINCL;
                }

-               if (options & F_RROUTE && options & F_HDRINCL)
+               if (options & (F_RROUTE | F_HDRINCL))
                        errx(1, "-R option and -D or -T, or -t to unicast"
                            " destinations are incompatible");

@@ -717,10 +719,8 @@ main(int argc, char *argv[])
                        else
                                ip->ip_src.s_addr = INADDR_ANY;
                        ip->ip_dst = dst4.sin_addr;
-               }
-
                /* record route option */
-               if (options & F_RROUTE) {
+               } else if (options & F_RROUTE) {
                        if (IN_MULTICAST(ntohl(dst4.sin_addr.s_addr)))
                                errx(1, "record route not valid to multicast"
                                    " destinations");
@@ -729,10 +729,8 @@ main(int argc, char *argv[])
                        rspace[IPOPT_OLEN] = sizeof(rspace)-1;
                        rspace[IPOPT_OFFSET] = IPOPT_MINOFF;
                        if (setsockopt(s, IPPROTO_IP, IP_OPTIONS, rspace,
-                           sizeof(rspace)) < 0) {
-                               perror("ping: record route");
-                               exit(1);
-                       }
+                           sizeof(rspace)) < 0)
+                               err(1, "record route");
                }

                if ((moptions & MULTICAST_NOLOOP) &&
@@ -756,10 +754,10 @@ main(int argc, char *argv[])
        arc4random_buf(&tv64_offset, sizeof(tv64_offset));
        arc4random_buf(&mac_key, sizeof(mac_key));

-       printf("PING %s (", hostname);
+       (void)printf("PING %s (", hostname);
        if (options & F_VERBOSE)
-               printf("%s --> ", pr_addr(from, from->sa_len));
-       printf("%s): %d data bytes\n", pr_addr(dst, dst->sa_len), datalen);
+               (void)printf("%s --> ", pr_addr(from, from->sa_len));
+       (void)printf("%s): %d data bytes\n", pr_addr(dst, dst->sa_len), 
datalen);

        smsghdr.msg_name = dst;
        smsghdr.msg_namelen = dst->sa_len;
@@ -773,7 +771,7 @@ main(int argc, char *argv[])
        (void)signal(SIGINT, onsignal);
        (void)signal(SIGINFO, onsignal);

-       if ((options & F_FLOOD) == 0) {
+       if (!(options & F_FLOOD)) {
                (void)signal(SIGALRM, onsignal);
                itimer.it_interval = interval;
                itimer.it_value = interval;
@@ -861,8 +859,8 @@ main(int argc, char *argv[])
                         * a path MTU notification.)
                         */
                        if ((mtu = get_pathmtu(&m, &dst6)) > 0) {
-                               if ((options & F_VERBOSE) != 0) {
-                                       printf("new path MTU (%d) is "
+                               if (options & F_VERBOSE) {
+                                       (void)printf("new path MTU (%d) is "
                                            "notified\n", mtu);
                                }
                        }
@@ -926,28 +924,28 @@ fill(char *bp, char *patp)
void
summary(void)
{
-       printf("\n--- %s ping statistics ---\n", hostname);
-       printf("%lld packets transmitted, ", ntransmitted);
-       printf("%lld packets received, ", nreceived);
+       (void)printf("\n--- %s ping statistics ---\n"
+           "%lld packets transmitted, %lld packets received, ",
+           hostname, ntransmitted, nreceived);

        if (nrepeats)
-               printf("%lld duplicates, ", nrepeats);
+               (void)printf("%lld duplicates, ", nrepeats);
        if (ntransmitted) {
                if (nreceived > ntransmitted)
-                       printf("-- somebody's duplicating packets!");
+                       (void)printf("-- somebody's duplicating packets!");
                else
-                       printf("%.1f%% packet loss",
-                           ((((double)ntransmitted - nreceived) * 100) /
-                           ntransmitted));
+                       (void)printf("%.1f%% packet loss",
+                           (double)(ntransmitted - nreceived)
+                           * 100 / ntransmitted);
        }
-       printf("\n");
+       (void)printf("\n");
        if (timinginfo) {
                /* Only display average to microseconds */
                double num = nreceived + nrepeats;
                double avg = tsum / num;
                double dev = sqrt(fmax(0, tsumsq / num - avg * avg));
-               printf("round-trip min/avg/max/std-dev = %.3f/%.3f/%.3f/%.3f 
ms\n",
-                   tmin, avg, tmax, dev);
+               (void)printf("round-trip min/avg/max/std-dev = "
+                   "%.3f/%.3f/%.3f/%.3f ms\n", tmin, avg, tmax, dev);
        }
}

@@ -961,7 +959,7 @@ pr_addr(struct sockaddr *addr, socklen_t
        static char buf[NI_MAXHOST];
        int flag = 0;

-       if ((options & F_HOSTNAME) == 0)
+       if (!(options & F_HOSTNAME))
                flag |= NI_NUMERICHOST;

        if (getnameinfo(addr, addrlen, buf, sizeof(buf), NULL, 0, flag) == 0)
@@ -1092,7 +1090,8 @@ pinger(int s)
        if (i < 0 || i != cc) {
                if (i < 0)
                        warn("sendmsg");
-               printf("ping: wrote %s %d chars, ret=%d\n", hostname, cc, i);
+               (void)printf("ping: wrote %s %d chars, ret=%d\n",
+                   hostname, cc, i);
        }
        if (!(options & F_QUIET) && options & F_FLOOD)
                (void)write(STDOUT_FILENO, &DOT, 1);
@@ -1278,11 +1277,9 @@ pr_pack(u_char *buf, int cc, struct msgh
                                                cp = (u_char *)
                                                    &icp->icmp_data[0];
                                        for (i = ECHOLEN; i < cc && i < datalen;
-                                           ++i, ++cp) {
-                                               if ((i % 32) == 8)
-                                                       (void)printf("\n\t");
-                                               (void)printf("%x ", *cp);
-                                       }
+                                           ++i, ++cp)
+                                               (void)printf(i % 32 == 8 ?
+                                                   "\n\t%x " : "%x ", *cp);
                                        break;
                                }
                        }
@@ -1379,7 +1376,7 @@ pr_ipopt(int hlen, u_char *buf)
                            !memcmp(cp, old_rr, i) &&
                            !(options & F_FLOOD)) {
                                (void)printf("\t(same route)");
-                               i = ((i + 3) / 4) * 4;
+                               i = (i + 3) & ~0x3;
                                hlen -= i;
                                cp += i;
                                break;
@@ -1422,8 +1419,8 @@ pr_ipopt(int hlen, u_char *buf)
                        break;
                default:
                        (void)printf("\nunknown option %x", *cp);
-                       hlen = hlen - (cp[IPOPT_OLEN] - 1);
-                       cp = cp + (cp[IPOPT_OLEN] - 1);
+                       hlen -= cp[IPOPT_OLEN] - 1;
+                       cp += cp[IPOPT_OLEN] - 1;
                        break;
                }
        }
@@ -1461,7 +1458,7 @@ in_cksum(u_short *addr, int len)
        sum = (sum >> 16) + (sum & 0xffff);   /* add hi 16 to low 16 */
        sum += (sum >> 16);                       /* add carry */
        answer = ~sum;                          /* truncate to 16 bits */
-       return(answer);
+       return (answer);
}

/*
@@ -1560,8 +1557,7 @@ pr_icmph(struct icmp *icp)
                        (void)printf("Redirect, Unknown Code: %d", 
icp->icmp_code);
                        break;
                }
-               (void)printf("(New addr: %s)\n",
-                   inet_ntoa(icp->icmp_gwaddr));
+               (void)printf("(New addr: %s)\n", inet_ntoa(icp->icmp_gwaddr));
                pr_retip((struct ip *)icp->icmp_data);
                break;
        case ICMP_ECHO:
@@ -1570,8 +1566,8 @@ pr_icmph(struct icmp *icp)
                break;
        case ICMP_ROUTERADVERT:
                /* RFC1256 */
-               (void)printf("Router Discovery Advertisement\n");
-               (void)printf("(%d entries, lifetime %d seconds)\n",
+               (void)printf("Router Discovery Advertisement\n"
+                   "(%d entries, lifetime %d seconds)\n",
                    icp->icmp_num_addrs, ntohs(icp->icmp_lifetime));
                break;
        case ICMP_ROUTERSOLICIT:
@@ -1648,14 +1644,13 @@ pr_iph(struct ip *ip)
        hlen = ip->ip_hl << 2;
        cp = (u_char *)ip + 20;         /* point to options */

-       (void)printf("Vr HL TOS  Len   ID Flg  off TTL Pro  cks      Src      Dst 
Data\n");
-       (void)printf(" %1x  %1x  %02x %04x %04x",
-           ip->ip_v, ip->ip_hl, ip->ip_tos, ip->ip_len, ip->ip_id);
-       (void)printf("   %1x %04x", ((ip->ip_off) & 0xe000) >> 13,
-           (ip->ip_off) & 0x1fff);
-       (void)printf("  %02x  %02x %04x", ip->ip_ttl, ip->ip_p, ip->ip_sum);
-       (void)printf(" %s ", inet_ntoa(*(struct in_addr *)&ip->ip_src.s_addr));
-       (void)printf(" %s ", inet_ntoa(*(struct in_addr *)&ip->ip_dst.s_addr));
+       (void)printf("Vr HL TOS  Len   ID Flg  off TTL Pro  cks      Src      Dst 
Data\n"
+           " %1x  %1x  %02x %04x %04x   %1x %04x  %02x  %02x %04x %s  %s ",
+           ip->ip_v, ip->ip_hl, ip->ip_tos, ip->ip_len, ip->ip_id,
+           ((ip->ip_off) & 0xe000) >> 13, (ip->ip_off) & 0x1fff,
+           ip->ip_ttl, ip->ip_p, ip->ip_sum,
+           inet_ntoa(*(struct in_addr *)&ip->ip_src.s_addr),
+           inet_ntoa(*(struct in_addr *)&ip->ip_dst.s_addr));
        /* dump and option bytes */
        while (hlen-- > 20) {
                (void)printf("%02x", *cp++);
@@ -1679,10 +1674,10 @@ pr_retip(struct ip *ip)

        if (ip->ip_p == 6)
                (void)printf("TCP: from port %u, to port %u (decimal)\n",
-                   (*cp * 256 + *(cp + 1)), (*(cp + 2) * 256 + *(cp + 3)));
+                   *cp * 256 + *(cp + 1), *(cp + 2) * 256 + *(cp + 3));
        else if (ip->ip_p == 17)
                (void)printf("UDP: from port %u, to port %u (decimal)\n",
-                   (*cp * 256 + *(cp + 1)), (*(cp + 2) * 256 + *(cp + 3)));
+                   *cp * 256 + *(cp + 1), *(cp + 2) * 256 + *(cp + 3));
}

#ifndef SMALL
@@ -1747,16 +1742,16 @@ pr_exthdrs(struct msghdr *mhdr)

                switch (cm->cmsg_type) {
                case IPV6_HOPOPTS:
-                       printf("  HbH Options: ");
+                       (void)printf("  HbH Options: ");
                        pr_ip6opt(CMSG_DATA(cm));
                        break;
                case IPV6_DSTOPTS:
                case IPV6_RTHDRDSTOPTS:
-                       printf("  Dst Options: ");
+                       (void)printf("  Dst Options: ");
                        pr_ip6opt(CMSG_DATA(cm));
                        break;
                case IPV6_RTHDR:
-                       printf("  Routing: ");
+                       (void)printf("  Routing: ");
                        pr_rthdr(CMSG_DATA(cm));
                        break;
                }
@@ -1777,7 +1772,7 @@ pr_ip6opt(void *extbuf)

        ext = (struct ip6_hbh *)extbuf;
        extlen = (ext->ip6h_len + 1) * 8;
-       printf("nxt %u, len %u (%lu bytes)\n", ext->ip6h_nxt,
+       (void)printf("nxt %u, len %u (%lu bytes)\n", ext->ip6h_nxt,
            (unsigned int)ext->ip6h_len, (unsigned long)extlen);

        currentlen = 0;
@@ -1793,16 +1788,16 @@ pr_ip6opt(void *extbuf)
                 */
                case IP6OPT_JUMBO:
                        inet6_opt_get_val(databuf, 0, &value4, sizeof(value4));
-                       printf("    Jumbo Payload Opt: Length %u\n",
+                       (void)printf("    Jumbo Payload Opt: Length %u\n",
                            (u_int32_t)ntohl(value4));
                        break;
                case IP6OPT_ROUTER_ALERT:
                        inet6_opt_get_val(databuf, 0, &value2, sizeof(value2));
-                       printf("    Router Alert Opt: Type %u\n",
+                       (void)printf("    Router Alert Opt: Type %u\n",
                            ntohs(value2));
                        break;
                default:
-                       printf("    Received Opt %u len %lu\n",
+                       (void)printf("    Received Opt %u len %lu\n",
                            type, (unsigned long)len);
                        break;
                }
@@ -1819,23 +1814,23 @@ pr_rthdr(void *extbuf)
        int i, segments;

        /* print fixed part of the header */
-       printf("nxt %u, len %u (%d bytes), type %u, ", rh->ip6r_nxt,
+       (void)printf("nxt %u, len %u (%d bytes), type %u, ", rh->ip6r_nxt,
            rh->ip6r_len, (rh->ip6r_len + 1) << 3, rh->ip6r_type);
        if ((segments = inet6_rth_segments(extbuf)) >= 0)
-               printf("%d segments, ", segments);
+               (void)printf("%d segments, ", segments);
        else
-               printf("segments unknown, ");
-       printf("%d left\n", rh->ip6r_segleft);
+               (void)printf("segments unknown, ");
+       (void)printf("%d left\n", rh->ip6r_segleft);

        for (i = 0; i < segments; i++) {
                in6 = inet6_rth_getaddr(extbuf, i);
                if (in6 == NULL)
-                       printf("   [%d]<NULL>\n", i);
+                       (void)printf("   [%d]<NULL>\n", i);
                else {
                        if (!inet_ntop(AF_INET6, in6, ntopbuf,
                            sizeof(ntopbuf)))
                                strncpy(ntopbuf, "?", sizeof(ntopbuf));
-                       printf("   [%d]%s\n", i, ntopbuf);
+                       (void)printf("   [%d]%s\n", i, ntopbuf);
                }
        }

@@ -1892,9 +1887,9 @@ get_pathmtu(struct msghdr *mhdr, struct dst->sin6_scope_id &&
                            mtuctl->ip6m_addr.sin6_scope_id !=
                            dst->sin6_scope_id)) {
-                               if ((options & F_VERBOSE) != 0) {
-                                       printf("path MTU for %s is notified. "
-                                           "(ignored)\n",
+                               if (options & F_VERBOSE) {
+                                       (void)printf("path MTU for %s is "
+                                           "notified. (ignored)\n",
                                            pr_addr((struct sockaddr *)
                                            &mtuctl->ip6m_addr,
                                            sizeof(mtuctl->ip6m_addr)));
@@ -2054,16 +2049,16 @@ pr_iph6(struct ip6_hdr *ip6)
        tc = (tc >> 4) & 0x0f;
        tc |= (ip6->ip6_vfc << 4);

-       printf("Vr TC  Flow Plen Nxt Hlim\n");
-       printf(" %1x %02x %05x %04x  %02x   %02x\n",
+       (void)printf("Vr TC  Flow Plen Nxt Hlim\n"
+           " %1x %02x %05x %04x  %02x   %02x\n",
            (ip6->ip6_vfc & IPV6_VERSION_MASK) >> 4, tc, (u_int32_t)ntohl(flow),
            ntohs(ip6->ip6_plen), ip6->ip6_nxt, ip6->ip6_hlim);
        if (!inet_ntop(AF_INET6, &ip6->ip6_src, ntop_buf, sizeof(ntop_buf)))
                strncpy(ntop_buf, "?", sizeof(ntop_buf));
-       printf("%s->", ntop_buf);
+       (void)printf("%s->", ntop_buf);
        if (!inet_ntop(AF_INET6, &ip6->ip6_dst, ntop_buf, sizeof(ntop_buf)))
                strncpy(ntop_buf, "?", sizeof(ntop_buf));
-       printf("%s\n", ntop_buf);
+       (void)printf("%s\n", ntop_buf);
}

/*
@@ -2077,7 +2072,7 @@ pr_retip6(struct ip6_hdr *ip6, u_char *e
        int hlen;

        if (end - (u_char *)ip6 < sizeof(*ip6)) {
-               printf("IP6");
+               (void)printf("IP6");
                goto trunc;
        }
        pr_iph6(ip6);
@@ -2088,49 +2083,49 @@ pr_retip6(struct ip6_hdr *ip6, u_char *e
        while (end - cp >= 8) {
                switch (nh) {
                case IPPROTO_HOPOPTS:
-                       printf("HBH ");
+                       (void)printf("HBH ");
                        hlen = (((struct ip6_hbh *)cp)->ip6h_len+1) << 3;
                        nh = ((struct ip6_hbh *)cp)->ip6h_nxt;
                        break;
                case IPPROTO_DSTOPTS:
-                       printf("DSTOPT ");
+                       (void)printf("DSTOPT ");
                        hlen = (((struct ip6_dest *)cp)->ip6d_len+1) << 3;
                        nh = ((struct ip6_dest *)cp)->ip6d_nxt;
                        break;
                case IPPROTO_FRAGMENT:
-                       printf("FRAG ");
+                       (void)printf("FRAG ");
                        hlen = sizeof(struct ip6_frag);
                        nh = ((struct ip6_frag *)cp)->ip6f_nxt;
                        break;
                case IPPROTO_ROUTING:
-                       printf("RTHDR ");
+                       (void)printf("RTHDR ");
                        hlen = (((struct ip6_rthdr *)cp)->ip6r_len+1) << 3;
                        nh = ((struct ip6_rthdr *)cp)->ip6r_nxt;
                        break;
                case IPPROTO_AH:
-                       printf("AH ");
+                       (void)printf("AH ");
                        hlen = (((struct ah *)cp)->ah_hl+2) << 2;
                        nh = ((struct ah *)cp)->ah_nh;
                        break;
                case IPPROTO_ICMPV6:
-                       printf("ICMP6: type = %d, code = %d\n",
+                       (void)printf("ICMP6: type = %d, code = %d\n",
                            *cp, *(cp + 1));
                        return;
                case IPPROTO_ESP:
-                       printf("ESP\n");
+                       (void)printf("ESP\n");
                        return;
                case IPPROTO_TCP:
-                       printf("TCP: from port %u, to port %u (decimal)\n",
-                           (*cp * 256 + *(cp + 1)),
-                           (*(cp + 2) * 256 + *(cp + 3)));
+                       (void)printf("TCP: from port %u, to port %u 
(decimal)\n",
+                           *cp * 256 + *(cp + 1),
+                           *(cp + 2) * 256 + *(cp + 3));
                        return;
                case IPPROTO_UDP:
-                       printf("UDP: from port %u, to port %u (decimal)\n",
-                           (*cp * 256 + *(cp + 1)),
-                           (*(cp + 2) * 256 + *(cp + 3)));
+                       (void)printf("UDP: from port %u, to port %u 
(decimal)\n",
+                           *cp * 256 + *(cp + 1),
+                           *(cp + 2) * 256 + *(cp + 3));
                        return;
                default:
-                       printf("Unknown Header(%d)\n", nh);
+                       (void)printf("Unknown Header(%d)\n", nh);
                        return;
                }

@@ -2140,30 +2135,26 @@ pr_retip6(struct ip6_hdr *ip6, u_char *e
        if (end - cp < 8)
                goto trunc;

-       putchar('\n');
+       (void)putchar('\n');
        return;

  trunc:
-       printf("...\n");
+       (void)printf("...\n");
        return;
}

__dead void
usage(void)
{
-       if (v6flag) {
-               (void)fprintf(stderr,
-                   "usage: ping6 [-dEefHLmnqv] [-c count] [-h hoplimit] "
-                   "[-I sourceaddr]\n\t[-i wait] [-l preload] [-p pattern] "
-                   "[-s packetsize] [-V rtable]\n\t[-w maxwait] host\n");
-       } else {
-               (void)fprintf(stderr,
-                   "usage: ping [-DdEefHLnqRv] [-c count] [-I ifaddr]"
-                   " [-i wait]\n\t[-l preload] [-p pattern] [-s packetsize]"
+       (void)fprintf(stderr, v6flag ?
+           "usage: ping6 [-dEefHLmnqv] [-c count] [-h hoplimit] [-I 
sourceaddr]"
+           "\n\t[-i wait] [-l preload] [-p pattern] [-s packetsize] [-V 
rtable]"
+           "\n\t[-w maxwait] host\n" :
+           "usage: ping [-DdEefHLnqRv] [-c count] [-I ifaddr] [-i wait]"
+           "\n\t[-l preload] [-p pattern] [-s packetsize]"
#ifndef SMALL
-                   " [-T toskeyword]"
+           " [-T toskeyword]"
#endif  /* SMALL */
-                   "\n\t[-t ttl] [-V rtable] [-w maxwait] host\n");
-       }
+           "\n\t[-t ttl] [-V rtable] [-w maxwait] host\n");
        exit(1);
}

Reply via email to