From 7d56c0ee6bfb141be513785ad79b4d8a440a91ea Mon Sep 17 00:00:00 2001
From: Alexander Langer <alex@FreeBSD.org>
Date: Sun, 2 Jun 1996 23:19:12 +0000
Subject: [PATCH] Code cleanup: remove unused variables, use correct *printf
 format specifiers (some unsigned values were printed as signed, some longs
 were printed as ints), and place parentheses around assignments in if
 statements.

---
 usr.bin/netstat/if.c     |  15 ++--
 usr.bin/netstat/inet.c   | 182 +++++++++++++++++++--------------------
 usr.bin/netstat/ipx.c    |   6 +-
 usr.bin/netstat/main.c   |  11 ++-
 usr.bin/netstat/mbuf.c   |   8 +-
 usr.bin/netstat/mroute.c |  31 ++++---
 usr.bin/netstat/route.c  |  28 +++---
 usr.bin/netstat/unix.c   |  10 +--
 8 files changed, 144 insertions(+), 147 deletions(-)

diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c
index d4cedce33d59..43fd8cb4ba5e 100644
--- a/usr.bin/netstat/if.c
+++ b/usr.bin/netstat/if.c
@@ -136,7 +136,7 @@ intpr(interval, ifnetaddr)
 			*cp = '\0';
 			ifaddraddr = (u_long)ifnet.if_addrlist;
 		}
-		printf("%-5.5s %-5d ", name, ifnet.if_mtu);
+		printf("%-5.5s %-5lu ", name, ifnet.if_mtu);
 		if (ifaddraddr == 0) {
 			printf("%-13.13s ", "none");
 			printf("%-15.15s ", "none");
@@ -229,15 +229,15 @@ intpr(interval, ifnetaddr)
 			}
 			ifaddraddr = (u_long)ifaddr.ifa.ifa_next;
 		}
