Module Name:    src
Committed By:   lukem
Date:           Sun Apr 12 16:08:37 UTC 2009

Modified Files:
        src/usr.bin/netstat: atalk.c bpf.c fast_ipsec.c if.c inet.c inet6.c
            ipsec.c iso.c main.c mbuf.c mroute.c netstat.h route.c show.c
            unix.c

Log Message:
Fix many WARNS=4 issues (-Wshadow -Wcast-qual -Wsign-compare).
Fix probable bug with numeric printing of anon ports when using sysctl.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/netstat/atalk.c
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/netstat/bpf.c
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/netstat/fast_ipsec.c
cvs rdiff -u -r1.62 -r1.63 src/usr.bin/netstat/if.c
cvs rdiff -u -r1.89 -r1.90 src/usr.bin/netstat/inet.c
cvs rdiff -u -r1.51 -r1.52 src/usr.bin/netstat/inet6.c
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/netstat/ipsec.c
cvs rdiff -u -r1.31 -r1.32 src/usr.bin/netstat/iso.c
cvs rdiff -u -r1.70 -r1.71 src/usr.bin/netstat/main.c
cvs rdiff -u -r1.28 -r1.29 src/usr.bin/netstat/mbuf.c \
    src/usr.bin/netstat/unix.c
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/netstat/mroute.c
cvs rdiff -u -r1.36 -r1.37 src/usr.bin/netstat/netstat.h
cvs rdiff -u -r1.72 -r1.73 src/usr.bin/netstat/route.c
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/netstat/show.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/netstat/atalk.c
diff -u src/usr.bin/netstat/atalk.c:1.13 src/usr.bin/netstat/atalk.c:1.14
--- src/usr.bin/netstat/atalk.c:1.13	Thu Apr 24 04:09:50 2008
+++ src/usr.bin/netstat/atalk.c	Sun Apr 12 16:08:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: atalk.c,v 1.13 2008/04/24 04:09:50 thorpej Exp $	*/
+/*	$NetBSD: atalk.c,v 1.14 2009/04/12 16:08:37 lukem Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "from @(#)atalk.c	1.1 (Whistle) 6/6/96";
 #else
-__RCSID("$NetBSD: atalk.c,v 1.13 2008/04/24 04:09:50 thorpej Exp $");
+__RCSID("$NetBSD: atalk.c,v 1.14 2009/04/12 16:08:37 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -74,8 +74,8 @@
  * -a (all) flag is specified.
  */
 
-static char *
-at_pr_net(struct sockaddr_at *sat, int numeric)
+static const char *
+at_pr_net(const struct sockaddr_at *sat, int numeric)
 {
 	static char mybuf[50];
 
@@ -91,8 +91,8 @@
 	return (mybuf);
 }
 
-static char *
-at_pr_host(struct sockaddr_at *sat, int numeric)
+static const char *
+at_pr_host(const struct sockaddr_at *sat, int numeric)
 {
 	static char mybuf[50];
 
@@ -109,8 +109,8 @@
 	return (mybuf);
 }
 
-static char *
-at_pr_port(struct sockaddr_at *sat)
+static const char *
+at_pr_port(const struct sockaddr_at *sat)
 {
 	static char mybuf[50];
 
@@ -126,8 +126,8 @@
 	}
 }
 
