From cd48a1d32b7e37d716e9ca0da9ba773994c976b3 Mon Sep 17 00:00:00 2001 From: charnier Date: Mon, 26 Jul 2004 20:18:11 +0000 Subject: [PATCH] Add __FBSDID. Replace local variable sin by sockin to not conflict with sin(3). Use warnx() instead of warn() when error message is not of any interest. Add prototypes. --- usr.bin/netstat/atalk.c | 9 +++++---- usr.bin/netstat/if.c | 21 +++++++++++---------- usr.bin/netstat/inet.c | 11 ++++++----- usr.bin/netstat/inet6.c | 12 +++++++----- usr.bin/netstat/ipsec.c | 13 ++++++------- usr.bin/netstat/ipx.c | 11 ++++++----- usr.bin/netstat/main.c | 18 ++++++++++-------- usr.bin/netstat/mbuf.c | 9 +++++---- usr.bin/netstat/mcast.c | 6 ++---- usr.bin/netstat/mroute.c | 6 ++---- usr.bin/netstat/mroute6.c | 4 +++- usr.bin/netstat/netgraph.c | 8 ++------ usr.bin/netstat/route.c | 21 +++++++++++---------- usr.bin/netstat/unix.c | 11 ++++++----- 14 files changed, 82 insertions(+), 78 deletions(-) diff --git a/usr.bin/netstat/atalk.c b/usr.bin/netstat/atalk.c index d0a09c2f1dba..517325c7a645 100644 --- a/usr.bin/netstat/atalk.c +++ b/usr.bin/netstat/atalk.c @@ -31,13 +31,14 @@ * SUCH DAMAGE. */ +#if 0 #ifndef lint -/* static char sccsid[] = "@(#)atalk.c 1.1 (Whistle) 6/6/96"; -*/ -static const char rcsid[] = - "$FreeBSD$"; #endif /* not lint */ +#endif + +#include +__FBSDID("$FreeBSD$"); #include #include diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c index 90a5a0ad4102..0a8725b186a0 100644 --- a/usr.bin/netstat/if.c +++ b/usr.bin/netstat/if.c @@ -31,13 +31,14 @@ * SUCH DAMAGE. */ +#if 0 #ifndef lint -/* static char sccsid[] = "@(#)if.c 8.3 (Berkeley) 4/28/95"; -*/ -static const char rcsid[] = - "$FreeBSD$"; #endif /* not lint */ +#endif + +#include +__FBSDID("$FreeBSD$"); #include #include @@ -210,9 +211,9 @@ intpr(int _interval, u_long ifnetaddr, void (*pfunc)(char *)) } ifaddraddr = 0; while (ifnetaddr || ifaddraddr) { - struct sockaddr_in *sin; + struct sockaddr_in *sockin; #ifdef INET6 - struct sockaddr_in6 *sin6; + struct sockaddr_in6 *sockin6; #endif char *cp; int n, m; @@ -291,7 +292,7 @@ intpr(int _interval, u_long ifnetaddr, void (*pfunc)(char *)) printf("%-15.15s ", "none"); break; case AF_INET: - sin = (struct sockaddr_in *)sa; + sockin = (struct sockaddr_in *)sa; #ifdef notdef /* can't use inet_makeaddr because kernel * keeps nets unshifted. @@ -306,19 +307,19 @@ intpr(int _interval, u_long ifnetaddr, void (*pfunc)(char *)) ifaddr.in.ia_subnetmask)); #endif printf("%-17.17s ", - routename(sin->sin_addr.s_addr)); + routename(sockin->sin_addr.s_addr)); network_layer = 1; break; #ifdef INET6 case AF_INET6: - sin6 = (struct sockaddr_in6 *)sa; + sockin6 = (struct sockaddr_in6 *)sa; printf("%-13.13s ", netname6(&ifaddr.in6.ia_addr, &ifaddr.in6.ia_prefixmask.sin6_addr)); printf("%-17.17s ", inet_ntop(AF_INET6, - &sin6->sin6_addr, + &sockin6->sin6_addr, ntop_buf, sizeof(ntop_buf))); network_layer = 1; diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c index f75963f90401..ea679f81af7a 100644 --- a/usr.bin/netstat/inet.c +++ b/usr.bin/netstat/inet.c @@ -31,13 +31,14 @@ * SUCH DAMAGE. */ +#if 0 #ifndef lint -/* static char sccsid[] = "@(#)inet.c 8.5 (Berkeley) 5/24/95"; -*/ -static const char rcsid[] = - "$FreeBSD$"; #endif /* not lint */ +#endif + +#include +__FBSDID("$FreeBSD$"); #include #include @@ -142,7 +143,7 @@ protopr(u_long proto, /* for sysctl version we pass proto # */ return; } if ((buf = malloc(len)) == 0) { - warn("malloc %lu bytes", (u_long)len); + warnx("malloc %lu bytes", (u_long)len); return; } if (sysctlbyname(mibvar, buf, &len, 0, 0) < 0) { diff --git a/usr.bin/netstat/inet6.c b/usr.bin/netstat/inet6.c index 6b90b751a31b..7f11a54c2861 100644 --- a/usr.bin/netstat/inet6.c +++ b/usr.bin/netstat/inet6.c @@ -30,15 +30,16 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ +#if 0 #ifndef lint -/* static char sccsid[] = "@(#)inet6.c 8.4 (Berkeley) 4/20/94"; -*/ #endif /* not lint */ +#endif + +#include +__FBSDID("$FreeBSD$"); #ifdef INET6 #include @@ -72,7 +73,8 @@ static char sccsid[] = "@(#)inet6.c 8.4 (Berkeley) 4/20/94"; struct socket sockb; -char *inet6name (struct in6_addr *); +char *inet6name(struct in6_addr *); +const char *pluralies(int); static char ntop_buf[INET6_ADDRSTRLEN]; diff --git a/usr.bin/netstat/ipsec.c b/usr.bin/netstat/ipsec.c index 03c685a7a20a..c99d27a2e988 100644 --- a/usr.bin/netstat/ipsec.c +++ b/usr.bin/netstat/ipsec.c @@ -63,15 +63,14 @@ * SUCH DAMAGE. */ -#include -#ifndef lint #if 0 -static char sccsid[] = "from: @(#)inet.c 8.4 (Berkeley) 4/20/94"; -#else -static const char rcsid[] = - "$FreeBSD$"; -#endif +#ifndef lint +static char sccsid[] = "@(#)inet.c 8.5 (Berkeley) 5/24/95"; #endif /* not lint */ +#endif + +#include +__FBSDID("$FreeBSD$"); #include #include diff --git a/usr.bin/netstat/ipx.c b/usr.bin/netstat/ipx.c index 2ab359aac9c4..b4f294007436 100644 --- a/usr.bin/netstat/ipx.c +++ b/usr.bin/netstat/ipx.c @@ -31,13 +31,14 @@ * SUCH DAMAGE. */ +#if 0 #ifndef lint -/* static char sccsid[] = "@(#)ns.c 8.1 (Berkeley) 6/6/93"; -*/ -static const char rcsid[] = - "$FreeBSD$"; #endif /* not lint */ +#endif + +#include +__FBSDID("$FreeBSD$"); #include #include @@ -74,6 +75,7 @@ struct socket sockb; static char *ipx_prpr (struct ipx_addr *); static int first = 1; +extern char *tcpstates[]; /* * Print a summary of connections related to a Network Systems @@ -139,7 +141,6 @@ ipxprotopr(u_long off, const char *name, int af1 __unused) printf(Aflag?" %-18.18s":" %-22.22s", ipx_prpr(&ipxpcb.ipxp_laddr)); printf(Aflag?" %-18.18s":" %-22.22s", ipx_prpr(&ipxpcb.ipxp_faddr)); if (isspx) { - extern char *tcpstates[]; if (spxpcb.s_state >= TCP_NSTATES) printf(" %d", spxpcb.s_state); else diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c index 8992599d0891..1474ba3750e3 100644 --- a/usr.bin/netstat/main.c +++ b/usr.bin/netstat/main.c @@ -37,13 +37,14 @@ char const copyright[] = Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ -#ifndef lint #if 0 +#ifndef lint static char sccsid[] = "@(#)main.c 8.4 (Berkeley) 3/1/94"; -#endif -static const char rcsid[] = - "$FreeBSD$"; #endif /* not lint */ +#endif + +#include +__FBSDID("$FreeBSD$"); #include #include @@ -245,10 +246,11 @@ struct protox *protoprotox[] = { #endif ipxprotox, atalkprotox, NULL }; -static void printproto (struct protox *, const char *); -static void usage (void); -static struct protox *name2protox (char *); -static struct protox *knownname (char *); +const char *pluralies(int); +static void printproto(struct protox *, const char *); +static void usage(void); +static struct protox *name2protox(char *); +static struct protox *knownname(char *); static kvm_t *kvmd; static char *nlistf = NULL, *memf = NULL; diff --git a/usr.bin/netstat/mbuf.c b/usr.bin/netstat/mbuf.c index 98546c4a36f2..feb4871d8f42 100644 --- a/usr.bin/netstat/mbuf.c +++ b/usr.bin/netstat/mbuf.c @@ -31,13 +31,14 @@ * SUCH DAMAGE. */ -#ifndef lint #if 0 +#ifndef lint static char sccsid[] = "@(#)mbuf.c 8.1 (Berkeley) 6/6/93"; -#endif -static const char rcsid[] = - "$FreeBSD$"; #endif /* not lint */ +#endif + +#include +__FBSDID("$FreeBSD$"); #include #include diff --git a/usr.bin/netstat/mcast.c b/usr.bin/netstat/mcast.c index 6a7afab6be93..2b2a5cd1bb70 100644 --- a/usr.bin/netstat/mcast.c +++ b/usr.bin/netstat/mcast.c @@ -25,10 +25,8 @@ * */ -#ifndef lint -static const char rcsid[] = - "$FreeBSD$"; -#endif /* not lint */ +#include +__FBSDID("$FreeBSD$"); /* * Print the system's current multicast group memberships. diff --git a/usr.bin/netstat/mroute.c b/usr.bin/netstat/mroute.c index 344926897040..e81ca2bd3821 100644 --- a/usr.bin/netstat/mroute.c +++ b/usr.bin/netstat/mroute.c @@ -37,10 +37,8 @@ * @(#)mroute.c 8.2 (Berkeley) 4/28/95 */ -#ifndef lint -static const char rcsid[] = - "$FreeBSD$"; -#endif /* not lint */ +#include +__FBSDID("$FreeBSD$"); /* * Print multicast routing structures and statistics. diff --git a/usr.bin/netstat/mroute6.c b/usr.bin/netstat/mroute6.c index 4dbaca5e4559..bc06a3d6c30d 100644 --- a/usr.bin/netstat/mroute6.c +++ b/usr.bin/netstat/mroute6.c @@ -64,9 +64,11 @@ * SUCH DAMAGE. * * @(#)mroute.c 8.2 (Berkeley) 4/28/95 - * $FreeBSD$ */ +#include +__FBSDID("$FreeBSD$"); + #ifdef INET6 #include #include diff --git a/usr.bin/netstat/netgraph.c b/usr.bin/netstat/netgraph.c index 845a7ccc6073..e156989155c5 100644 --- a/usr.bin/netstat/netgraph.c +++ b/usr.bin/netstat/netgraph.c @@ -30,14 +30,10 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. - * - * $FreeBSD$ */ -#ifndef lint -static const char rcsid[] = - "$Id: atalk.c,v 1.11 1998/07/06 21:01:22 bde Exp $"; -#endif /* not lint */ +#include +__FBSDID("$FreeBSD$"); #include #include diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c index 8f9d81487e86..37ca85d051a5 100644 --- a/usr.bin/netstat/route.c +++ b/usr.bin/netstat/route.c @@ -31,13 +31,14 @@ * SUCH DAMAGE. */ -#ifndef lint #if 0 +#ifndef lint static char sccsid[] = "From: @(#)route.c 8.6 (Berkeley) 4/28/95"; -#endif -static const char rcsid[] = - "$FreeBSD$"; #endif /* not lint */ +#endif + +#include +__FBSDID("$FreeBSD$"); #include #include @@ -486,7 +487,7 @@ ntreestuff(void) } if ((buf = malloc(needed)) == 0) { - err(2, "malloc(%lu)", (unsigned long)needed); + errx(2, "malloc(%lu)", (unsigned long)needed); } if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) { err(1, "sysctl: net.route.0.0.dump"); @@ -563,21 +564,21 @@ fmt_sockaddr(struct sockaddr *sa, struct sockaddr *mask, int flags) switch(sa->sa_family) { case AF_INET: { - struct sockaddr_in *sin = (struct sockaddr_in *)sa; + struct sockaddr_in *sockin = (struct sockaddr_in *)sa; - if ((sin->sin_addr.s_addr == INADDR_ANY) && + if ((sockin->sin_addr.s_addr == INADDR_ANY) && mask && ntohl(((struct sockaddr_in *)mask)->sin_addr.s_addr) ==0L) cp = "default" ; else if (flags & RTF_HOST) - cp = routename(sin->sin_addr.s_addr); + cp = routename(sockin->sin_addr.s_addr); else if (mask) - cp = netname(sin->sin_addr.s_addr, + cp = netname(sockin->sin_addr.s_addr, ntohl(((struct sockaddr_in *)mask) ->sin_addr.s_addr)); else - cp = netname(sin->sin_addr.s_addr, 0L); + cp = netname(sockin->sin_addr.s_addr, 0L); break; } diff --git a/usr.bin/netstat/unix.c b/usr.bin/netstat/unix.c index 5698edef3135..d9256115382a 100644 --- a/usr.bin/netstat/unix.c +++ b/usr.bin/netstat/unix.c @@ -31,13 +31,14 @@ * SUCH DAMAGE. */ -#ifndef lint #if 0 +#ifndef lint static char sccsid[] = "@(#)unix.c 8.1 (Berkeley) 6/6/93"; -#endif -static const char rcsid[] = - "$FreeBSD$"; #endif /* not lint */ +#endif + +#include +__FBSDID("$FreeBSD$"); /* * Display protocol blocks in the unix domain. @@ -88,7 +89,7 @@ unixpr(void) continue; } if ((buf = malloc(len)) == 0) { - warn("malloc %lu bytes", (u_long)len); + warnx("malloc %lu bytes", (u_long)len); return; } if (sysctlbyname(mibvar, buf, &len, 0, 0) < 0) {