-		printf("%8d %5d ",
+		printf("%8lu %5lu ",
 		    ifnet.if_ipackets, ifnet.if_ierrors);
 		if (bflag)
-			printf("%10d ", ifnet.if_ibytes);
-		printf("%8d %5d ",
+			printf("%10lu ", ifnet.if_ibytes);
+		printf("%8lu %5lu ",
 		    ifnet.if_opackets, ifnet.if_oerrors);
 		if (bflag)
-			printf("%10d ", ifnet.if_obytes);
-		printf("%5d", ifnet.if_collisions);
+			printf("%10lu ", ifnet.if_obytes);
+		printf("%5lu", ifnet.if_collisions);
 		if (tflag)
 			printf(" %3d", ifnet.if_timer);
 		if (dflag)
@@ -288,7 +288,6 @@ sidewaysintpr(interval, off)
 	interesting = NULL;
 	interesting_off = 0;
 	for (off = firstifnet, ip = iftot; off;) {
-		char *cp;
 		char name[16], tname[16];
 
 		if (kread(off, (char *)&ifnet, sizeof ifnet))
@@ -342,7 +341,7 @@ loop:
 			exit(1);
 		};
 		if (!first) {
-			printf("%10u %5u %10u %10u %5u %10u %5u",
+			printf("%10lu %5lu %10lu %10lu %5lu %10lu %5lu",
 				ifnet.if_ipackets - ip->ift_ip,
 				ifnet.if_ierrors - ip->ift_ie,
 				ifnet.if_ibytes - ip->ift_ib,
diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c
index 0a2848e4b503..057f150bb429 100644
--- a/usr.bin/netstat/inet.c
+++ b/usr.bin/netstat/inet.c
@@ -136,10 +136,10 @@ protopr(off, name)
 		}
 		if (Aflag)
 			if (istcp)
-				printf("%8x ", inpcb.inp_ppcb);
+				printf("%8x ", (int)inpcb.inp_ppcb);
 			else
-				printf("%8x ", next);
-		printf("%-5.5s %6d %6d ", name, sockb.so_rcv.sb_cc,
+				printf("%8x ", (int)next);
+		printf("%-5.5s %6ld %6ld ", name, sockb.so_rcv.sb_cc,
 			sockb.so_snd.sb_cc);
 		inetprint(&inpcb.inp_laddr, (int)inpcb.inp_lport, name);
 		inetprint(&inpcb.inp_faddr, (int)inpcb.inp_fport, name);
@@ -182,63 +182,63 @@ tcp_stats(off, name)
 #define	p3(f, m) if (tcpstat.f || sflag <= 1) \
     printf(m, tcpstat.f, plurales(tcpstat.f))
 
-	p(tcps_sndtotal, "\t%d packet%s sent\n");
+	p(tcps_sndtotal, "\t%ld packet%s sent\n");
 	p2(tcps_sndpack,tcps_sndbyte,
-		"\t\t%d data packet%s (%d byte%s)\n");
+		"\t\t%ld data packet%s (%ld byte%s)\n");
 	p2(tcps_sndrexmitpack, tcps_sndrexmitbyte,
-		"\t\t%d data packet%s (%d byte%s) retransmitted\n");
-	p(tcps_mturesent, "\t\t%d resend%s initiated by MTU discovery\n");
+		"\t\t%ld data packet%s (%ld byte%s) retransmitted\n");
+	p(tcps_mturesent, "\t\t%ld resend%s initiated by MTU discovery\n");
 	p2(tcps_sndacks, tcps_delack,
-		"\t\t%d ack-only packet%s (%d delayed)\n");
-	p(tcps_sndurg, "\t\t%d URG only packet%s\n");
-	p(tcps_sndprobe, "\t\t%d window probe packet%s\n");
-	p(tcps_sndwinup, "\t\t%d window update packet%s\n");
-	p(tcps_sndctrl, "\t\t%d control packet%s\n");
-	p(tcps_rcvtotal, "\t%d packet%s received\n");
-	p2(tcps_rcvackpack, tcps_rcvackbyte, "\t\t%d ack%s (for %d byte%s)\n");
-	p(tcps_rcvdupack, "\t\t%d duplicate ack%s\n");
-	p(tcps_rcvacktoomuch, "\t\t%d ack%s for unsent data\n");
+		"\t\t%ld ack-only packet%s (%ld delayed)\n");
+	p(tcps_sndurg, "\t\t%ld URG only packet%s\n");
+	p(tcps_sndprobe, "\t\t%ld window probe packet%s\n");
+	p(tcps_sndwinup, "\t\t%ld window update packet%s\n");
+	p(tcps_sndctrl, "\t\t%ld control packet%s\n");
+	p(tcps_rcvtotal, "\t%ld packet%s received\n");
+	p2(tcps_rcvackpack, tcps_rcvackbyte, "\t\t%ld ack%s (for %ld byte%s)\n");
+	p(tcps_rcvdupack, "\t\t%ld duplicate ack%s\n");
+	p(tcps_rcvacktoomuch, "\t\t%ld ack%s for unsent data\n");
 	p2(tcps_rcvpack, tcps_rcvbyte,
-		"\t\t%d packet%s (%d byte%s) received in-sequence\n");
+		"\t\t%ld packet%s (%ld byte%s) received in-sequence\n");
 	p2(tcps_rcvduppack, tcps_rcvdupbyte,
-		"\t\t%d completely duplicate packet%s (%d byte%s)\n");
-	p(tcps_pawsdrop, "\t\t%d old duplicate packet%s\n");
+		"\t\t%ld completely duplicate packet%s (%ld byte%s)\n");
+	p(tcps_pawsdrop, "\t\t%ld old duplicate packet%s\n");
 	p2(tcps_rcvpartduppack, tcps_rcvpartdupbyte,
-		"\t\t%d packet%s with some dup. data (%d byte%s duped)\n");
+		"\t\t%ld packet%s with some dup. data (%ld byte%s duped)\n");
 	p2(tcps_rcvoopack, tcps_rcvoobyte,
-		"\t\t%d out-of-order packet%s (%d byte%s)\n");
+		"\t\t%ld out-of-order packet%s (%ld byte%s)\n");
 	p2(tcps_rcvpackafterwin, tcps_rcvbyteafterwin,
-		"\t\t%d packet%s (%d byte%s) of data after window\n");
-	p(tcps_rcvwinprobe, "\t\t%d window probe%s\n");
-	p(tcps_rcvwinupd, "\t\t%d window update packet%s\n");
-	p(tcps_rcvafterclose, "\t\t%d packet%s received after close\n");
-	p(tcps_rcvbadsum, "\t\t%d discarded for bad checksum%s\n");
-	p(tcps_rcvbadoff, "\t\t%d discarded for bad header offset field%s\n");
-	p(tcps_rcvshort, "\t\t%d discarded because packet too short\n");
-	p(tcps_connattempt, "\t%d connection request%s\n");
-	p(tcps_accepts, "\t%d connection accept%s\n");
-	p(tcps_badsyn, "\t%d bad connection attempt%s\n");
-	p(tcps_listendrop, "\t%d listen queue overflow%s\n");
-	p(tcps_connects, "\t%d connection%s established (including accepts)\n");
+		"\t\t%ld packet%s (%ld byte%s) of data after window\n");
+	p(tcps_rcvwinprobe, "\t\t%ld window probe%s\n");
+	p(tcps_rcvwinupd, "\t\t%ld window update packet%s\n");
+	p(tcps_rcvafterclose, "\t\t%ld packet%s received after close\n");
+	p(tcps_rcvbadsum, "\t\t%ld discarded for bad checksum%s\n");
+	p(tcps_rcvbadoff, "\t\t%ld discarded for bad header offset field%s\n");
+	p(tcps_rcvshort, "\t\t%ld discarded because packet too short\n");
+	p(tcps_connattempt, "\t%ld connection request%s\n");
+	p(tcps_accepts, "\t%ld connection accept%s\n");
+	p(tcps_badsyn, "\t%ld bad connection attempt%s\n");
+	p(tcps_listendrop, "\t%ld listen queue overflow%s\n");
+	p(tcps_connects, "\t%ld connection%s established (including accepts)\n");
 	p2(tcps_closed, tcps_drops,
-		"\t%d connection%s closed (including %d drop%s)\n");
-	p(tcps_cachedrtt, "\t\t%d connection%s updated cached RTT on close\n");
+		"\t%ld connection%s closed (including %ld drop%s)\n");
+	p(tcps_cachedrtt, "\t\t%ld connection%s updated cached RTT on close\n");
 	p(tcps_cachedrttvar, 
-	  "\t\t%d connection%s updated cached RTT variance on close\n");
+	  "\t\t%ld connection%s updated cached RTT variance on close\n");
 	p(tcps_cachedssthresh,
-	  "\t\t%d connection%s updated cached ssthresh on close\n");
-	p(tcps_conndrops, "\t%d embryonic connection%s dropped\n");
+	  "\t\t%ld connection%s updated cached ssthresh on close\n");
+	p(tcps_conndrops, "\t%ld embryonic connection%s dropped\n");
 	p2(tcps_rttupdated, tcps_segstimed,
-		"\t%d segment%s updated rtt (of %d attempt%s)\n");
-	p(tcps_rexmttimeo, "\t%d retransmit timeout%s\n");
-	p(tcps_timeoutdrop, "\t\t%d connection%s dropped by rexmit timeout\n");
-	p(tcps_persisttimeo, "\t%d persist timeout%s\n");
-	p(tcps_persistdrop, "\t\t%d connection%s dropped by persist timeout\n");
-	p(tcps_keeptimeo, "\t%d keepalive timeout%s\n");
-	p(tcps_keepprobe, "\t\t%d keepalive probe%s sent\n");
-	p(tcps_keepdrops, "\t\t%d connection%s dropped by keepalive\n");
-	p(tcps_predack, "\t%d correct ACK header prediction%s\n");
-	p(tcps_preddat, "\t%d correct data packet header prediction%s\n");
+		"\t%ld segment%s updated rtt (of %ld attempt%s)\n");
+	p(tcps_rexmttimeo, "\t%ld retransmit timeout%s\n");
+	p(tcps_timeoutdrop, "\t\t%ld connection%s dropped by rexmit timeout\n");
+	p(tcps_persisttimeo, "\t%ld persist timeout%s\n");
+	p(tcps_persistdrop, "\t\t%ld connection%s dropped by persist timeout\n");
+	p(tcps_keeptimeo, "\t%ld keepalive timeout%s\n");
+	p(tcps_keepprobe, "\t\t%ld keepalive probe%s sent\n");
+	p(tcps_keepdrops, "\t\t%ld connection%s dropped by keepalive\n");
+	p(tcps_predack, "\t%ld correct ACK header prediction%s\n");
+	p(tcps_preddat, "\t%ld correct data packet header prediction%s\n");
 #undef p
 #undef p2
 #undef p3