-static char *
-at_pr_range(struct sockaddr_at *sat)
+static const char *
+at_pr_range(const struct sockaddr_at *sat)
 {
 	static char mybuf[50];
 
@@ -150,10 +150,10 @@
  *	4 for port
  *	8 for numeric only
  */
-char *
+const char *
 atalk_print(const struct sockaddr *sa, int what)
 {
-	struct sockaddr_at *sat = (struct sockaddr_at *) sa;
+	const struct sockaddr_at *sat = (const struct sockaddr_at *) sa;
 	static char mybuf[50];
 	int numeric = (what & 0x08);
 
@@ -185,23 +185,23 @@
 	return (mybuf);
 }
 
-char *
+const char *
 atalk_print2(const struct sockaddr *sa, const struct sockaddr *mask, int what)
 {
 	int		n, l;
 	static char     buf[100];
-	struct sockaddr_at *sat1, *sat2;
+	const struct sockaddr_at *sat1, *sat2;
 	struct sockaddr_at thesockaddr;
 	struct sockaddr *sa2;
 
-	sat1 = (struct sockaddr_at *) sa;
-	sat2 = (struct sockaddr_at *) mask;
+	sat1 = (const struct sockaddr_at *) sa;
+	sat2 = (const struct sockaddr_at *) mask;
 	sa2 = (struct sockaddr *) & thesockaddr;
 
 	thesockaddr.sat_addr.s_net = sat1->sat_addr.s_net &
 	    sat2->sat_addr.s_net;
 	n = snprintf(buf, sizeof(buf), "%s", atalk_print(sa2, 1 | (what & 8)));
-	if (n >= sizeof(buf))
+	if (n >= (int)sizeof(buf))
 		n = sizeof(buf) - 1;
 	else if (n == -1)
 		n = 0;	/* What else can be done ? */
@@ -210,7 +210,7 @@
 		    ~sat2->sat_addr.s_net;
 		l = snprintf(buf + n, sizeof(buf) - n,
 		    "-%s", atalk_print(sa2, 1 | (what & 8)));
-		if (l >= sizeof(buf) - n)
+		if (l >= (int)(sizeof(buf) - n))
 			l = sizeof(buf) - n - 1;
 		if (l > 0)
 			n += l;
@@ -218,7 +218,7 @@
 	if (what & 2) {
 		l = snprintf(buf + n, sizeof(buf) - n, ".%s",
 		    atalk_print(sa, what & (~1)));
-		if (l >= sizeof(buf) - n)
+		if (l >= (int)(sizeof(buf) - n))
 			l = sizeof(buf) - n - 1;
 		if (l > 0)
 			n += l;
@@ -227,7 +227,7 @@
 }
 
 void
-atalkprotopr(u_long off, char *name)
+atalkprotopr(u_long off, const char *name)
 {
 	struct ddpcb    cb;
 	struct ddpcb *prev, *next;
@@ -286,7 +286,7 @@
  * Dump DDP statistics structure.
  */
 void
-ddp_stats(u_long off, char *name)
+ddp_stats(u_long off, const char *name)
 {
 	uint64_t ddpstat[DDP_NSTATS];
 

Index: src/usr.bin/netstat/bpf.c
diff -u src/usr.bin/netstat/bpf.c:1.8 src/usr.bin/netstat/bpf.c:1.9
--- src/usr.bin/netstat/bpf.c:1.8	Mon Apr 28 20:24:14 2008
+++ src/usr.bin/netstat/bpf.c	Sun Apr 12 16:08:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: bpf.c,v 1.8 2008/04/28 20:24:14 martin Exp $	*/
+/*	$NetBSD: bpf.c,v 1.9 2009/04/12 16:08:37 lukem Exp $	*/
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -68,13 +68,13 @@
 }
 
 void
-bpf_dump(char *interface)
+bpf_dump(const char *bpfif)
 {
 	struct bpf_d_ext *dpe;
 
 	if (use_sysctl) {
-		int	name[CTL_MAXNAME], rc, i;
-		size_t	sz, szproc;
+		int	name[CTL_MAXNAME], rc;
+		size_t	i, sz, szproc;
 		u_int	namelen;
 		void	*v;
 		struct kinfo_proc2 p;
@@ -115,8 +115,8 @@
 #define BPFEXT(entry) dpe->entry
 
 		for (i = 0; i < (sz / sizeof(*dpe)); i++, dpe++) {
-			if (interface && 
-			    strncmp(BPFEXT(bde_ifname), interface, IFNAMSIZ))
+			if (bpfif && 
+			    strncmp(BPFEXT(bde_ifname), bpfif, IFNAMSIZ))
 				continue;
 			
 			printf("%-7d ", BPFEXT(bde_pid));

Index: src/usr.bin/netstat/fast_ipsec.c
diff -u src/usr.bin/netstat/fast_ipsec.c:1.11 src/usr.bin/netstat/fast_ipsec.c:1.12
--- src/usr.bin/netstat/fast_ipsec.c:1.11	Thu Apr 24 04:09:27 2008
+++ src/usr.bin/netstat/fast_ipsec.c	Sun Apr 12 16:08:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: fast_ipsec.c,v 1.11 2008/04/24 04:09:27 thorpej Exp $ */
+/*	$NetBSD: fast_ipsec.c,v 1.12 2009/04/12 16:08:37 lukem Exp $ */
 /* 	$FreeBSD: src/tools/tools/crypto/ipsecstats.c,v 1.1.4.1 2003/06/03 00:13:13 sam Exp $ */
 
 /*-
@@ -33,7 +33,7 @@
 #include <sys/cdefs.h>
 #ifndef lint
 #ifdef __NetBSD__
-__RCSID("$NetBSD: fast_ipsec.c,v 1.11 2008/04/24 04:09:27 thorpej Exp $");
+__RCSID("$NetBSD: fast_ipsec.c,v 1.12 2009/04/12 16:08:37 lukem Exp $");
 #endif
 #endif /* not lint*/
 
@@ -90,7 +90,7 @@
  * about the vagaries of the two implementations.
  */
 void
-ipsec_switch(u_long off, char * name)
+ipsec_switch(u_long off, const char * name)
 {
 
 	if (have_fast_ipsec())
@@ -156,7 +156,7 @@
  * if that happens when we are running on KAME IPsec.
  */
 void
-fast_ipsec_stats(u_long off, char *name)
+fast_ipsec_stats(u_long off, const char *name)
 {
 	uint64_t ipsecstats[IPSEC_NSTATS];
 	uint64_t ahstats[AH_NSTATS];

Index: src/usr.bin/netstat/if.c
diff -u src/usr.bin/netstat/if.c:1.62 src/usr.bin/netstat/if.c:1.63
--- src/usr.bin/netstat/if.c:1.62	Wed Apr 23 15:35:37 2008
+++ src/usr.bin/netstat/if.c	Sun Apr 12 16:08:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: if.c,v 1.62 2008/04/23 15:35:37 thorpej Exp $	*/
+/*	$NetBSD: if.c,v 1.63 2009/04/12 16:08:37 lukem Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "from: @(#)if.c	8.2 (Berkeley) 2/21/94";
 #else
-__RCSID("$NetBSD: if.c,v 1.62 2008/04/23 15:35:37 thorpej Exp $");
+__RCSID("$NetBSD: if.c,v 1.63 2009/04/12 16:08:37 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -77,7 +77,7 @@
 intpr(interval, ifnetaddr, pfunc)
 	int interval;
 	u_long ifnetaddr;
-	void (*pfunc)(char *);
+	void (*pfunc)(const char *);
 {
 	struct ifnet ifnet;
 	union {
@@ -256,9 +256,9 @@
 						sin6->sin6_len,
 						hbuf, sizeof(hbuf), NULL, 0,
 						niflag) != 0) {
-					cp = "?";
-				} else
-					cp = hbuf;
+					strlcpy(hbuf, "?", sizeof(hbuf));
+				}
+				cp = hbuf;
 				if (vflag)
 					n = strlen(cp) < 17 ? 17 : strlen(cp);
 				else
@@ -267,28 +267,28 @@
 				if (aflag) {
 					u_long multiaddr;
 					struct in6_multi inm;
-					struct sockaddr_in6 sin6;
+					struct sockaddr_in6 as6;
 		
 					multiaddr = (u_long)
 					    ifaddr.in6.ia6_multiaddrs.lh_first;
 					while (multiaddr != 0) {
 						kread(multiaddr, (char *)&inm,
 						   sizeof inm);
-						memset(&sin6, 0, sizeof(sin6));
-						sin6.sin6_len = sizeof(struct sockaddr_in6);
-						sin6.sin6_family = AF_INET6;
-						sin6.sin6_addr = inm.in6m_addr;
+						memset(&as6, 0, sizeof(as6));
+						as6.sin6_len = sizeof(struct sockaddr_in6);
+						as6.sin6_family = AF_INET6;
+						as6.sin6_addr = inm.in6m_addr;
 #ifdef __KAME__
-						if (IN6_IS_ADDR_MC_LINKLOCAL(&sin6.sin6_addr)) {
-							sin6.sin6_scope_id =
+						if (IN6_IS_ADDR_MC_LINKLOCAL(&as6.sin6_addr)) {
+							as6.sin6_scope_id =
 							    ntohs(*(u_int16_t *)
-								&sin6.sin6_addr.s6_addr[2]);
-							sin6.sin6_addr.s6_addr[2] = 0;
-							sin6.sin6_addr.s6_addr[3] = 0;
+								&as6.sin6_addr.s6_addr[2]);
+							as6.sin6_addr.s6_addr[2] = 0;
+							as6.sin6_addr.s6_addr[3] = 0;
 						}
 #endif
-						if (getnameinfo((struct sockaddr *)&sin6,
-						    sin6.sin6_len, hbuf,
+						if (getnameinfo((struct sockaddr *)&as6,
+						    as6.sin6_len, hbuf,
 						    sizeof(hbuf), NULL, 0,
 						    niflag) != 0) {
 							strlcpy(hbuf, "??",
@@ -320,9 +320,9 @@
 				if (getnameinfo(sa, sa->sa_len,
 				    hbuf, sizeof(hbuf), NULL, 0,
 				    NI_NUMERICHOST) != 0) {
-					cp = "?";
-				} else
-					cp = hbuf;
+					strlcpy(hbuf, "?", sizeof(hbuf));
+				}
+				cp = hbuf;
 				if (vflag)
 					n = strlen(cp) < 17 ? 17 : strlen(cp);
 				else

Index: src/usr.bin/netstat/inet.c
diff -u src/usr.bin/netstat/inet.c:1.89 src/usr.bin/netstat/inet.c:1.90
--- src/usr.bin/netstat/inet.c:1.89	Sun Feb 22 07:43:01 2009
+++ src/usr.bin/netstat/inet.c	Sun Apr 12 16:08:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: inet.c,v 1.89 2009/02/22 07:43:01 dholland Exp $	*/
+/*	$NetBSD: inet.c,v 1.90 2009/04/12 16:08:37 lukem Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "from: @(#)inet.c	8.4 (Berkeley) 4/20/94";
 #else
-__RCSID("$NetBSD: inet.c,v 1.89 2009/02/22 07:43:01 dholland Exp $");
+__RCSID("$NetBSD: inet.c,v 1.90 2009/04/12 16:08:37 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -87,10 +87,6 @@
 #include <err.h>
 #include "netstat.h"
 
-struct	inpcb inpcb;
-struct	tcpcb tcpcb;
-struct	socket sockb;
-
 char	*inetname(struct in_addr *);
 void	inetprint(struct in_addr *, u_int16_t, const char *, int);
 
@@ -123,7 +119,7 @@
 protopr0(intptr_t ppcb, u_long rcv_sb_cc, u_long snd_sb_cc,
 	 struct in_addr *laddr, u_int16_t lport,
 	 struct in_addr *faddr, u_int16_t fport,
-	 short t_state, char *name)
+	 short t_state, const char *name, int inp_flags)
 {
 	static const char *shorttcpstates[] = {
 		"CLOSED",	"LISTEN",	"SYNSEN",	"SYSRCV",
@@ -142,7 +138,7 @@
 	if (numeric_port) {
 		inetprint(laddr, lport, name, 1);
 		inetprint(faddr, fport, name, 1);
-	} else if (inpcb.inp_flags & INP_ANONPORT) {
+	} else if (inp_flags & INP_ANONPORT) {
 		inetprint(laddr, lport, name, 1);
 		inetprint(faddr, fport, name, 0);
 	} else {
@@ -160,11 +156,13 @@
 }
 
 void
-protopr(u_long off, char *name)
+protopr(u_long off, const char *name)
 {
 	struct inpcbtable table;
 	struct inpcb *head, *next, *prev;
 	struct inpcb inpcb;
+	struct tcpcb tcpcb;
+	struct socket sockb;
 	int istcp;
 	static int first = 1;
 
@@ -228,7 +226,8 @@
 				 pcblist[i].ki_rcvq, pcblist[i].ki_sndq,
 				 &src.sin_addr, src.sin_port,
 				 &dst.sin_addr, dst.sin_port,
-				 pcblist[i].ki_tstate, name);
+				 pcblist[i].ki_tstate, name,
+				 pcblist[i].ki_pflags);
 		}
 
 		free(pcblist);
@@ -273,7 +272,7 @@
 			 sockb.so_rcv.sb_cc, sockb.so_snd.sb_cc,
 			 &inpcb.inp_laddr, inpcb.inp_lport,
 			 &inpcb.inp_faddr, inpcb.inp_fport,
-			 tcpcb.t_state, name);
+			 tcpcb.t_state, name, inpcb.inp_flags);
 	}
 }
 
@@ -281,7 +280,7 @@
  * Dump TCP statistics structure.
  */
 void
-tcp_stats(u_long off, char *name)
+tcp_stats(u_long off, const char *name)
 {
 	uint64_t tcpstat[TCP_NSTATS];
 
@@ -406,7 +405,7 @@
  * Dump UDP statistics structure.
  */
 void
-udp_stats(u_long off, char *name)
+udp_stats(u_long off, const char *name)
 {
 	uint64_t udpstat[UDP_NSTATS];
 	u_quad_t delivered;
@@ -460,7 +459,7 @@
  * Dump IP statistics structure.
  */
 void
-ip_stats(u_long off, char *name)
+ip_stats(u_long off, const char *name)
 {
 	uint64_t ipstat[IP_NSTATS];
 
@@ -544,7 +543,7 @@
  * Dump ICMP statistics.
  */
 void
-icmp_stats(u_long off, char *name)
+icmp_stats(u_long off, const char *name)
 {
 	uint64_t icmpstat[ICMP_NSTATS];
 	int i, first;
@@ -599,7 +598,7 @@
  * Dump IGMP statistics structure.
  */
 void
-igmp_stats(u_long off, char *name)
+igmp_stats(u_long off, const char *name)
 {
 	uint64_t igmpstat[IGMP_NSTATS];
 
@@ -637,7 +636,7 @@
  * Dump CARP statistics structure.
  */
 void
-carp_stats(u_long off, char *name)
+carp_stats(u_long off, const char *name)
 {
 	uint64_t carpstat[CARP_NSTATS];
 
@@ -689,7 +688,7 @@
  * Dump PIM statistics structure.
  */
 void
-pim_stats(u_long off, char *name)
+pim_stats(u_long off, const char *name)
 {
 	struct pimstat pimstat;
 
@@ -723,7 +722,7 @@
  * Dump the ARP statistics structure.
  */
 void
-arp_stats(u_long off, char *name)
+arp_stats(u_long off, const char *name)
 {
 	uint64_t arpstat[ARP_NSTATS];
 
@@ -784,7 +783,7 @@
  */
 void
 inetprint(struct in_addr *in, uint16_t port, const char *proto,
-	  int numeric_port)
+	  int port_numeric)
 {
 	struct servent *sp = 0;
 	char line[80], *cp;
@@ -793,7 +792,7 @@
 	(void)snprintf(line, sizeof line, "%.*s.",
 	    (Aflag && !numeric_addr) ? 12 : 16, inetname(in));
 	cp = strchr(line, '\0');
-	if (!numeric_port && port)
+	if (!port_numeric && port)
 		sp = getservbyport((int)port, proto);
 	space = sizeof line - (cp-line);
 	if (sp || port == 0)

Index: src/usr.bin/netstat/inet6.c
diff -u src/usr.bin/netstat/inet6.c:1.51 src/usr.bin/netstat/inet6.c:1.52
--- src/usr.bin/netstat/inet6.c:1.51	Sun Feb 22 07:43:01 2009
+++ src/usr.bin/netstat/inet6.c	Sun Apr 12 16:08:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: inet6.c,v 1.51 2009/02/22 07:43:01 dholland Exp $	*/
+/*	$NetBSD: inet6.c,v 1.52 2009/04/12 16:08:37 lukem Exp $	*/
 /*	BSDI inet.c,v 2.3 1995/10/24 02:19:29 prb Exp	*/
 
 /*
@@ -64,7 +64,7 @@
 #if 0
 static char sccsid[] = "@(#)inet.c	8.4 (Berkeley) 4/20/94";
 #else
-__RCSID("$NetBSD: inet6.c,v 1.51 2009/02/22 07:43:01 dholland Exp $");
+__RCSID("$NetBSD: inet6.c,v 1.52 2009/04/12 16:08:37 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -141,7 +141,7 @@
 struct	socket sockb;
 
 char	*inet6name(struct in6_addr *);
-void	inet6print(struct in6_addr *, int, char *);
+void	inet6print(struct in6_addr *, int, const char *);
 
 /*
  * Print a summary of connections related to an Internet
@@ -177,9 +177,9 @@
 ip6protopr0(intptr_t ppcb, u_long rcv_sb_cc, u_long snd_sb_cc,
 	struct in6_addr *laddr, u_int16_t lport,
 	struct in6_addr *faddr, u_int16_t fport,
-	short t_state, char *name)
+	short t_state, const char *name)
 {
-	static char *shorttcpstates[] = {
+	static const char *shorttcpstates[] = {
 		"CLOSED",       "LISTEN",       "SYNSEN",       "SYSRCV",
 		"ESTABL",       "CLWAIT",       "FWAIT1",       "CLOSNG",
 		"LASTAK",       "FWAIT2",       "TMWAIT",
@@ -215,7 +215,7 @@
 
 
 void
-ip6protopr(u_long off, char *name)
+ip6protopr(u_long off, const char *name)
 {
 	struct inpcbtable table;
 	struct in6pcb *head, *prev, *next;
@@ -343,7 +343,7 @@
  * Dump TCP6 statistics structure.
  */
 void
-tcp6_stats(u_long off, char *name)
+tcp6_stats(u_long off, const char *name)
 {
 	struct tcp6stat tcp6stat;
 
@@ -428,7 +428,7 @@
  * Dump UDP6 statistics structure.
  */
 void
-udp6_stats(u_long off, char *name)
+udp6_stats(u_long off, const char *name)
 {
 	uint64_t udp6stat[UDP6_NSTATS];
 	u_quad_t delivered;
@@ -570,7 +570,7 @@
  * Dump IP6 statistics structure.
  */
 void
-ip6_stats(u_long off, char *name)
+ip6_stats(u_long off, const char *name)
 {
 	uint64_t ip6stat[IP6_NSTATS];
 	int first, i;
@@ -740,7 +740,7 @@
  * Dump IPv6 per-interface statistics based on RFC 2465.
  */
 void
-ip6_ifstats(char *ifname)
+ip6_ifstats(const char *ifname)
 {
 	struct in6_ifreq ifr;
 	int s;
@@ -1056,7 +1056,7 @@
  * Dump ICMPv6 statistics.
  */
 void
-icmp6_stats(u_long off, char *name)
+icmp6_stats(u_long off, const char *name)
 {
 	uint64_t icmp6stat[ICMP6_NSTATS];
 	register int i, first;
@@ -1138,7 +1138,7 @@
  * Dump ICMPv6 per-interface statistics based on RFC 2466.
  */
 void
-icmp6_ifstats(char *ifname)
+icmp6_ifstats(const char *ifname)
 {
 	struct in6_ifreq ifr;
 	int s;
@@ -1204,7 +1204,7 @@
  * Dump PIM statistics structure.
  */
 void
-pim6_stats(u_long off, char *name)
+pim6_stats(u_long off, const char *name)
 {
 	uint64_t pim6stat[PIM6_NSTATS];
 
@@ -1236,7 +1236,7 @@
  * Dump raw ip6 statistics structure.
  */
 void
-rip6_stats(u_long off, char *name)
+rip6_stats(u_long off, const char *name)
 {
 	uint64_t rip6stat[RIP6_NSTATS];
 	u_quad_t delivered;
@@ -1279,7 +1279,7 @@
  * Take numeric_addr and numeric_port into consideration.
  */
 void
-inet6print(struct in6_addr *in6, int port, char *proto)
+inet6print(struct in6_addr *in6, int port, const char *proto)
 {
 #define GETSERVBYPORT6(port, proto, ret)\
 do {\
@@ -1292,12 +1292,12 @@
 } while (0)
 	struct servent *sp = 0;
 	char line[80], *cp;
-	int width;
+	int lwidth;
 
-	width = Aflag ? 12 : 16;
-	if (vflag && width < strlen(inet6name(in6)))
-		width = strlen(inet6name(in6));
-	snprintf(line, sizeof(line), "%.*s.", width, inet6name(in6));
+	lwidth = Aflag ? 12 : 16;
+	if (vflag && lwidth < (int)strlen(inet6name(in6)))
+		lwidth = strlen(inet6name(in6));
+	snprintf(line, sizeof(line), "%.*s.", lwidth, inet6name(in6));
 	cp = strchr(line, '\0');
 	if (!numeric_port && port)
 		GETSERVBYPORT6(port, proto, sp);
@@ -1307,10 +1307,10 @@
 	else
 		snprintf(cp, sizeof(line) - (cp - line),
 		    "%d", ntohs((u_short)port));
-	width = Aflag ? 18 : 22;
-	if (vflag && width < strlen(line))
-		width = strlen(line);
-	printf(" %-*.*s", width, width, line);
+	lwidth = Aflag ? 18 : 22;
+	if (vflag && lwidth < (int)strlen(line))
+		lwidth = strlen(line);
+	printf(" %-*.*s", lwidth, lwidth, line);
 }
 
 /*

Index: src/usr.bin/netstat/ipsec.c
diff -u src/usr.bin/netstat/ipsec.c:1.14 src/usr.bin/netstat/ipsec.c:1.15
--- src/usr.bin/netstat/ipsec.c:1.14	Thu Apr 24 04:09:27 2008
+++ src/usr.bin/netstat/ipsec.c	Sun Apr 12 16:08:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: ipsec.c,v 1.14 2008/04/24 04:09:27 thorpej Exp $	*/
+/*	$NetBSD: ipsec.c,v 1.15 2009/04/12 16:08:37 lukem Exp $	*/
 /*	$KAME: ipsec.c,v 1.33 2003/07/25 09:54:32 itojun Exp $	*/
 
 /*
@@ -65,7 +65,7 @@
 static char sccsid[] = "from: @(#)inet.c	8.4 (Berkeley) 4/20/94";
 #else
 #ifdef __NetBSD__
-__RCSID("$NetBSD: ipsec.c,v 1.14 2008/04/24 04:09:27 thorpej Exp $");
+__RCSID("$NetBSD: ipsec.c,v 1.15 2009/04/12 16:08:37 lukem Exp $");
 #endif
 #endif
 #endif /* not lint */
@@ -142,18 +142,18 @@
 
 static void print_ipsecstats(void);
 static const char *pfkey_msgtype_names(int);
-static void ipsec_hist(const u_quad_t *, size_t, const struct val2str *,
+static void ipsec_hist(const u_quad_t *, int, const struct val2str *,
 	size_t, const char *);
 
 /*
  * Dump IPSEC statistics structure.
  */
 static void
-ipsec_hist(const uint64_t *hist, size_t histmax, const struct val2str *name,
+ipsec_hist(const uint64_t *hist, int histmax, const struct val2str *name,
 	   size_t namemax, const char *title)
 {
 	int first;
-	size_t proto;
+	int proto;
 	const struct val2str *p;
 
 	first = 1;
@@ -221,7 +221,7 @@
 }
 
 void
-ipsec_stats(u_long off, char *name)
+ipsec_stats(u_long off, const char *name)
 {
 
 	if (use_sysctl) {
@@ -254,7 +254,7 @@
 }
 
 void
-pfkey_stats(u_long off, char *name)
+pfkey_stats(u_long off, const char *name)
 {
 	uint64_t pfkeystat[PFKEY_NSTATS];
 	int first, type;

Index: src/usr.bin/netstat/iso.c
diff -u src/usr.bin/netstat/iso.c:1.31 src/usr.bin/netstat/iso.c:1.32
--- src/usr.bin/netstat/iso.c:1.31	Sun Feb 22 07:43:01 2009
+++ src/usr.bin/netstat/iso.c	Sun Apr 12 16:08:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: iso.c,v 1.31 2009/02/22 07:43:01 dholland Exp $	*/
+/*	$NetBSD: iso.c,v 1.32 2009/04/12 16:08:37 lukem Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "from: @(#)iso.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: iso.c,v 1.31 2009/02/22 07:43:01 dholland Exp $");
+__RCSID("$NetBSD: iso.c,v 1.32 2009/04/12 16:08:37 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -106,7 +106,7 @@
 
 static void tprintstat __P((struct tp_stat *, int));
 static void isonetprint __P((struct sockaddr_iso *, int));
-static void hexprint __P((int, const char *, char *));
+static void hexprint __P((int, const char *, const char *));
 extern void inetprint __P((struct in_addr *, u_int16_t, const char *, int));
 
 /*
@@ -115,7 +115,7 @@
 void
 esis_stats(off, name)
 	u_long	off;
-	char	*name;
+	const char	*name;
 {
 	struct esis_stat esis_stat;
 
@@ -148,7 +148,7 @@
 void
 clnp_stats(off, name)
 	u_long off;
-	char *name;
+	const char *name;
 {
 	struct clnp_stat clnp_stat;
 
@@ -188,7 +188,7 @@
 void
 cltp_stats(off, name)
 	u_long off;
-	char *name;
+	const char *name;
 {
 	struct cltpstat cltpstat;
 
@@ -230,7 +230,7 @@
 void
 iso_protopr(off, name)
 	u_long off;
-	char *name;
+	const char *name;
 {
 	struct isopcb cb;
 	struct isopcb *prev, *next;
@@ -321,7 +321,7 @@
 void
 tp_protopr(off, name)
 	u_long off;
-	char *name;
+	const char *name;
 {
 	extern const char * const tp_sstring[];	/* from sys/netiso/tp_astring.c */
 	struct tp_ref *tpr, *tpr_base;
@@ -553,7 +553,7 @@
 void
 tp_stats(off, name)
 	u_long off;
-	char *name;
+	const char *name;
 {
 
 	if (off == 0) {
@@ -567,7 +567,7 @@
 
 struct tpstatpr {
 	size_t off;
-	char *text;
+	const char *text;
 };
 
 #define o(f) offsetof(struct tp_stat, f)
@@ -649,7 +649,7 @@
 {
 	int j, tpfirst, tpfirst2;
 
-	static char *rttname[]= {
+	static const char *rttname[]= {
 		"~LOCAL, PDN",
 		"~LOCAL,~PDN",
 		" LOCAL,~PDN",
@@ -852,9 +852,9 @@
 hexprint(n, buf, delim)
 	int n;
 	const char *buf;
-	char *delim;
+	const char *delim;
 {
-	u_char *in = (u_char *)buf, *top = in + n;
+	const u_char *in = (const u_char *)buf, *top = in + n;
 	char *out = obuf;
 	int i;
 

Index: src/usr.bin/netstat/main.c
diff -u src/usr.bin/netstat/main.c:1.70 src/usr.bin/netstat/main.c:1.71
--- src/usr.bin/netstat/main.c:1.70	Mon Jul 21 14:19:24 2008
+++ src/usr.bin/netstat/main.c	Sun Apr 12 16:08:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.70 2008/07/21 14:19:24 lukem Exp $	*/
+/*	$NetBSD: main.c,v 1.71 2009/04/12 16:08:37 lukem Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "from: @(#)main.c	8.4 (Berkeley) 3/1/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.70 2008/07/21 14:19:24 lukem Exp $");
+__RCSID("$NetBSD: main.c,v 1.71 2009/04/12 16:08:37 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -67,138 +67,138 @@
 
 struct nlist nl[] = {
 #define	N_MBSTAT	0
-	{ "_mbstat" },
+	{ "_mbstat", 0, 0, 0, 0 },
 #define	N_IPSTAT	1
-	{ "_ipstat" },		/* not available via kvm */
+	{ "_ipstat", 0, 0, 0, 0 },	/* not available via kvm */
 #define	N_TCBTABLE	2
-	{ "_tcbtable" },
+	{ "_tcbtable", 0, 0, 0, 0 },
 #define	N_TCPSTAT	3
-	{ "_tcpstat" },		/* not available via kvm */
+	{ "_tcpstat", 0, 0, 0, 0 },	/* not available via kvm */
 #define	N_UDBTABLE	4
-	{ "_udbtable" },
+	{ "_udbtable", 0, 0, 0, 0 },
 #define	N_UDPSTAT	5
-	{ "_udpstat" },		/* not available via kvm */
+	{ "_udpstat", 0, 0, 0, 0 },	/* not available via kvm */
 #define	N_IFNET		6
-	{ "_ifnet" },
+	{ "_ifnet", 0, 0, 0, 0 },
 #define	N_IMP		7
-	{ "_imp_softc" },
+	{ "_imp_softc", 0, 0, 0, 0 },
 #define	N_ICMPSTAT	8
-	{ "_icmpstat" },	/* not available via kvm */
+	{ "_icmpstat", 0, 0, 0, 0 },	/* not available via kvm */
 #define	N_RTSTAT	9
-	{ "_rtstat" },
+	{ "_rtstat", 0, 0, 0, 0 },
 #define	N_UNIXSW	10
-	{ "_unixsw" },
+	{ "_unixsw", 0, 0, 0, 0 },
 #define	N_CLNPSTAT	11
-	{ "_clnp_stat"},
+	{ "_clnp_stat", 0, 0, 0, 0 },
 #define	IN_NOTUSED	12
-	{ "_tp_inpcb" },
+	{ "_tp_inpcb", 0, 0, 0, 0 },
 #define	ISO_TP		13
-	{ "_tp_refinfo" },
+	{ "_tp_refinfo", 0, 0, 0, 0 },
 #define	N_TPSTAT	14
-	{ "_tp_stat" },
+	{ "_tp_stat", 0, 0, 0, 0 },
 #define	N_ESISSTAT	15
-	{ "_esis_stat"},
+	{ "_esis_stat", 0, 0, 0, 0 },
 #define N_NIMP		16
-	{ "_nimp"},
+	{ "_nimp", 0, 0, 0, 0 },
 #define N_RTREE		17
-	{ "_rt_tables"},
+	{ "_rt_tables", 0, 0, 0, 0 },
 #define N_CLTP		18
-	{ "_cltb"},
+	{ "_cltb", 0, 0, 0, 0 },
 #define N_CLTPSTAT	19
-	{ "_cltpstat"},
+	{ "_cltpstat", 0, 0, 0, 0 },
 #define	N_NFILE		20
-	{ "_nfile" },
+	{ "_nfile", 0, 0, 0, 0 },
 #define	N_FILE		21
-	{ "_file" },
+	{ "_file", 0, 0, 0, 0 },
 #define N_IGMPSTAT	22
-	{ "_igmpstat" },	/* not available via kvm */
+	{ "_igmpstat", 0, 0, 0, 0 },	/* not available via kvm */
 #define N_MRTPROTO	23
-	{ "_ip_mrtproto" },
+	{ "_ip_mrtproto", 0, 0, 0, 0 },
 #define N_MRTSTAT	24
-	{ "_mrtstat" },
+	{ "_mrtstat", 0, 0, 0, 0 },
 #define N_MFCHASHTBL	25
-	{ "_mfchashtbl" },
+	{ "_mfchashtbl", 0, 0, 0, 0 },
 #define	N_MFCHASH	26
-	{ "_mfchash" },
+	{ "_mfchash", 0, 0, 0, 0 },
 #define N_VIFTABLE	27
-	{ "_viftable" },
+	{ "_viftable", 0, 0, 0, 0 },
 #define N_MSIZE		28
-	{ "_msize" },
+	{ "_msize", 0, 0, 0, 0 },
 #define N_MCLBYTES	29
-	{ "_mclbytes" },
+	{ "_mclbytes", 0, 0, 0, 0 },
 #define N_DDPSTAT	30
-	{ "_ddpstat"},		/* not available via kvm */
+	{ "_ddpstat", 0, 0, 0, 0 },	/* not available via kvm */
 #define N_DDPCB		31
-	{ "_ddpcb"},
+	{ "_ddpcb", 0, 0, 0, 0 },
 #define N_MBPOOL	32
-	{ "_mbpool" },
+	{ "_mbpool", 0, 0, 0, 0 },
 #define N_MCLPOOL	33
-	{ "_mclpool" },
+	{ "_mclpool", 0, 0, 0, 0 },
 #define N_DIVPCB	34
-	{ "_divcb"},
+	{ "_divcb", 0, 0, 0, 0 },
 #define N_DIVSTAT	35
-	{ "_divstat"},
+	{ "_divstat", 0, 0, 0, 0 },
 #define N_IP6STAT	36
-	{ "_ip6stat" },		/* not available via kvm */
+	{ "_ip6stat", 0, 0, 0, 0 },	/* not available via kvm */
 #define N_TCP6STAT	37
-	{ "_tcp6stat" },	/* not available via kvm */
+	{ "_tcp6stat", 0, 0, 0, 0 },	/* not available via kvm */
 #define N_UDP6STAT	38
-	{ "_udp6stat" },	/* not available via kvm */
+	{ "_udp6stat", 0, 0, 0, 0 },	/* not available via kvm */
 #define N_ICMP6STAT	39
-	{ "_icmp6stat" },	/* not available via kvm */
+	{ "_icmp6stat", 0, 0, 0, 0 },	/* not available via kvm */
 #define N_IPSECSTAT	40
-	{ "_ipsecstat" },	/* not available via kvm */
+	{ "_ipsecstat", 0, 0, 0, 0 },	/* not available via kvm */
 #define N_IPSEC6STAT	41
-	{ "_ipsec6stat" },	/* not available via kvm */
+	{ "_ipsec6stat", 0, 0, 0, 0 },	/* not available via kvm */
 #define N_PIM6STAT	42
-	{ "_pim6stat" },	/* not available via kvm */
+	{ "_pim6stat", 0, 0, 0, 0 },	/* not available via kvm */
 #define N_MRT6PROTO	43
-	{ "_ip6_mrtproto" },
+	{ "_ip6_mrtproto", 0, 0, 0, 0 },
 #define N_MRT6STAT	44
-	{ "_mrt6stat" },
+	{ "_mrt6stat", 0, 0, 0, 0 },
 #define N_MF6CTABLE	45
-	{ "_mf6ctable" },
+	{ "_mf6ctable", 0, 0, 0, 0 },
 #define N_MIF6TABLE	46
-	{ "_mif6table" },
+	{ "_mif6table", 0, 0, 0, 0 },
 #define N_PFKEYSTAT	47
-	{ "_pfkeystat" },	/* not available via kvm */
+	{ "_pfkeystat", 0, 0, 0, 0 },	/* not available via kvm */
 #define N_ARPSTAT	48
-	{ "_arpstat" },		/* not available via kvm */
+	{ "_arpstat", 0, 0, 0, 0 },	/* not available via kvm */
 #define N_RIP6STAT	49
-	{ "_rip6stat" },	/* not available via kvm */
+	{ "_rip6stat", 0, 0, 0, 0 },	/* not available via kvm */
 #define	N_ARPINTRQ	50
-	{ "_arpintrq" },
+	{ "_arpintrq", 0, 0, 0, 0 },
 #define	N_IPINTRQ	51
-	{ "_ipintrq" },
+	{ "_ipintrq", 0, 0, 0, 0 },
 #define	N_IP6INTRQ	52
-	{ "_ip6intrq" },
+	{ "_ip6intrq", 0, 0, 0, 0 },
 #define	N_ATINTRQ1	53
-	{ "_atintrq1" },
+	{ "_atintrq1", 0, 0, 0, 0 },
 #define	N_ATINTRQ2	54
-	{ "_atintrq2" },
+	{ "_atintrq2", 0, 0, 0, 0 },
 #define	N_NSINTRQ	55
-	{ "_nsintrq" },
+	{ "_nsintrq", 0, 0, 0, 0 },
 #define	N_CLNLINTRQ	56
-	{ "_clnlintrq" },
+	{ "_clnlintrq", 0, 0, 0, 0 },
 #define	N_LLCINTRQ	57
-	{ "_llcintrq" },
+	{ "_llcintrq", 0, 0, 0, 0 },
 #define	N_HDINTRQ	58
-	{ "_hdintrq" },
+	{ "_hdintrq", 0, 0, 0, 0 },
 #define	N_NATMINTRQ	59
-	{ "_natmintrq" },
+	{ "_natmintrq", 0, 0, 0, 0 },
 #define	N_PPPOEDISCINQ	61
-	{ "_ppoediscinq" },
+	{ "_ppoediscinq", 0, 0, 0, 0 },
 #define	N_PPPOEINQ	61
-	{ "_ppoeinq" },
+	{ "_ppoeinq", 0, 0, 0, 0 },
 #define	N_PKINTRQ	62
-	{ "_pkintrq" },
+	{ "_pkintrq", 0, 0, 0, 0 },
 #define	N_HARDCLOCK_TICKS 63
-	{ "_hardclock_ticks" },
+	{ "_hardclock_ticks", 0, 0, 0, 0 },
 #define N_PIMSTAT	64
-	{ "_pimstat" },
+	{ "_pimstat", 0, 0, 0, 0 },
 #define N_CARPSTAT	65
-	{ "_carpstats" },	/* not available via kvm */
-	{ "" },
+	{ "_carpstats", 0, 0, 0, 0 },	/* not available via kvm */
+	{ "", 0, 0, 0, 0 },
 };
 
 struct protox {
@@ -206,14 +206,14 @@
 	u_char	pr_sindex;		/* index into nlist of stat block */
 	u_char	pr_wanted;		/* 1 if wanted, 0 otherwise */
 	void	(*pr_cblocks)		/* control blocks printing routine */
-			__P((u_long, char *));
+			__P((u_long, const char *));
 	void	(*pr_stats)		/* statistics printing routine */
-			__P((u_long, char *));
+			__P((u_long, const char *));
 	void	(*pr_istats)
-			__P((char *));	/* per/if statistics printing routine */
+			__P((const char *));	/* per/if statistics printing routine */
 	void	(*pr_dump)		/* PCB state dump routine */
 			__P((u_long));
-	char	*pr_name;		/* well-known name */
+	const char *pr_name;		/* well-known name */
 } protox[] = {
 	{ N_TCBTABLE,	N_TCPSTAT,	1,	protopr,
 	  tcp_stats,	NULL,		tcp_dump,	"tcp" },
@@ -286,7 +286,7 @@
 	{ N_DDPCB,	N_DDPSTAT,	1,	atalkprotopr,
 	  ddp_stats,	NULL,		0,	"ddp" },
 	{ -1,		-1,		0,	0,
-	  0,		NULL,		0 }
+	  0,		NULL,		0,	NULL }
 };
 
 struct protox isoprotox[] = {
@@ -337,15 +337,16 @@
 };
 
 int main __P((int, char *[]));
-static void printproto __P((struct protox *, char *));
+static void printproto __P((struct protox *, const char *));
 static void print_softintrq __P((void));
 static void usage __P((void));
-static struct protox *name2protox __P((char *));
-static struct protox *knownname __P((char *));
+static struct protox *name2protox __P((const char *));
+static struct protox *knownname __P((const char *));
 static void prepare(char *, char *, struct protox *tp);
 
 kvm_t *kvmd;
 gid_t egid;
+int interval;	/* repeat interval for i/f stats */
 
 void
 prepare(char *nlistf, char *memf, struct protox *tp)
@@ -692,9 +693,9 @@
 static void
 printproto(tp, name)
 	struct protox *tp;
-	char *name;
+	const char *name;
 {
-	void (*pr) __P((u_long, char *));
+	void (*pr) __P((u_long, const char *));
 	u_long off;
 
 	if (sflag) {
@@ -757,7 +758,7 @@
 	return (0);
 }
 
-char *
+const char *
 plural(n)
 	int n;
 {
@@ -765,7 +766,7 @@
 	return (n != 1 ? "s" : "");
 }
 
-char *
+const char *
 plurales(n)
 	int n;
 {
@@ -788,7 +789,7 @@
  */
 static struct protox *
 knownname(name)
-	char *name;
+	const char *name;
 {
 	struct protox **tpp, *tp;
 
@@ -804,7 +805,7 @@
  */
 static struct protox *
 name2protox(name)
-	char *name;
+	const char *name;
 {
 	struct protox *tp;
 	char **alias;			/* alias from p->aliases */

Index: src/usr.bin/netstat/mbuf.c
diff -u src/usr.bin/netstat/mbuf.c:1.28 src/usr.bin/netstat/mbuf.c:1.29
--- src/usr.bin/netstat/mbuf.c:1.28	Thu Jan 17 14:53:18 2008
+++ src/usr.bin/netstat/mbuf.c	Sun Apr 12 16:08:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: mbuf.c,v 1.28 2008/01/17 14:53:18 yamt Exp $	*/
+/*	$NetBSD: mbuf.c,v 1.29 2009/04/12 16:08:37 lukem Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "from: @(#)mbuf.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: mbuf.c,v 1.28 2008/01/17 14:53:18 yamt Exp $");
+__RCSID("$NetBSD: mbuf.c,v 1.29 2009/04/12 16:08:37 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -63,8 +63,8 @@
 struct pool_allocator mbpa, mclpa;
 
 static struct mbtypes {
-	int	mt_type;
-	char	*mt_name;
+	int		mt_type;
+	const char	*mt_name;
 } mbtypes[] = {
 	{ MT_DATA,	"data" },
 	{ MT_OOBDATA,	"oob data" },
Index: src/usr.bin/netstat/unix.c
diff -u src/usr.bin/netstat/unix.c:1.28 src/usr.bin/netstat/unix.c:1.29
--- src/usr.bin/netstat/unix.c:1.28	Wed Feb 27 16:36:54 2008
+++ src/usr.bin/netstat/unix.c	Sun Apr 12 16:08:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: unix.c,v 1.28 2008/02/27 16:36:54 ad Exp $	*/
+/*	$NetBSD: unix.c,v 1.29 2009/04/12 16:08:37 lukem Exp $	*/
 
 /*-
  * Copyright (c) 1983, 1988, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "from: @(#)unix.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: unix.c,v 1.28 2008/02/27 16:36:54 ad Exp $");
+__RCSID("$NetBSD: unix.c,v 1.29 2009/04/12 16:08:37 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -84,7 +84,7 @@
 	       "Nextref");
 }
 
-static	char *socktype[] =
+static	const char *socktype[] =
     { "#0", "stream", "dgram", "raw", "rdm", "seqpacket" };
 
 static void
@@ -153,7 +153,7 @@
 		struct kinfo_pcb *pcblist;
 		int mib[8];
 		size_t namelen = 0, size = 0, i;
-		char *mibname = "net.local.stream.pcblist";
+		const char *mibname = "net.local.stream.pcblist";
 		static int first = 1;
 		int done = 0;
 

Index: src/usr.bin/netstat/mroute.c
diff -u src/usr.bin/netstat/mroute.c:1.22 src/usr.bin/netstat/mroute.c:1.23
--- src/usr.bin/netstat/mroute.c:1.22	Mon Dec 29 01:33:03 2008
+++ src/usr.bin/netstat/mroute.c	Sun Apr 12 16:08:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: mroute.c,v 1.22 2008/12/29 01:33:03 christos Exp $	*/
+/*	$NetBSD: mroute.c,v 1.23 2009/04/12 16:08:37 lukem Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -76,7 +76,7 @@
 #if 0
 static char sccsid[] = "from: @(#)mroute.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: mroute.c,v 1.22 2008/12/29 01:33:03 christos Exp $");
+__RCSID("$NetBSD: mroute.c,v 1.23 2009/04/12 16:08:37 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -134,12 +134,11 @@
 {
 	u_int mrtproto;
 	LIST_HEAD(, mfc) *mfchashtbl;
-	u_long mfchash;
+	u_long mfchash, i;
 	struct vif viftable[MAXVIFS];
 	struct mfc *mfcp, mfc;
 	struct vif *v;
 	vifi_t vifi;
-	int i;
 	int banner_printed;
 	int saved_numeric_addr;
 	int numvifs;
@@ -224,7 +223,7 @@
 			}
 
 			kread((u_long)mfcp, (char *)&mfc, sizeof(mfc));
-			printf("  %3u  %-15.15s",
+			printf("  %3lu  %-15.15s",
 			    i, routename4(mfc.mfc_origin.s_addr));
 			printf("  %-15.15s  %7s     %3u ",
 			    routename4(mfc.mfc_mcastgrp.s_addr),

Index: src/usr.bin/netstat/netstat.h
diff -u src/usr.bin/netstat/netstat.h:1.36 src/usr.bin/netstat/netstat.h:1.37
--- src/usr.bin/netstat/netstat.h:1.36	Wed Feb 27 16:36:54 2008
+++ src/usr.bin/netstat/netstat.h	Sun Apr 12 16:08:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: netstat.h,v 1.36 2008/02/27 16:36:54 ad Exp $	*/
+/*	$NetBSD: netstat.h,v 1.37 2009/04/12 16:08:37 lukem Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -56,8 +56,6 @@
 int	tflag;		/* show i/f watchdog timers */
 int	vflag;		/* verbose route information or don't truncate names */
 
-int	interval;	/* repeat interval for i/f stats */
-
 char	*interface;	/* desired i/f for stats, or NULL for all i/fs */
 
 int	af;		/* address family */
@@ -65,49 +63,49 @@
 
 
 int	kread __P((u_long addr, char *buf, int size));
-char	*plural __P((int));
-char	*plurales __P((int));
+const char *plural __P((int));
+const char *plurales __P((int));
 int	get_hardticks __P((void));
 
-void	protopr __P((u_long, char *));
-void	tcp_stats __P((u_long, char *));
+void	protopr __P((u_long, const char *));
+void	tcp_stats __P((u_long, const char *));
 void	tcp_dump __P((u_long));
-void	udp_stats __P((u_long, char *));
-void	ip_stats __P((u_long, char *));
-void	icmp_stats __P((u_long, char *));
-void	igmp_stats __P((u_long, char *));
-void	pim_stats __P((u_long, char *));
-void	arp_stats __P((u_long, char *));
-void	carp_stats __P((u_long, char *));
+void	udp_stats __P((u_long, const char *));
+void	ip_stats __P((u_long, const char *));
+void	icmp_stats __P((u_long, const char *));
+void	igmp_stats __P((u_long, const char *));
+void	pim_stats __P((u_long, const char *));
+void	arp_stats __P((u_long, const char *));
+void	carp_stats __P((u_long, const char *));
 #ifdef IPSEC
 /* run-time selector for which  implementation (KAME, FAST_IPSEC) to show */
-void	ipsec_switch __P((u_long, char *));
+void	ipsec_switch __P((u_long, const char *));
 /* KAME ipsec version */
-void	ipsec_stats __P((u_long, char *));
+void	ipsec_stats __P((u_long, const char *));
 /* FAST_IPSEC version */
-void	fast_ipsec_stats __P((u_long, char *));
+void	fast_ipsec_stats __P((u_long, const char *));
 #endif
 
 #ifdef INET6
 struct sockaddr_in6;
 struct in6_addr;
-void	ip6protopr __P((u_long, char *));
-void	tcp6_stats __P((u_long, char *));
+void	ip6protopr __P((u_long, const char *));
+void	tcp6_stats __P((u_long, const char *));
 void	tcp6_dump __P((u_long));
-void	udp6_stats __P((u_long, char *));
-void	ip6_stats __P((u_long, char *));
-void	ip6_ifstats __P((char *));
-void	icmp6_stats __P((u_long, char *));
-void	icmp6_ifstats __P((char *));
-void	pim6_stats __P((u_long, char *));
-void	rip6_stats __P((u_long, char *));
+void	udp6_stats __P((u_long, const char *));
+void	ip6_stats __P((u_long, const char *));
+void	ip6_ifstats __P((const char *));
+void	icmp6_stats __P((u_long, const char *));
+void	icmp6_ifstats __P((const char *));
+void	pim6_stats __P((u_long, const char *));
+void	rip6_stats __P((u_long, const char *));
 void	mroute6pr __P((u_long, u_long, u_long));
 void	mrt6_stats __P((u_long, u_long));
 char	*routename6 __P((struct sockaddr_in6 *));
 #endif /*INET6*/
 
 #ifdef IPSEC
-void	pfkey_stats __P((u_long, char *));
+void	pfkey_stats __P((u_long, const char *));
 #endif
 
 void	mbpr(u_long, u_long, u_long, u_long, u_long);
@@ -122,7 +120,7 @@
 void	upHex __P((char *));
 
 void	p_rttables(int);
-void	p_flags(int, char *);
+void	p_flags(int, const char *);
 void	p_addr(struct sockaddr *, struct sockaddr *, int);
 void	p_gwaddr(struct sockaddr *, int);
 void	p_sockaddr(struct sockaddr *, struct sockaddr *, int, int);
@@ -136,37 +134,37 @@
 #ifdef INET6
 char	*netname6 __P((struct sockaddr_in6 *, struct sockaddr_in6 *));
 #endif 
-char	*atalk_print __P((const struct sockaddr *, int));
-char	*atalk_print2 __P((const struct sockaddr *, const struct sockaddr *,
+const char *atalk_print __P((const struct sockaddr *, int));
+const char *atalk_print2 __P((const struct sockaddr *, const struct sockaddr *,
     int));
 char	*ns_print __P((struct sockaddr *));
 void	routepr __P((u_long));
 
-void	nsprotopr __P((u_long, char *));
-void	spp_stats __P((u_long, char *));
-void	idp_stats __P((u_long, char *));
-void	nserr_stats __P((u_long, char *));
+void	nsprotopr __P((u_long, const char *));
+void	spp_stats __P((u_long, const char *));
+void	idp_stats __P((u_long, const char *));
+void	nserr_stats __P((u_long, const char *));
 
-void	atalkprotopr __P((u_long, char *));
-void	ddp_stats __P((u_long, char *));
+void	atalkprotopr __P((u_long, const char *));
+void	ddp_stats __P((u_long, const char *));
 
-void	intpr __P((int, u_long, void (*) __P((char *))));
+void	intpr __P((int, u_long, void (*) __P((const char *))));
 
 void	unixpr __P((u_long));
 
-void	esis_stats __P((u_long, char *));
-void	clnp_stats __P((u_long, char *));
-void	cltp_stats __P((u_long, char *));
-void	iso_protopr __P((u_long, char *));
+void	esis_stats __P((u_long, const char *));
+void	clnp_stats __P((u_long, const char *));
+void	cltp_stats __P((u_long, const char *));
+void	iso_protopr __P((u_long, const char *));
 void	iso_protopr1 __P((u_long, int));
-void	tp_protopr __P((u_long, char *));
+void	tp_protopr __P((u_long, const char *));
 void	tp_inproto __P((u_long));
-void	tp_stats __P((u_long, char *));
+void	tp_stats __P((u_long, const char *));
 
 void	mroutepr __P((u_long, u_long, u_long, u_long));
 void	mrt_stats __P((u_long, u_long));
 
 void	bpf_stats(void);
-void	bpf_dump(char *);
+void	bpf_dump(const char *);
 
 #define PLEN    (LONG_BIT / 4 + 2)

Index: src/usr.bin/netstat/route.c
diff -u src/usr.bin/netstat/route.c:1.72 src/usr.bin/netstat/route.c:1.73
--- src/usr.bin/netstat/route.c:1.72	Mon Dec 29 01:33:03 2008
+++ src/usr.bin/netstat/route.c	Sun Apr 12 16:08:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: route.c,v 1.72 2008/12/29 01:33:03 christos Exp $	*/
+/*	$NetBSD: route.c,v 1.73 2009/04/12 16:08:37 lukem Exp $	*/
 
 /*
  * Copyright (c) 1983, 1988, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "from: @(#)route.c	8.3 (Berkeley) 3/9/94";
 #else
-__RCSID("$NetBSD: route.c,v 1.72 2008/12/29 01:33:03 christos Exp $");
+__RCSID("$NetBSD: route.c,v 1.73 2009/04/12 16:08:37 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -109,7 +109,7 @@
 	u_long rtree;
 {
 	struct radix_node_head *rnh, head;
-	struct radix_node_head *rt_tables[AF_MAX+1];
+	struct radix_node_head *rt_nodes[AF_MAX+1];
 	int i;
 
 	printf("Routing tables\n");
@@ -119,9 +119,9 @@
 		return;
 	}
 
-	kget(rtree, rt_tables);
+	kget(rtree, rt_nodes);
 	for (i = 0; i <= AF_MAX; i++) {
-		if ((rnh = rt_tables[i]) == 0)
+		if ((rnh = rt_nodes[i]) == 0)
 			continue;
 		kget(rnh, head);
 		if (i == AF_UNSPEC) {
@@ -168,7 +168,7 @@
 			if (Aflag)
 				p_rtnode();
 		} else {
-			p_sockaddr(kgetsa((struct sockaddr *)rnode.rn_key),
+			p_sockaddr(kgetsa((const struct sockaddr *)rnode.rn_key),
 			    NULL, 0, 44);
 			putchar('\n');
 		}
@@ -194,7 +194,7 @@
 	if (rnode.rn_b < 0) {
 		if (rnode.rn_mask) {
 			printf("\t  mask ");
-			p_sockaddr(kgetsa((struct sockaddr *)rnode.rn_mask),
+			p_sockaddr(kgetsa((const struct sockaddr *)rnode.rn_mask),
 				    NULL, 0, -1);
 		} else if (rm == 0)
 			return;
@@ -212,10 +212,10 @@
 			struct radix_node rnode_aux;
 			printf(" <normal>, ");
 			kget(rmask.rm_leaf, rnode_aux);
-			p_sockaddr(kgetsa((struct sockaddr *)rnode_aux.rn_mask),
+			p_sockaddr(kgetsa((const struct sockaddr *)rnode_aux.rn_mask),
 				    NULL, 0, -1);
 		} else
-			p_sockaddr(kgetsa((struct sockaddr *)rmask.rm_mask),
+			p_sockaddr(kgetsa((const struct sockaddr *)rmask.rm_mask),
 			    NULL, 0, -1);
 		putchar('}');
 		if ((rm = rmask.rm_mklist) != NULL)
@@ -254,7 +254,6 @@
 	static struct ifnet ifnet, *lastif;
 	union sockaddr_union addr_un, mask_un;
 	struct sockaddr *addr, *mask;
-	int af;
 
 	if (Lflag && (rt->rt_flags & RTF_LLINFO))
 		return;
@@ -262,7 +261,6 @@
 	memset(&addr_un, 0, sizeof(addr_un));
 	memset(&mask_un, 0, sizeof(mask_un));
 	addr = sockcopy(kgetsa(rt_getkey(rt)), &addr_un);
-	af = addr->sa_family;
 	if (rt_mask(rt))
 		mask = sockcopy(kgetsa(rt_mask(rt)), &mask_un);
 	else
@@ -315,36 +313,36 @@
 rt_stats(off)
 	u_long off;
 {
-	struct rtstat rtstat;
+	struct rtstat rtstats;
 
 	if (use_sysctl) {
-		size_t rtsize = sizeof(rtstat);
+		size_t rtsize = sizeof(rtstats);
 
-		if (sysctlbyname("net.route.stats", &rtstat, &rtsize,
+		if (sysctlbyname("net.route.stats", &rtstats, &rtsize,
 		    NULL, 0) == -1)
 			err(1, "rt_stats: sysctl");
 	} else 	if (off == 0) {
 		printf("rtstat: symbol not in namelist\n");
 		return;
 	} else
-		kread(off, (char *)&rtstat, sizeof (rtstat));
+		kread(off, (char *)&rtstats, sizeof(rtstats));
 
 	printf("routing:\n");
 	printf("\t%llu bad routing redirect%s\n",
-		(unsigned long long)rtstat.rts_badredirect,
-		plural(rtstat.rts_badredirect));
+		(unsigned long long)rtstats.rts_badredirect,
+		plural(rtstats.rts_badredirect));
 	printf("\t%llu dynamically created route%s\n",
-		(unsigned long long)rtstat.rts_dynamic,
-		plural(rtstat.rts_dynamic));
+		(unsigned long long)rtstats.rts_dynamic,
+		plural(rtstats.rts_dynamic));
 	printf("\t%llu new gateway%s due to redirects\n",
-		(unsigned long long)rtstat.rts_newgateway,
-		plural(rtstat.rts_newgateway));
+		(unsigned long long)rtstats.rts_newgateway,
+		plural(rtstats.rts_newgateway));
 	printf("\t%llu destination%s found unreachable\n",
-		(unsigned long long)rtstat.rts_unreach,
-		plural(rtstat.rts_unreach));
+		(unsigned long long)rtstats.rts_unreach,
+		plural(rtstats.rts_unreach));
 	printf("\t%llu use%s of a wildcard route\n",
-		(unsigned long long)rtstat.rts_wildcard,
-		plural(rtstat.rts_wildcard));
+		(unsigned long long)rtstats.rts_wildcard,
+		plural(rtstats.rts_wildcard));
 }
 
 void

Index: src/usr.bin/netstat/show.c
diff -u src/usr.bin/netstat/show.c:1.6 src/usr.bin/netstat/show.c:1.7
--- src/usr.bin/netstat/show.c:1.6	Sat Dec 23 11:05:14 2006
+++ src/usr.bin/netstat/show.c	Sun Apr 12 16:08:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: show.c,v 1.6 2006/12/23 11:05:14 jdc Exp $	*/
+/*	$NetBSD: show.c,v 1.7 2009/04/12 16:08:37 lukem Exp $	*/
 /*	$OpenBSD: show.c,v 1.1 2006/05/27 19:16:37 claudio Exp $	*/
 
 /*
@@ -92,14 +92,13 @@
 	/* { RTF_PROTO3,	'3' }, */
 	{ RTF_CLONED,	'c' },
 	/* { RTF_JUMBO,	'J' }, */
-	{ 0 }
+	{ 0, 0 }
 };
 
 void	 pr_rthdr(int, int);
 void	 p_rtentry(struct rt_msghdr *);
 void	 pr_family(int);
 void	 p_sockaddr(struct sockaddr *, struct sockaddr *, int, int);
-void	 p_flags(int, char *);
 char	*routename4(in_addr_t);
 char	*routename6(struct sockaddr_in6 *);
 
@@ -107,7 +106,7 @@
  * Print routing tables.
  */
 void
-p_rttables(int af)
+p_rttables(int paf)
 {
 	struct rt_msghdr *rtm;
 	char *buf = NULL, *next, *lim = NULL;
@@ -118,7 +117,7 @@
 	mib[0] = CTL_NET;
 	mib[1] = PF_ROUTE;
 	mib[2] = 0;
-	mib[3] = af;
+	mib[3] = paf;
 	mib[4] = NET_RT_DUMP;
 	mib[5] = 0;
 	if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0)
@@ -137,7 +136,7 @@
 		for (next = buf; next < lim; next += rtm->rtm_msglen) {
 			rtm = (struct rt_msghdr *)next;
 			sa = (struct sockaddr *)(rtm + 1);
-			if (af != AF_UNSPEC && sa->sa_family != af)
+			if (paf != AF_UNSPEC && sa->sa_family != paf)
 				continue;
 			p_rtentry(rtm);
 		}
@@ -145,7 +144,7 @@
 		buf = NULL;
 	}
 
-	if (af != 0 && af != PF_KEY)
+	if (paf != 0 && paf != PF_KEY)
 		return;
 
 #ifdef notyet /* XXX elad */
@@ -196,14 +195,14 @@
  * Print header for routing table columns.
  */
 void
-pr_rthdr(int af, int Aflag)
+pr_rthdr(int paf, int pAflag)
 {
-	if (Aflag)
+	if (pAflag)
 		printf("%-*.*s ", PLEN, PLEN, "Address");
-	if (af != PF_KEY)
+	if (paf != PF_KEY)
 		printf("%-*.*s %-*.*s %-6.6s %6.6s %8.8s %6.6s  %s\n",
-		    WID_DST(af), WID_DST(af), "Destination",
-		    WID_GW(af), WID_GW(af), "Gateway",
+		    WID_DST(paf), WID_DST(paf), "Destination",
+		    WID_GW(paf), WID_GW(paf), "Gateway",
 		    "Flags", "Refs", "Use", "Mtu", "Interface");
 	else
 		printf("%-18s %-5s %-18s %-5s %-5s %-22s\n",
@@ -272,11 +271,11 @@
  * Print address family header before a section of the routing table.
  */
 void
-pr_family(int af)
+pr_family(int paf)
 {
-	char *afname;
+	const char *afname;
 
-	switch (af) {
+	switch (paf) {
 	case AF_INET:
 		afname = "Internet";
 		break;
@@ -296,7 +295,7 @@
 	if (afname)
 		printf("\n%s:\n", afname);
 	else
-		printf("\nProtocol Family %d:\n", af);
+		printf("\nProtocol Family %d:\n", paf);
 }
 
 void
@@ -306,9 +305,9 @@
 }
 
 void
-p_gwaddr(struct sockaddr *sa, int af)
+p_gwaddr(struct sockaddr *sa, int gwaf)
 {
-	p_sockaddr(sa, 0, RTF_HOST, WID_GW(af));
+	p_sockaddr(sa, 0, RTF_HOST, WID_GW(gwaf));
 }
 
 void
@@ -357,7 +356,7 @@
 }
 
 void
-p_flags(int f, char *format)
+p_flags(int f, const char *format)
 {
 	char name[33], *flags;
 	const struct bits *p = bits;
@@ -444,7 +443,7 @@
 char *
 routename4(in_addr_t in)
 {
-	char		*cp = NULL;
+	const char	*cp = NULL;
 	struct in_addr	 ina;
 	struct hostent	*hp;
 
@@ -453,9 +452,10 @@
 	if (!cp && !nflag) {
 		if ((hp = gethostbyaddr((char *)&in,
 		    sizeof(in), AF_INET)) != NULL) {
-			if ((cp = strchr(hp->h_name, '.')) &&
-			    !strcmp(cp + 1, domain))
-				*cp = '\0';
+			char *p;
+			if ((p = strchr(hp->h_name, '.')) &&
+			    !strcmp(p + 1, domain))
+				*p = '\0';
 			cp = hp->h_name;
 		}
 	}
@@ -489,7 +489,7 @@
 char *
 netname4(in_addr_t in, in_addr_t mask)
 {
-	char *cp = NULL;
+	const char *cp = NULL;
 	struct netent *np = NULL;
 	int mbits;
 
@@ -538,7 +538,7 @@
 		lim = mask->sin6_len - offsetof(struct sockaddr_in6, sin6_addr);
 		if (lim < 0)
 			lim = 0;
-		else if (lim > sizeof(struct in6_addr))
+		else if (lim > (int)sizeof(struct in6_addr))
 			lim = sizeof(struct in6_addr);
 		for (p = (u_char *)&mask->sin6_addr, i = 0; i < lim; p++) {
 			if (final && *p) {
@@ -593,13 +593,15 @@
 			else
 				sin6.sin6_addr.s6_addr[i++] = 0x00;
 		}
-		while (i < sizeof(struct in6_addr))
+		while (i < (int)sizeof(struct in6_addr))
 			sin6.sin6_addr.s6_addr[i++] = 0x00;
 	} else
 		masklen = 128;
 
-	if (masklen == 0 && IN6_IS_ADDR_UNSPECIFIED(&sin6.sin6_addr))
-		return ("default");
+	if (masklen == 0 && IN6_IS_ADDR_UNSPECIFIED(&sin6.sin6_addr)) {
+		snprintf(line, sizeof(line), "default");
+		return (line);
+	}
 
 	if (illegal)
 		warnx("illegal prefixlen");

Reply via email to