From 39707ce809ce0b77da08727e924802c32f19c313 Mon Sep 17 00:00:00 2001 From: xtraeme Date: Wed, 9 Feb 2005 14:09:46 +0000 Subject: [PATCH] Kill __P(), use ANSI function declarations; WARNS=3. --- sbin/ping6/Makefile | 4 +- sbin/ping6/ping6.c | 157 +++++++++++++++++--------------------------- 2 files changed, 64 insertions(+), 97 deletions(-) diff --git a/sbin/ping6/Makefile b/sbin/ping6/Makefile index 366f1388025f..68c58b14aa34 100644 --- a/sbin/ping6/Makefile +++ b/sbin/ping6/Makefile @@ -1,8 +1,10 @@ -# $NetBSD: Makefile,v 1.7 2002/05/26 13:01:21 itojun Exp $ +# $NetBSD: Makefile,v 1.8 2005/02/09 14:09:46 xtraeme Exp $ PROG= ping6 MAN= ping6.8 +WARNS= 3 + BINOWN= root BINMODE=4555 diff --git a/sbin/ping6/ping6.c b/sbin/ping6/ping6.c index 4131e870b926..ed20ac367d88 100644 --- a/sbin/ping6/ping6.c +++ b/sbin/ping6/ping6.c @@ -1,4 +1,4 @@ -/* $NetBSD: ping6.c,v 1.61 2004/10/29 19:20:36 dsl Exp $ */ +/* $NetBSD: ping6.c,v 1.62 2005/02/09 14:09:46 xtraeme Exp $ */ /* $KAME: ping6.c,v 1.164 2002/11/16 14:05:37 itojun Exp $ */ /* @@ -77,7 +77,7 @@ static char sccsid[] = "@(#)ping.c 8.1 (Berkeley) 6/5/93"; #else #include #ifndef lint -__RCSID("$NetBSD: ping6.c,v 1.61 2004/10/29 19:20:36 dsl Exp $"); +__RCSID("$NetBSD: ping6.c,v 1.62 2005/02/09 14:09:46 xtraeme Exp $"); #endif #endif @@ -249,41 +249,38 @@ volatile sig_atomic_t seenint; volatile sig_atomic_t seeninfo; #endif -int main __P((int, char *[])); -void fill __P((char *, char *)); -int get_hoplim __P((struct msghdr *)); -int get_pathmtu __P((struct msghdr *)); -struct in6_pktinfo *get_rcvpktinfo __P((struct msghdr *)); -void onsignal __P((int)); -void retransmit __P((void)); -void onint __P((int)); -size_t pingerlen __P((void)); -int pinger __P((void)); -const char *pr_addr __P((struct sockaddr *, int)); -void pr_icmph __P((struct icmp6_hdr *, u_char *)); -void pr_iph __P((struct ip6_hdr *)); -void pr_suptypes __P((struct icmp6_nodeinfo *, size_t)); -void pr_nodeaddr __P((struct icmp6_nodeinfo *, int)); -int myechoreply __P((const struct icmp6_hdr *)); -int mynireply __P((const struct icmp6_nodeinfo *)); -char *dnsdecode __P((const u_char **, const u_char *, const u_char *, - char *, size_t)); -void pr_pack __P((u_char *, int, struct msghdr *)); -void pr_exthdrs __P((struct msghdr *)); -void pr_ip6opt __P((void *)); -void pr_rthdr __P((void *)); -int pr_bitrange __P((u_int32_t, int, int)); -void pr_retip __P((struct ip6_hdr *, u_char *)); -void summary __P((void)); -void tvsub __P((struct timeval *, struct timeval *)); -int setpolicy __P((int, char *)); -char *nigroup __P((char *)); -void usage __P((void)); +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 retransmit(void); +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 *); +void pr_rthdr(void *); +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 *); +void usage(void); int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char *argv[]) { struct itimerval itimer; struct sockaddr_in6 from; @@ -1143,8 +1140,7 @@ main(argc, argv) } void -onsignal(sig) - int sig; +onsignal(int sig) { switch (sig) { @@ -1167,7 +1163,7 @@ onsignal(sig) * This routine transmits another ping6. */ void -retransmit() +retransmit(void) { struct itimerval itimer; @@ -1203,7 +1199,7 @@ retransmit() * byte-order, to compute the round-trip time. */ size_t -pingerlen() +pingerlen(void) { size_t l; @@ -1222,7 +1218,7 @@ pingerlen() } int -pinger() +pinger(void) { struct icmp6_hdr *icp; struct iovec iov[2]; @@ -1337,8 +1333,7 @@ pinger() } int -myechoreply(icp) - const struct icmp6_hdr *icp; +myechoreply(const struct icmp6_hdr *icp) { if (ntohs(icp->icmp6_id) == ident) return 1; @@ -1347,8 +1342,7 @@ myechoreply(icp) } int -mynireply(nip) - const struct icmp6_nodeinfo *nip; +mynireply(const struct icmp6_nodeinfo *nip) { if (memcmp(nip->icmp6_ni_nonce + sizeof(u_int16_t), nonce + sizeof(u_int16_t), @@ -1359,12 +1353,8 @@ mynireply(nip) } char * -dnsdecode(sp, ep, base, buf, bufsiz) - const u_char **sp; - const u_char *ep; - const u_char *base; /*base for compressed name*/ - char *buf; - size_t bufsiz; +dnsdecode(const u_char **sp, const u_char *ep, const u_char *base, char *buf, + size_t bufsiz) { int i; const u_char *cp; @@ -1429,10 +1419,7 @@ dnsdecode(sp, ep, base, buf, bufsiz) * program to be run without having intermingled output (or statistics!). */ void -pr_pack(buf, cc, mhdr) - u_char *buf; - int cc; - struct msghdr *mhdr; +pr_pack(u_char *buf, int cc, struct msghdr *mhdr) { #define safeputc(c) printf((isprint((c)) ? "%c" : "\\%03o"), c) struct icmp6_hdr *icp; @@ -1710,8 +1697,7 @@ pr_pack(buf, cc, mhdr) } void -pr_exthdrs(mhdr) - struct msghdr *mhdr; +pr_exthdrs(struct msghdr *mhdr) { struct cmsghdr *cm; @@ -1846,10 +1832,7 @@ pr_rthdr(void *extbuf) #endif /* USE_RFC2292BIS */ int -pr_bitrange(v, soff, ii) - u_int32_t v; - int soff; - int ii; +pr_bitrange(u_int32_t v, int soff, int ii) { int off; int i; @@ -1895,9 +1878,8 @@ pr_bitrange(v, soff, ii) } void -pr_suptypes(ni, nilen) - struct icmp6_nodeinfo *ni; /* ni->qtype must be SUPTYPES */ - size_t nilen; +pr_suptypes(struct icmp6_nodeinfo *ni /* ni->qtype must be SUPTYPES */, + size_t nilen) { size_t clen; u_int32_t v; @@ -1962,9 +1944,8 @@ pr_suptypes(ni, nilen) } void -pr_nodeaddr(ni, nilen) - struct icmp6_nodeinfo *ni; /* ni->qtype must be NODEADDR */ - int nilen; +pr_nodeaddr(struct icmp6_nodeinfo *ni, /* ni->qtype must be NODEADDR */ + int nilen) { u_char *cp = (u_char *)(ni + 1); char ntop_buf[INET6_ADDRSTRLEN]; @@ -2029,8 +2010,7 @@ pr_nodeaddr(ni, nilen) } int -get_hoplim(mhdr) - struct msghdr *mhdr; +get_hoplim(struct msghdr *mhdr) { struct cmsghdr *cm; @@ -2049,8 +2029,7 @@ get_hoplim(mhdr) } struct in6_pktinfo * -get_rcvpktinfo(mhdr) - struct msghdr *mhdr; +get_rcvpktinfo(struct msghdr *mhdr) { struct cmsghdr *cm; @@ -2069,8 +2048,7 @@ get_rcvpktinfo(mhdr) } int -get_pathmtu(mhdr) - struct msghdr *mhdr; +get_pathmtu(struct msghdr *mhdr) { #ifdef IPV6_RECVPATHMTU struct cmsghdr *cm; @@ -2130,8 +2108,7 @@ get_pathmtu(mhdr) * be >= in. */ void -tvsub(out, in) - struct timeval *out, *in; +tvsub(struct timeval *out, struct timeval *in) { if ((out->tv_usec -= in->tv_usec) < 0) { --out->tv_sec; @@ -2146,8 +2123,7 @@ tvsub(out, in) */ /* ARGSUSED */ void -onint(notused) - int notused; +onint(int notused) { summary(); @@ -2163,7 +2139,7 @@ onint(notused) * Print out statistics. */ void -summary() +summary(void) { (void)printf("\n--- %s ping6 statistics ---\n", hostname); @@ -2211,9 +2187,7 @@ static const char *nircode[] = { * Print a descriptive string about an ICMP header. */ void -pr_icmph(icp, end) - struct icmp6_hdr *icp; - u_char *end; +pr_icmph(struct icmp6_hdr *icp, u_char *end) { char ntop_buf[INET6_ADDRSTRLEN]; struct nd_redirect *red; @@ -2443,8 +2417,7 @@ pr_icmph(icp, end) * Print an IP6 header. */ void -pr_iph(ip6) - struct ip6_hdr *ip6; +pr_iph(struct ip6_hdr *ip6) { u_int32_t flow = ip6->ip6_flow & IPV6_FLOWLABEL_MASK; u_int8_t tc; @@ -2472,9 +2445,7 @@ pr_iph(ip6) * a hostname. */ const char * -pr_addr(addr, addrlen) - struct sockaddr *addr; - int addrlen; +pr_addr(struct sockaddr *addr, int addrlen) { static char buf[NI_MAXHOST]; int flag = 0; @@ -2493,9 +2464,7 @@ pr_addr(addr, addrlen) * Dump some info on a returned (via ICMPv6) IPv6 packet. */ void -pr_retip(ip6, end) - struct ip6_hdr *ip6; - u_char *end; +pr_retip(struct ip6_hdr *ip6, u_char *end) { u_char *cp = (u_char *)ip6, nh; int hlen; @@ -2575,8 +2544,7 @@ pr_retip(ip6, end) } void -fill(bp, patp) - char *bp, *patp; +fill(char *bp, char *patp) { int ii, jj, kk; int pat[16]; @@ -2609,9 +2577,7 @@ fill(bp, patp) #ifdef IPSEC #ifdef IPSEC_POLICY_IPSEC int -setpolicy(so, policy) - int so; - char *policy; +setpolicy(int so, char *policy) { char *buf; @@ -2632,8 +2598,7 @@ setpolicy(so, policy) #endif char * -nigroup(name) - char *name; +nigroup(char *name) { char *p; char *q; @@ -2677,7 +2642,7 @@ nigroup(name) } void -usage() +usage(void) { (void)fprintf(stderr, "usage: ping6 [-dfH"