@@ -261,13 +261,13 @@ udp_stats(off, name)
 	printf("%s:\n", name);
 #define	p(f, m) if (udpstat.f || sflag <= 1) \
     printf(m, udpstat.f, plural(udpstat.f))
-	p(udps_ipackets, "\t%u datagram%s received\n");
-	p(udps_hdrops, "\t%u with incomplete header\n");
-	p(udps_badlen, "\t%u with bad data length field\n");
-	p(udps_badsum, "\t%u with bad checksum\n");
-	p(udps_noport, "\t%u dropped due to no socket\n");
-	p(udps_noportbcast, "\t%u broadcast/multicast datagram%s dropped due to no socket\n");
-	p(udps_fullsock, "\t%u dropped due to full socket buffers\n");
+	p(udps_ipackets, "\t%lu datagram%s received\n");
+	p(udps_hdrops, "\t%lu with incomplete header\n");
+	p(udps_badlen, "\t%lu with bad data length field\n");
+	p(udps_badsum, "\t%lu with bad checksum\n");
+	p(udps_noport, "\t%lu dropped due to no socket\n");
+	p(udps_noportbcast, "\t%lu broadcast/multicast datagram%s dropped due to no socket\n");
+	p(udps_fullsock, "\t%lu dropped due to full socket buffers\n");
 	delivered = udpstat.udps_ipackets -
 		    udpstat.udps_hdrops -
 		    udpstat.udps_badlen -
