Date: Mon, 20 Oct 2014 00:27:40 +0000 (UTC) From: Hiroki Sato <hrs@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r273295 - in head/sbin: ping ping6 Message-ID: <201410200027.s9K0RegN062458@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: hrs Date: Mon Oct 20 00:27:40 2014 New Revision: 273295 URL: https://svnweb.freebsd.org/changeset/base/273295 Log: WARNS=3 and style fixes. No functionality change. Modified: head/sbin/ping/Makefile head/sbin/ping/ping.c head/sbin/ping6/Makefile head/sbin/ping6/ping6.c Modified: head/sbin/ping/Makefile ============================================================================== --- head/sbin/ping/Makefile Mon Oct 20 00:22:08 2014 (r273294) +++ head/sbin/ping/Makefile Mon Oct 20 00:27:40 2014 (r273295) @@ -7,7 +7,7 @@ PROG= ping MAN= ping.8 BINOWN= root BINMODE=4555 -WARNS?= 2 +WARNS?= 3 DPADD= ${LIBM} LDADD= -lm Modified: head/sbin/ping/ping.c ============================================================================== --- head/sbin/ping/ping.c Mon Oct 20 00:22:08 2014 (r273294) +++ head/sbin/ping/ping.c Mon Oct 20 00:27:40 2014 (r273295) @@ -122,7 +122,7 @@ struct tv32 { }; /* various options */ -int options; +static int options; #define F_FLOOD 0x0001 #define F_INTERVAL 0x0002 #define F_NUMERIC 0x0004 @@ -157,52 +157,52 @@ int options; * to 8192 for complete accuracy... */ #define MAX_DUP_CHK (8 * 128) -int mx_dup_ck = MAX_DUP_CHK; -char rcvd_tbl[MAX_DUP_CHK / 8]; +static int mx_dup_ck = MAX_DUP_CHK; +static char rcvd_tbl[MAX_DUP_CHK / 8]; -struct sockaddr_in whereto; /* who to ping */ -int datalen = DEFDATALEN; -int maxpayload; -int ssend; /* send socket file descriptor */ -int srecv; /* receive socket file descriptor */ -u_char outpackhdr[IP_MAXPACKET], *outpack; -char BBELL = '\a'; /* characters written for MISSED and AUDIBLE */ -char BSPACE = '\b'; /* characters written for flood */ -char DOT = '.'; -char *hostname; -char *shostname; -int ident; /* process id to identify our packets */ -int uid; /* cached uid for micro-optimization */ -u_char icmp_type = ICMP_ECHO; -u_char icmp_type_rsp = ICMP_ECHOREPLY; -int phdr_len = 0; -int send_len; +static struct sockaddr_in whereto; /* who to ping */ +static int datalen = DEFDATALEN; +static int maxpayload; +static int ssend; /* send socket file descriptor */ +static int srecv; /* receive socket file descriptor */ +static u_char outpackhdr[IP_MAXPACKET], *outpack; +static char BBELL = '\a'; /* characters written for MISSED and AUDIBLE */ +static char BSPACE = '\b'; /* characters written for flood */ +static char DOT = '.'; +static char *hostname; +static char *shostname; +static int ident; /* process id to identify our packets */ +static int uid; /* cached uid for micro-optimization */ +static u_char icmp_type = ICMP_ECHO; +static u_char icmp_type_rsp = ICMP_ECHOREPLY; +static int phdr_len = 0; +static int send_len; /* counters */ -long nmissedmax; /* max value of ntransmitted - nreceived - 1 */ -long npackets; /* max packets to transmit */ -long nreceived; /* # of packets we got back */ -long nrepeats; /* number of duplicates */ -long ntransmitted; /* sequence # for outbound packets = #sent */ -long snpackets; /* max packets to transmit in one sweep */ -long snreceived; /* # of packets we got back in this sweep */ -long sntransmitted; /* # of packets we sent in this sweep */ -int sweepmax; /* max value of payload in sweep */ -int sweepmin = 0; /* start value of payload in sweep */ -int sweepincr = 1; /* payload increment in sweep */ -int interval = 1000; /* interval between packets, ms */ -int waittime = MAXWAIT; /* timeout for each packet */ -long nrcvtimeout = 0; /* # of packets we got back after waittime */ +static long nmissedmax; /* max value of ntransmitted - nreceived - 1 */ +static long npackets; /* max packets to transmit */ +static long nreceived; /* # of packets we got back */ +static long nrepeats; /* number of duplicates */ +static long ntransmitted; /* sequence # for outbound packets = #sent */ +static long snpackets; /* max packets to transmit in one sweep */ +static long sntransmitted; /* # of packets we sent in this sweep */ +static int sweepmax; /* max value of payload in sweep */ +static int sweepmin = 0; /* start value of payload in sweep */ +static int sweepincr = 1; /* payload increment in sweep */ +static int interval = 1000; /* interval between packets, ms */ +static int waittime = MAXWAIT; /* timeout for each packet */ +static long nrcvtimeout = 0; /* # of packets we got back after waittime */ /* timing */ -int timing; /* flag to do timing */ -double tmin = 999999999.0; /* minimum round trip time */ -double tmax = 0.0; /* maximum round trip time */ -double tsum = 0.0; /* sum of all times, for doing average */ -double tsumsq = 0.0; /* sum of all times squared, for std. dev. */ - -volatile sig_atomic_t finish_up; /* nonzero if we've been told to finish up */ -volatile sig_atomic_t siginfo_p; +static int timing; /* flag to do timing */ +static double tmin = 999999999.0; /* minimum round trip time */ +static double tmax = 0.0; /* maximum round trip time */ +static double tsum = 0.0; /* sum of all times, for doing average */ +static double tsumsq = 0.0; /* sum of all times squared, for std. dev. */ + +/* nonzero if we've been told to finish up */ +static volatile sig_atomic_t finish_up; +static volatile sig_atomic_t siginfo_p; #ifdef HAVE_LIBCAPSICUM static cap_channel_t *capdns; @@ -1150,7 +1150,8 @@ pr_pack(char *buf, int cc, struct sockad #endif tp = (const char *)tp + phdr_len; - if (cc - ICMP_MINLEN - phdr_len >= sizeof(tv1)) { + if ((size_t)(cc - ICMP_MINLEN - phdr_len) >= + sizeof(tv1)) { /* Copy to avoid alignment problems: */ memcpy(&tv32, tp, sizeof(tv32)); tv1.tv_sec = ntohl(tv32.tv32_sec); Modified: head/sbin/ping6/Makefile ============================================================================== --- head/sbin/ping6/Makefile Mon Oct 20 00:22:08 2014 (r273294) +++ head/sbin/ping6/Makefile Mon Oct 20 00:27:40 2014 (r273295) @@ -5,7 +5,7 @@ MAN= ping6.8 CFLAGS+=-DIPSEC -DKAME_SCOPEID -DUSE_RFC2292BIS \ -DHAVE_ARC4RANDOM -WARNS?= 2 +WARNS?= 3 BINOWN= root BINMODE=4555 Modified: head/sbin/ping6/ping6.c ============================================================================== --- head/sbin/ping6/ping6.c Mon Oct 20 00:22:08 2014 (r273294) +++ head/sbin/ping6/ping6.c Mon Oct 20 00:27:40 2014 (r273295) @@ -205,84 +205,83 @@ u_int options; * to 8192 for complete accuracy... */ #define MAX_DUP_CHK (8 * 8192) -int mx_dup_ck = MAX_DUP_CHK; -char rcvd_tbl[MAX_DUP_CHK / 8]; +static int mx_dup_ck = MAX_DUP_CHK; +static char rcvd_tbl[MAX_DUP_CHK / 8]; -struct sockaddr_in6 dst; /* who to ping6 */ -struct sockaddr_in6 src; /* src addr of this packet */ -socklen_t srclen; -int datalen = DEFDATALEN; -int s; /* socket file descriptor */ -u_char outpack[MAXPACKETLEN]; -char BSPACE = '\b'; /* characters written for flood */ -char BBELL = '\a'; /* characters written for AUDIBLE */ -char DOT = '.'; -char *hostname; -int ident; /* process id to identify our packets */ -u_int8_t nonce[8]; /* nonce field for node information */ -int hoplimit = -1; /* hoplimit */ -int pathmtu = 0; /* path MTU for the destination. 0 = unspec. */ -u_char *packet = NULL; +static struct sockaddr_in6 dst; /* who to ping6 */ +static struct sockaddr_in6 src; /* src addr of this packet */ +static socklen_t srclen; +static size_t datalen = DEFDATALEN; +static int s; /* socket file descriptor */ +static u_char outpack[MAXPACKETLEN]; +static char BSPACE = '\b'; /* characters written for flood */ +static char BBELL = '\a'; /* characters written for AUDIBLE */ +static char DOT = '.'; +static char *hostname; +static int ident; /* process id to identify our packets */ +static u_int8_t nonce[8]; /* nonce field for node information */ +static int hoplimit = -1; /* hoplimit */ +static u_char *packet = NULL; /* counters */ -long nmissedmax; /* max value of ntransmitted - nreceived - 1 */ -long npackets; /* max packets to transmit */ -long nreceived; /* # of packets we got back */ -long nrepeats; /* number of duplicates */ -long ntransmitted; /* sequence # for outbound packets = #sent */ -int interval = 1000; /* interval between packets in ms */ -int waittime = MAXWAIT; /* timeout for each packet */ -long nrcvtimeout = 0; /* # of packets we got back after waittime */ +static long nmissedmax; /* max value of ntransmitted - nreceived - 1 */ +static long npackets; /* max packets to transmit */ +static long nreceived; /* # of packets we got back */ +static long nrepeats; /* number of duplicates */ +static long ntransmitted; /* sequence # for outbound packets = #sent */ +static int interval = 1000; /* interval between packets in ms */ +static int waittime = MAXWAIT; /* timeout for each packet */ +static long nrcvtimeout = 0; /* # of packets we got back after waittime */ /* timing */ -int timing; /* flag to do timing */ -double tmin = 999999999.0; /* minimum round trip time */ -double tmax = 0.0; /* maximum round trip time */ -double tsum = 0.0; /* sum of all times, for doing average */ -double tsumsq = 0.0; /* sum of all times squared, for std. dev. */ +static int timing; /* flag to do timing */ +static double tmin = 999999999.0; /* minimum round trip time */ +static double tmax = 0.0; /* maximum round trip time */ +static double tsum = 0.0; /* sum of all times, for doing average */ +static double tsumsq = 0.0; /* sum of all times squared, for std. dev. */ /* for node addresses */ -u_short naflags; +static u_short naflags; /* for ancillary data(advanced API) */ -struct msghdr smsghdr; -struct iovec smsgiov; -char *scmsg = 0; +static struct msghdr smsghdr; +static struct iovec smsgiov; +static char *scmsg = 0; -volatile sig_atomic_t seenint; +static volatile sig_atomic_t seenint; #ifdef SIGINFO -volatile sig_atomic_t seeninfo; +static volatile sig_atomic_t seeninfo; #endif int main(int, char *[]); -void fill(char *, char *); -int get_hoplim(struct msghdr *); -int get_pathmtu(struct msghdr *); -struct in6_pktinfo *get_rcvpktinfo(struct msghdr *); -void onsignal(int); -void onint(int); -size_t pingerlen(void); -int pinger(void); -const char *pr_addr(struct sockaddr *, int); -void pr_icmph(struct icmp6_hdr *, u_char *); -void pr_iph(struct ip6_hdr *); -void pr_suptypes(struct icmp6_nodeinfo *, size_t); -void pr_nodeaddr(struct icmp6_nodeinfo *, int); -int myechoreply(const struct icmp6_hdr *); -int mynireply(const struct icmp6_nodeinfo *); -char *dnsdecode(const u_char **, const u_char *, const u_char *, - char *, size_t); -void pr_pack(u_char *, int, struct msghdr *); -void pr_exthdrs(struct msghdr *); -void pr_ip6opt(void *, size_t); -void pr_rthdr(void *, size_t); -int pr_bitrange(u_int32_t, int, int); -void pr_retip(struct ip6_hdr *, u_char *); -void summary(void); -void tvsub(struct timeval *, struct timeval *); -int setpolicy(int, char *); -char *nigroup(char *, int); -void usage(void); +static void fill(char *, char *); +static int get_hoplim(struct msghdr *); +static int get_pathmtu(struct msghdr *); +static struct in6_pktinfo *get_rcvpktinfo(struct msghdr *); +static void onsignal(int); +static void onint(int); +static size_t pingerlen(void); +static int pinger(void); +static const char *pr_addr(struct sockaddr *, int); +static void pr_icmph(struct icmp6_hdr *, u_char *); +static void pr_iph(struct ip6_hdr *); +static void pr_suptypes(struct icmp6_nodeinfo *, size_t); +static void pr_nodeaddr(struct icmp6_nodeinfo *, int); +static int myechoreply(const struct icmp6_hdr *); +static int mynireply(const struct icmp6_nodeinfo *); +static char *dnsdecode(const u_char **, const u_char *, const u_char *, + char *, size_t); +static void pr_pack(u_char *, int, struct msghdr *); +static void pr_exthdrs(struct msghdr *); +static void pr_ip6opt(void *, size_t); +static void pr_rthdr(void *, size_t); +static int pr_bitrange(u_int32_t, int, int); +static void pr_retip(struct ip6_hdr *, u_char *); +static void summary(void); +static void tvsub(struct timeval *, struct timeval *); +static int setpolicy(int, char *); +static char *nigroup(char *, int); +static void usage(void); int main(int argc, char *argv[]) @@ -390,9 +389,9 @@ main(int argc, char *argv[]) errno = 0; e = NULL; lsockbufsize = strtoul(optarg, &e, 10); - sockbufsize = lsockbufsize; + sockbufsize = (int)lsockbufsize; if (errno || !*optarg || *e || - sockbufsize != lsockbufsize) + lsockbufsize > INT_MAX) errx(1, "invalid socket buffer size"); #else errx(1, @@ -751,7 +750,7 @@ main(int argc, char *argv[]) *((int *)&nonce[i]) = rand(); #else memset(nonce, 0, sizeof(nonce)); - for (i = 0; i < sizeof(nonce); i += sizeof(u_int32_t)) + for (i = 0; i < (int)sizeof(nonce); i += sizeof(u_int32_t)) *((u_int32_t *)&nonce[i]) = arc4random(); #endif optval = 1; @@ -1009,7 +1008,7 @@ main(int argc, char *argv[]) #if defined(SO_SNDBUF) && defined(SO_RCVBUF) if (sockbufsize) { - if (datalen > sockbufsize) + if (datalen > (size_t)sockbufsize) warnx("you need -b to increase socket buffer size"); if (setsockopt(s, SOL_SOCKET, SO_SNDBUF, &sockbufsize, sizeof(sockbufsize)) < 0) @@ -1222,7 +1221,7 @@ main(int argc, char *argv[]) exit(nreceived == 0 ? 2 : 0); } -void +static void onsignal(int sig) { @@ -1247,7 +1246,7 @@ onsignal(int sig) * of the data portion are used to hold a UNIX "timeval" struct in VAX * byte-order, to compute the round-trip time. */ -size_t +static size_t pingerlen(void) { size_t l; @@ -1266,7 +1265,7 @@ pingerlen(void) return l; } -int +static int pinger(void) { struct icmp6_hdr *icp; @@ -1381,7 +1380,7 @@ pinger(void) return(0); } -int +static int myechoreply(const struct icmp6_hdr *icp) { if (ntohs(icp->icmp6_id) == ident) @@ -1390,7 +1389,7 @@ myechoreply(const struct icmp6_hdr *icp) return 0; } -int +static int mynireply(const struct icmp6_nodeinfo *nip) { if (memcmp(nip->icmp6_ni_nonce + sizeof(u_int16_t), @@ -1401,7 +1400,7 @@ mynireply(const struct icmp6_nodeinfo *n return 0; } -char * +static char * dnsdecode(const u_char **sp, const u_char *ep, const u_char *base, char *buf, size_t bufsiz) /*base for compressed name*/ @@ -1445,7 +1444,7 @@ dnsdecode(const u_char **sp, const u_cha while (i-- > 0 && cp < ep) { l = snprintf(cresult, sizeof(cresult), isprint(*cp) ? "%c" : "\\%03o", *cp & 0xff); - if (l >= sizeof(cresult) || l < 0) + if ((size_t)l >= sizeof(cresult) || l < 0) return NULL; if (strlcat(buf, cresult, bufsiz) >= bufsiz) return NULL; /*result overrun*/ @@ -1468,7 +1467,7 @@ dnsdecode(const u_char **sp, const u_cha * which arrive ('tis only fair). This permits multiple copies of this * program to be run without having intermingled output (or statistics!). */ -void +static void pr_pack(u_char *buf, int cc, struct msghdr *mhdr) { #define safeputc(c) printf((isprint((c)) ? "%c" : "\\%03o"), c) @@ -1500,7 +1499,7 @@ pr_pack(u_char *buf, int cc, struct msgh } from = (struct sockaddr *)mhdr->msg_name; fromlen = mhdr->msg_namelen; - if (cc < sizeof(struct icmp6_hdr)) { + if (cc < (int)sizeof(struct icmp6_hdr)) { if (options & F_VERBOSE) warnx("packet too short (%d bytes) from %s", cc, pr_addr(from, fromlen)); @@ -1754,7 +1753,7 @@ pr_pack(u_char *buf, int cc, struct msgh #undef safeputc } -void +static void pr_exthdrs(struct msghdr *mhdr) { ssize_t bufsize; @@ -1792,7 +1791,7 @@ pr_exthdrs(struct msghdr *mhdr) } #ifdef USE_RFC2292BIS -void +static void pr_ip6opt(void *extbuf, size_t bufsize) { struct ip6_hbh *ext; @@ -1855,7 +1854,7 @@ pr_ip6opt(void *extbuf, size_t bufsize) } #else /* !USE_RFC2292BIS */ /* ARGSUSED */ -void +static void pr_ip6opt(void *extbuf, size_t bufsize __unused) { putchar('\n'); @@ -1864,7 +1863,7 @@ pr_ip6opt(void *extbuf, size_t bufsize _ #endif /* USE_RFC2292BIS */ #ifdef USE_RFC2292BIS -void +static void pr_rthdr(void *extbuf, size_t bufsize) { struct in6_addr *in6; @@ -1921,7 +1920,7 @@ pr_rthdr(void *extbuf, size_t bufsize) #else /* !USE_RFC2292BIS */ /* ARGSUSED */ -void +static void pr_rthdr(void *extbuf, size_t bufsize __unused) { putchar('\n'); @@ -1929,7 +1928,7 @@ pr_rthdr(void *extbuf, size_t bufsize __ } #endif /* USE_RFC2292BIS */ -int +static int pr_bitrange(u_int32_t v, int soff, int ii) { int off; @@ -1975,7 +1974,7 @@ pr_bitrange(u_int32_t v, int soff, int i return ii; } -void +static void pr_suptypes(struct icmp6_nodeinfo *ni, size_t nilen) /* ni->qtype must be SUPTYPES */ { @@ -2041,7 +2040,7 @@ pr_suptypes(struct icmp6_nodeinfo *ni, s } } -void +static void pr_nodeaddr(struct icmp6_nodeinfo *ni, int nilen) /* ni->qtype must be NODEADDR */ { @@ -2107,7 +2106,7 @@ pr_nodeaddr(struct icmp6_nodeinfo *ni, i } } -int +static int get_hoplim(struct msghdr *mhdr) { struct cmsghdr *cm; @@ -2126,7 +2125,7 @@ get_hoplim(struct msghdr *mhdr) return(-1); } -struct in6_pktinfo * +static struct in6_pktinfo * get_rcvpktinfo(struct msghdr *mhdr) { struct cmsghdr *cm; @@ -2145,7 +2144,7 @@ get_rcvpktinfo(struct msghdr *mhdr) return(NULL); } -int +static int get_pathmtu(struct msghdr *mhdr) { #ifdef IPV6_RECVPATHMTU @@ -2205,7 +2204,7 @@ get_pathmtu(struct msghdr *mhdr) * Subtract 2 timeval structs: out = out - in. Out is assumed to * be >= in. */ -void +static void tvsub(struct timeval *out, struct timeval *in) { if ((out->tv_usec -= in->tv_usec) < 0) { @@ -2220,7 +2219,7 @@ tvsub(struct timeval *out, struct timeva * SIGINT handler. */ /* ARGSUSED */ -void +static void onint(int notused __unused) { /* @@ -2235,7 +2234,7 @@ onint(int notused __unused) * summary -- * Print out statistics. */ -void +static void summary(void) { @@ -2285,7 +2284,7 @@ static const char *nircode[] = { * pr_icmph -- * Print a descriptive string about an ICMP header. */ -void +static void pr_icmph(struct icmp6_hdr *icp, u_char *end) { char ntop_buf[INET6_ADDRSTRLEN]; @@ -2515,7 +2514,7 @@ pr_icmph(struct icmp6_hdr *icp, u_char * * pr_iph -- * Print an IP6 header. */ -void +static void pr_iph(struct ip6_hdr *ip6) { u_int32_t flow = ip6->ip6_flow & IPV6_FLOWLABEL_MASK; @@ -2543,7 +2542,7 @@ pr_iph(struct ip6_hdr *ip6) * Return an ascii host address as a dotted quad and optionally with * a hostname. */ -const char * +static const char * pr_addr(struct sockaddr *addr, int addrlen) { static char buf[NI_MAXHOST]; @@ -2562,13 +2561,13 @@ pr_addr(struct sockaddr *addr, int addrl * pr_retip -- * Dump some info on a returned (via ICMPv6) IPv6 packet. */ -void +static void pr_retip(struct ip6_hdr *ip6, u_char *end) { u_char *cp = (u_char *)ip6, nh; int hlen; - if (end - (u_char *)ip6 < sizeof(*ip6)) { + if ((size_t)(end - (u_char *)ip6) < sizeof(*ip6)) { printf("IP6"); goto trunc; } @@ -2642,7 +2641,7 @@ pr_retip(struct ip6_hdr *ip6, u_char *en return; } -void +static void fill(char *bp, char *patp) { int ii, jj, kk; @@ -2661,7 +2660,7 @@ fill(char *bp, char *patp) /* xxx */ if (ii > 0) for (kk = 0; - kk <= MAXDATALEN - (8 + sizeof(struct tv32) + ii); + (size_t)kk <= MAXDATALEN - 8 + sizeof(struct tv32) + ii; kk += ii) for (jj = 0; jj < ii; ++jj) bp[jj + kk] = pat[jj]; @@ -2675,7 +2674,7 @@ fill(char *bp, char *patp) #ifdef IPSEC #ifdef IPSEC_POLICY_IPSEC -int +static int setpolicy(int so __unused, char *policy) { char *buf; @@ -2696,7 +2695,7 @@ setpolicy(int so __unused, char *policy) #endif #endif -char * +static char * nigroup(char *name, int nig_oldmcprefix) { char *p; @@ -2755,7 +2754,7 @@ nigroup(char *name, int nig_oldmcprefix) return strdup(hbuf); } -void +static void usage(void) { (void)fprintf(stderr,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201410200027.s9K0RegN062458>