@@ -276,8 +276,8 @@ udp_stats(off, name)
 		    udpstat.udps_noportbcast -
 		    udpstat.udps_fullsock;
 	if (delivered || sflag <= 1)
-		printf("\t%u delivered\n", delivered);
-	p(udps_opackets, "\t%u datagram%s output\n");
+		printf("\t%lu delivered\n", delivered);
+	p(udps_opackets, "\t%lu datagram%s output\n");
 #undef p
 }
 
@@ -299,30 +299,30 @@ ip_stats(off, name)
 #define	p(f, m) if (ipstat.f || sflag <= 1) \
     printf(m, ipstat.f, plural(ipstat.f))
 
-	p(ips_total, "\t%u total packet%s received\n");
-	p(ips_badsum, "\t%u bad header checksum%s\n");
-	p(ips_toosmall, "\t%u with size smaller than minimum\n");
-	p(ips_tooshort, "\t%u with data size < data length\n");
-	p(ips_badhlen, "\t%u with header length < data size\n");
-	p(ips_badlen, "\t%u with data length < header length\n");
-	p(ips_badoptions, "\t%u with bad options\n");
-	p(ips_badvers, "\t%u with incorrect version number\n");
-	p(ips_fragments, "\t%u fragment%s received\n");
-	p(ips_fragdropped, "\t%u fragment%s dropped (dup or out of space)\n");
-	p(ips_fragtimeout, "\t%u fragment%s dropped after timeout\n");
-	p(ips_reassembled, "\t%u packet%s reassembled ok\n");
-	p(ips_delivered, "\t%u packet%s for this host\n");
-	p(ips_noproto, "\t%u packet%s for unknown/unsupported protocol\n");
-	p(ips_forward, "\t%u packet%s forwarded\n");
-	p(ips_cantforward, "\t%u packet%s not forwardable\n");
-	p(ips_redirectsent, "\t%u redirect%s sent\n");
-	p(ips_localout, "\t%u packet%s sent from this host\n");
-	p(ips_rawout, "\t%u packet%s sent with fabricated ip header\n");
-	p(ips_odropped, "\t%u output packet%s dropped due to no bufs, etc.\n");
-	p(ips_noroute, "\t%u output packet%s discarded due to no route\n");
-	p(ips_fragmented, "\t%u output datagram%s fragmented\n");
-	p(ips_ofragments, "\t%u fragment%s created\n");
-	p(ips_cantfrag, "\t%u datagram%s that can't be fragmented\n");
+	p(ips_total, "\t%lu total packet%s received\n");
+	p(ips_badsum, "\t%lu bad header checksum%s\n");
+	p(ips_toosmall, "\t%lu with size smaller than minimum\n");
+	p(ips_tooshort, "\t%lu with data size < data length\n");
+	p(ips_badhlen, "\t%lu with header length < data size\n");
+	p(ips_badlen, "\t%lu with data length < header length\n");
+	p(ips_badoptions, "\t%lu with bad options\n");
+	p(ips_badvers, "\t%lu with incorrect version number\n");
+	p(ips_fragments, "\t%lu fragment%s received\n");
+	p(ips_fragdropped, "\t%lu fragment%s dropped (dup or out of space)\n");
+	p(ips_fragtimeout, "\t%lu fragment%s dropped after timeout\n");
+	p(ips_reassembled, "\t%lu packet%s reassembled ok\n");
+	p(ips_delivered, "\t%lu packet%s for this host\n");
+	p(ips_noproto, "\t%lu packet%s for unknown/unsupported protocol\n");
+	p(ips_forward, "\t%lu packet%s forwarded\n");
+	p(ips_cantforward, "\t%lu packet%s not forwardable\n");
+	p(ips_redirectsent, "\t%lu redirect%s sent\n");
+	p(ips_localout, "\t%lu packet%s sent from this host\n");
+	p(ips_rawout, "\t%lu packet%s sent with fabricated ip header\n");
+	p(ips_odropped, "\t%lu output packet%s dropped due to no bufs, etc.\n");
+	p(ips_noroute, "\t%lu output packet%s discarded due to no route\n");
+	p(ips_fragmented, "\t%lu output datagram%s fragmented\n");
+	p(ips_ofragments, "\t%lu fragment%s created\n");
+	p(ips_cantfrag, "\t%lu datagram%s that can't be fragmented\n");
 #undef p
 }
 
@@ -367,32 +367,32 @@ icmp_stats(off, name)
 #define	p(f, m) if (icmpstat.f || sflag <= 1) \
     printf(m, icmpstat.f, plural(icmpstat.f))
 
-	p(icps_error, "\t%u call%s to icmp_error\n");
+	p(icps_error, "\t%lu call%s to icmp_error\n");
 	p(icps_oldicmp,
-	    "\t%u error%s not generated 'cuz old message was icmp\n");
+	    "\t%lu error%s not generated 'cuz old message was icmp\n");
 	for (first = 1, i = 0; i < ICMP_MAXTYPE + 1; i++)
 		if (icmpstat.icps_outhist[i] != 0) {
 			if (first) {
 				printf("\tOutput histogram:\n");
 				first = 0;
 			}
-			printf("\t\t%s: %u\n", icmpnames[i],
+			printf("\t\t%s: %lu\n", icmpnames[i],
 				icmpstat.icps_outhist[i]);
 		}
-	p(icps_badcode, "\t%u message%s with bad code fields\n");
-	p(icps_tooshort, "\t%u message%s < minimum length\n");
-	p(icps_checksum, "\t%u bad checksum%s\n");
-	p(icps_badlen, "\t%u message%s with bad length\n");
+	p(icps_badcode, "\t%lu message%s with bad code fields\n");
+	p(icps_tooshort, "\t%lu message%s < minimum length\n");
+	p(icps_checksum, "\t%lu bad checksum%s\n");
+	p(icps_badlen, "\t%lu message%s with bad length\n");
 	for (first = 1, i = 0; i < ICMP_MAXTYPE + 1; i++)
 		if (icmpstat.icps_inhist[i] != 0) {
 			if (first) {
 				printf("\tInput histogram:\n");
 				first = 0;
 			}
-			printf("\t\t%s: %u\n", icmpnames[i],
+			printf("\t\t%s: %lu\n", icmpnames[i],
 				icmpstat.icps_inhist[i]);
 		}
-	p(icps_reflect, "\t%u message response%s generated\n");
+	p(icps_reflect, "\t%lu message response%s generated\n");
 #undef p
 }
 
@@ -493,7 +493,7 @@ inetname(inp)
 	else {
 		inp->s_addr = ntohl(inp->s_addr);
 #define C(x)	((x) & 0xff)
-		sprintf(line, "%u.%u.%u.%u", C(inp->s_addr >> 24),
+		sprintf(line, "%lu.%lu.%lu.%lu", C(inp->s_addr >> 24),
 		    C(inp->s_addr >> 16), C(inp->s_addr >> 8), C(inp->s_addr));
 	}
 	return (line);
diff --git a/usr.bin/netstat/ipx.c b/usr.bin/netstat/ipx.c
index 2355d507b621..4f47d98843a7 100644
--- a/usr.bin/netstat/ipx.c
+++ b/usr.bin/netstat/ipx.c
@@ -132,8 +132,8 @@ ipxprotopr(off, name)
 			first = 0;
 		}
 		if (Aflag)
-			printf("%8x ", ppcb);
-		printf("%-5.5s %6d %6d ", name, sockb.so_rcv.sb_cc,
+			printf("%8lx ", ppcb);
+		printf("%-5.5s %6ld %6ld ", name, sockb.so_rcv.sb_cc,
 			sockb.so_snd.sb_cc);
 		printf(Aflag?" %-18.18s":" %-22.22s", ipx_prpr(&ipxpcb.ipxp_laddr));
 		printf(Aflag?" %-18.18s":" %-22.22s", ipx_prpr(&ipxpcb.ipxp_faddr));
@@ -149,7 +149,7 @@ ipxprotopr(off, name)
 	}
 }
 #define ANY(x,y,z) \
-	((x) ? printf("\t%d %s%s%s -- %s\n",x,y,plural(x),z,"x") : 0)
+	((x) ? printf("\t%ld %s%s%s -- %s\n",(long)x,y,plural(x),z,"x") : 0)
 
 /*
  * Dump SPX statistics structure.
diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c
index fb05caa34c40..dea574c18453 100644
--- a/usr.bin/netstat/main.c
+++ b/usr.bin/netstat/main.c
@@ -133,7 +133,7 @@ struct nlist nl[] = {
 	{ "_spx_istat"},
 #define N_IPXERR	34
 	{ "_ipx_errstat"},
-	"",
+	{ "" },
 };
 
 struct protox {
@@ -226,9 +226,8 @@ main(argc, argv)
 	int ch;
 	char *nlistf = NULL, *memf = NULL;
 	char buf[_POSIX2_LINE_MAX];
-	char buf2[_POSIX2_LINE_MAX];
 
-	if (cp = rindex(argv[0], '/'))
+	if ((cp = rindex(argv[0], '/')))
 		prog = cp + 1;
 	else
 		prog = argv[0];
@@ -419,7 +418,7 @@ main(argc, argv)
 		setprotoent(1);
 		setservent(1);
 		/* ugh, this is O(MN) ... why do we do this? */
-		while (p = getprotoent()) {
+		while ((p = getprotoent())) {
 			for (tp = protox; tp->pr_name; tp++)
 				if (strcmp(tp->pr_name, p->p_name) == 0)
 					break;
@@ -533,11 +532,11 @@ name2protox(name)
 	 * Try to find the name in the list of "well-known" names. If that
 	 * fails, check if name is an alias for an Internet protocol.
 	 */
-	if (tp = knownname(name))
+	if ((tp = knownname(name)))
 		return (tp);
 
 	setprotoent(1);			/* make protocol lookup cheaper */
-	while (p = getprotoent()) {
+	while ((p = getprotoent())) {
 		/* assert: name not same as p->name */
 		for (alias = p->p_aliases; *alias; alias++)
 			if (strcmp(name, *alias) == 0) {
diff --git a/usr.bin/netstat/mbuf.c b/usr.bin/netstat/mbuf.c
index 0dfc9436bb3f..54d48b67782e 100644
--- a/usr.bin/netstat/mbuf.c
+++ b/usr.bin/netstat/mbuf.c
@@ -109,13 +109,13 @@ mbpr(mbaddr)
 			printf("\t%u mbufs allocated to <mbuf type %d>\n",
 			    mbstat.m_mtypes[i], i);
 		}
-	printf("%u/%u mbuf clusters in use\n",
+	printf("%lu/%lu mbuf clusters in use\n",
 		mbstat.m_clusters - mbstat.m_clfree, mbstat.m_clusters);
 	totmem = totmbufs * MSIZE + mbstat.m_clusters * MCLBYTES;
 	totfree = mbstat.m_clfree * MCLBYTES;
 	printf("%u Kbytes allocated to network (%d%% in use)\n",
 		totmem / 1024, (totmem - totfree) * 100 / totmem);
-	printf("%u requests for memory denied\n", mbstat.m_drops);
-	printf("%u requests for memory delayed\n", mbstat.m_wait);
-	printf("%u calls to protocol drain routines\n", mbstat.m_drain);
+	printf("%lu requests for memory denied\n", mbstat.m_drops);
+	printf("%lu requests for memory delayed\n", mbstat.m_wait);
+	printf("%lu calls to protocol drain routines\n", mbstat.m_drain);
 }
diff --git a/usr.bin/netstat/mroute.c b/usr.bin/netstat/mroute.c
index 92514e9a3df9..45c47b53f9eb 100644
--- a/usr.bin/netstat/mroute.c
+++ b/usr.bin/netstat/mroute.c
@@ -73,11 +73,10 @@ mroutepr(mrpaddr, mfcaddr, vifaddr)
 	struct mfc smfc;
 	register struct vif *v;
 	register vifi_t vifi;
-	register struct in_addr *grp;
-	register int i, n;
+	register int i;
 	register int banner_printed;
 	register int saved_nflag;
-	vifi_t maxvif;
+	vifi_t maxvif = 0;
 
 	if (mrpaddr == 0) {
 		printf("ip_mrtproto: symbol not in namelist\n");
@@ -207,30 +206,30 @@ mrt_stats(mrpaddr, mstaddr)
 
 	kread(mstaddr, (char *)&mrtstat, sizeof(mrtstat));
 	printf("multicast forwarding:\n");
-	printf(" %10u multicast forwarding cache lookup%s\n",
+	printf(" %10lu multicast forwarding cache lookup%s\n",
 	  mrtstat.mrts_mfc_lookups, plural(mrtstat.mrts_mfc_lookups));
-	printf(" %10u multicast forwarding cache miss%s\n",
+	printf(" %10lu multicast forwarding cache miss%s\n",
 	  mrtstat.mrts_mfc_misses, plurales(mrtstat.mrts_mfc_misses));
-	printf(" %10u upcall%s to mrouted\n",
+	printf(" %10lu upcall%s to mrouted\n",
 	  mrtstat.mrts_upcalls, plural(mrtstat.mrts_upcalls));
-	printf(" %10u upcall queue overflow%s\n",
+	printf(" %10lu upcall queue overflow%s\n",
 	  mrtstat.mrts_upq_ovflw, plural(mrtstat.mrts_upq_ovflw));
-	printf(" %10u upcall%s dropped due to full socket buffer\n",
+	printf(" %10lu upcall%s dropped due to full socket buffer\n",
 	  mrtstat.mrts_upq_sockfull, plural(mrtstat.mrts_upq_sockfull));
-	printf(" %10u cache cleanup%s\n",
+	printf(" %10lu cache cleanup%s\n",
 	  mrtstat.mrts_cache_cleanups, plural(mrtstat.mrts_cache_cleanups));
-	printf(" %10u datagram%s with no route for origin\n",
+	printf(" %10lu datagram%s with no route for origin\n",
 	  mrtstat.mrts_no_route, plural(mrtstat.mrts_no_route));
-	printf(" %10u datagram%s arrived with bad tunneling\n",
+	printf(" %10lu datagram%s arrived with bad tunneling\n",
 	  mrtstat.mrts_bad_tunnel, plural(mrtstat.mrts_bad_tunnel));
-	printf(" %10u datagram%s could not be tunneled\n",
+	printf(" %10lu datagram%s could not be tunneled\n",
 	  mrtstat.mrts_cant_tunnel, plural(mrtstat.mrts_cant_tunnel));
-	printf(" %10u datagram%s arrived on wrong interface\n",
+	printf(" %10lu datagram%s arrived on wrong interface\n",
 	  mrtstat.mrts_wrong_if, plural(mrtstat.mrts_wrong_if));
-	printf(" %10u datagram%s selectively dropped\n",
+	printf(" %10lu datagram%s selectively dropped\n",
 	  mrtstat.mrts_drop_sel, plural(mrtstat.mrts_drop_sel));
-	printf(" %10u datagram%s dropped due to queue overflow\n",
+	printf(" %10lu datagram%s dropped due to queue overflow\n",
 	  mrtstat.mrts_q_overflow, plural(mrtstat.mrts_q_overflow));
-	printf(" %10u datagram%s dropped for being too large\n",
+	printf(" %10lu datagram%s dropped for being too large\n",
 	  mrtstat.mrts_pkt2large, plural(mrtstat.mrts_pkt2large));
 }
diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c
index 7f237178b82e..856e55309078 100644
--- a/usr.bin/netstat/route.c
+++ b/usr.bin/netstat/route.c
@@ -36,7 +36,7 @@
 static char sccsid[] = "From: @(#)route.c	8.6 (Berkeley) 4/28/95";
 #endif
 static const char rcsid[] =
-	"$Id: route.c,v 1.11 1996/01/15 02:18:35 peter Exp $";
+	"$Id: route.c,v 1.12 1996/02/16 15:42:14 wollman Exp $";
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -235,7 +235,7 @@ again:
 	kget(rn, rnode);
 	if (rnode.rn_b < 0) {
 		if (Aflag)
-			printf("%-8.8x ", rn);
+			printf("%-8.8x ", (int)rn);
 		if (rnode.rn_flags & RNF_ROOT) {
 			if (Aflag)
 				printf("(root node)%s",
@@ -250,11 +250,11 @@ again:
 				   NULL, 0, 44);
 			putchar('\n');
 		}
-		if (rn = rnode.rn_dupedkey)
+		if ((rn = rnode.rn_dupedkey))
 			goto again;
 	} else {
 		if (Aflag && do_rtent) {
-			printf("%-8.8x ", rn);
+			printf("%-8.8x ", (int)rn);
 			p_rtnode();
 		}
 		rn = rnode.rn_r;
@@ -279,13 +279,13 @@ p_rtnode()
 			return;
 	} else {
 		sprintf(nbuf, "(%d)", rnode.rn_b);
-		printf("%6.6s %8.8x : %8.8x", nbuf, rnode.rn_l, rnode.rn_r);
+		printf("%6.6s %8.8x : %8.8x", nbuf, (int)rnode.rn_l, (int)rnode.rn_r);
 	}
 	while (rm) {
 		kget(rm, rmask);
 		sprintf(nbuf, " %d refs, ", rmask.rm_refs);
 		printf(" mk = %8.8x {(%d),%s",
-			rm, -1 - rmask.rm_b, rmask.rm_refs ? nbuf : " ");
+			(int)rm, -1 - rmask.rm_b, rmask.rm_refs ? nbuf : " ");
 		if (rmask.rm_flags & RNF_NORMAL) {
 			struct radix_node rnode_aux;
 			printf(" <normal>, ");
@@ -296,7 +296,7 @@ p_rtnode()
 		    p_sockaddr(kgetsa((struct sockaddr *)rmask.rm_mask),
 				NULL, 0, -1);
 		putchar('}');
-		if (rm = rmask.rm_mklist)
+		if ((rm = rmask.rm_mklist))
 			printf(" ->");
 	}
 	putchar('\n');
@@ -513,7 +513,7 @@ p_rtentry(rt)
 	p_sockaddr(&addr, &mask, rt->rt_flags, WID_DST);
 	p_sockaddr(kgetsa(rt->rt_gateway), NULL, RTF_HOST, WID_GW);
 	p_flags(rt->rt_flags, "%-6.6s ");
-	printf("%6d %8d ", rt->rt_refcnt, rt->rt_use);
+	printf("%6d %8ld ", rt->rt_refcnt, rt->rt_use);
 	if (rt->rt_ifp) {
 		if (rt->rt_ifp != lastif) {
 			kget(rt->rt_ifp, ifnet);
@@ -528,7 +528,7 @@ p_rtentry(rt)
 		        if ((expire_time
 			       =rt->rt_rmx.rmx_expire - time((time_t *)0)) > 0)
 			    printf(" %8.8s %6d%s", prettyname,
-				   expire_time,
+				   (int)expire_time,
 				   rt->rt_nodes[0].rn_dupedkey ? " =>" : "");
 		} else {
 			printf(" %8.8s%s", prettyname,
@@ -561,7 +561,7 @@ routename(in)
 	else {
 #define C(x)	((x) & 0xff)
 		in = ntohl(in);
-		sprintf(line, "%u.%u.%u.%u",
+		sprintf(line, "%lu.%lu.%lu.%lu",
 		    C(in >> 24), C(in >> 16), C(in >> 8), C(in));
 	}
 	return (line);
@@ -666,13 +666,13 @@ netname(in, mask)
 	if (cp)
 		strncpy(line, cp, sizeof(line) - 1);
 	else if ((i & 0xffffff) == 0)
-		sprintf(line, "%u", C(i >> 24));
+		sprintf(line, "%lu", C(i >> 24));
 	else if ((i & 0xffff) == 0)
-		sprintf(line, "%u.%u", C(i >> 24) , C(i >> 16));
+		sprintf(line, "%lu.%lu", C(i >> 24) , C(i >> 16));
 	else if ((i & 0xff) == 0)
-		sprintf(line, "%u.%u.%u", C(i >> 24), C(i >> 16), C(i >> 8));
+		sprintf(line, "%lu.%lu.%lu", C(i >> 24), C(i >> 16), C(i >> 8));
 	else
-		sprintf(line, "%u.%u.%u.%u", C(i >> 24),
+		sprintf(line, "%lu.%lu.%lu.%lu", C(i >> 24),
 			C(i >> 16), C(i >> 8), C(i));
 	domask(line+strlen(line), i, omask);
 	return (line);
diff --git a/usr.bin/netstat/unix.c b/usr.bin/netstat/unix.c
index 4095e1bed901..0309d1c30a47 100644
--- a/usr.bin/netstat/unix.c
+++ b/usr.bin/netstat/unix.c
@@ -103,7 +103,7 @@ unixdomainpr(so, soaddr)
 {
 	struct unpcb unpcb, *unp = &unpcb;
 	struct mbuf mbuf, *m;
-	struct sockaddr_un *sa;
+	struct sockaddr_un *sa = NULL;
 	static int first = 1;
 
 	if (kread((u_long)so->so_pcb, (char *)unp, sizeof (*unp)))
@@ -123,10 +123,10 @@ unixdomainpr(so, soaddr)
 		    "Inode", "Conn", "Refs", "Nextref");
 		first = 0;
 	}
-	printf("%8x %-6.6s %6d %6d %8x %8x %8x %8x",
-	    soaddr, socktype[so->so_type], so->so_rcv.sb_cc, so->so_snd.sb_cc,
-	    unp->unp_vnode, unp->unp_conn,
-	    unp->unp_refs, unp->unp_nextref);
+	printf("%8x %-6.6s %6ld %6ld %8x %8x %8x %8x",
+	    (int)soaddr, socktype[so->so_type], so->so_rcv.sb_cc, so->so_snd.sb_cc,
+	    (int)unp->unp_vnode, (int)unp->unp_conn,
+	    (int)unp->unp_refs, (int)unp->unp_nextref);
 	if (m)
 		printf(" %.*s",
 		    m->m_len - (int)(sizeof(*sa) - sizeof(sa->sun_path)),