diff options
author | yar <yar@FreeBSD.org> | 2006-07-28 16:16:40 +0000 |
---|---|---|
committer | yar <yar@FreeBSD.org> | 2006-07-28 16:16:40 +0000 |
commit | 59fab84bab308e4a3eb124a99ce391729ed77614 (patch) | |
tree | 8935d305c75dcfea6a10f10d3ac08de7e612c074 /usr.bin/netstat | |
parent | e1db503689ae54aa3513f73b6e1aa4212ded2641 (diff) | |
download | FreeBSD-src-59fab84bab308e4a3eb124a99ce391729ed77614.zip FreeBSD-src-59fab84bab308e4a3eb124a99ce391729ed77614.tar.gz |
- Achieve WARNS=3 by using sparse initializers or avoiding initializers at all.
- Fix a nlist initialization: it should be terminated by a NULL entry.
- Constify.
- Catch an unused parameter.
Tested on: i386 amd64 ia64
Diffstat (limited to 'usr.bin/netstat')
-rw-r--r-- | usr.bin/netstat/Makefile | 2 | ||||
-rw-r--r-- | usr.bin/netstat/inet.c | 2 | ||||
-rw-r--r-- | usr.bin/netstat/ipx.c | 2 | ||||
-rw-r--r-- | usr.bin/netstat/main.c | 88 | ||||
-rw-r--r-- | usr.bin/netstat/netgraph.c | 3 | ||||
-rw-r--r-- | usr.bin/netstat/route.c | 4 |
6 files changed, 52 insertions, 49 deletions
diff --git a/usr.bin/netstat/Makefile b/usr.bin/netstat/Makefile index 6168b63..04a2f58 100644 --- a/usr.bin/netstat/Makefile +++ b/usr.bin/netstat/Makefile @@ -7,7 +7,7 @@ PROG= netstat SRCS= if.c inet.c main.c mbuf.c mcast.c mroute.c route.c \ unix.c atalk.c netgraph.c mroute6.c ipsec.c bpf.c pfkey.c -WARNS?= 2 +WARNS?= 3 CFLAGS+=-DIPSEC CFLAGS+=-DFAST_IPSEC diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c index d168386..6475a39 100644 --- a/usr.bin/netstat/inet.c +++ b/usr.bin/netstat/inet.c @@ -532,7 +532,7 @@ udp_stats(u_long off __unused, const char *name, int af1 __unused) * Dump CARP statistics structure. */ void -carp_stats(u_long off, const char *name, int af1 __unused) +carp_stats(u_long off __unused, const char *name, int af1 __unused) { struct carpstats carpstat, zerostat; size_t len = sizeof(struct carpstats); diff --git a/usr.bin/netstat/ipx.c b/usr.bin/netstat/ipx.c index 8b71dbd..b8f50e3 100644 --- a/usr.bin/netstat/ipx.c +++ b/usr.bin/netstat/ipx.c @@ -339,7 +339,7 @@ ipx_erputil(int z, int c) } #endif /* IPXERRORMSGS */ -static struct sockaddr_ipx ssipx = {AF_IPX}; +static struct sockaddr_ipx ssipx = { .sipx_family = AF_IPX }; static char *ipx_prpr(struct ipx_addr *x) diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c index a2cd7e2..d72afc3 100644 --- a/usr.bin/netstat/main.c +++ b/usr.bin/netstat/main.c @@ -72,84 +72,84 @@ __FBSDID("$FreeBSD$"); static struct nlist nl[] = { #define N_IFNET 0 - { "_ifnet" }, + { .n_name = "_ifnet" }, #define N_RTSTAT 1 - { "_rtstat" }, + { .n_name = "_rtstat" }, #define N_RTREE 2 - { "_rt_tables"}, + { .n_name = "_rt_tables"}, #define N_MRTSTAT 3 - { "_mrtstat" }, + { .n_name = "_mrtstat" }, #define N_MFCTABLE 4 - { "_mfctable" }, + { .n_name = "_mfctable" }, #define N_VIFTABLE 5 - { "_viftable" }, + { .n_name = "_viftable" }, #define N_IPX 6 - { "_ipxpcb_list"}, + { .n_name = "_ipxpcb_list"}, #define N_IPXSTAT 7 - { "_ipxstat"}, + { .n_name = "_ipxstat"}, #define N_SPXSTAT 8 - { "_spx_istat"}, + { .n_name = "_spx_istat"}, #define N_DDPSTAT 9 - { "_ddpstat"}, + { .n_name = "_ddpstat"}, #define N_DDPCB 10 - { "_ddpcb"}, + { .n_name = "_ddpcb"}, #define N_NGSOCKS 11 - { "_ngsocklist"}, + { .n_name = "_ngsocklist"}, #define N_IP6STAT 12 - { "_ip6stat" }, + { .n_name = "_ip6stat" }, #define N_ICMP6STAT 13 - { "_icmp6stat" }, + { .n_name = "_icmp6stat" }, #define N_IPSECSTAT 14 - { "_ipsecstat" }, + { .n_name = "_ipsecstat" }, #define N_IPSEC6STAT 15 - { "_ipsec6stat" }, + { .n_name = "_ipsec6stat" }, #define N_PIM6STAT 16 - { "_pim6stat" }, + { .n_name = "_pim6stat" }, #define N_MRT6STAT 17 - { "_mrt6stat" }, + { .n_name = "_mrt6stat" }, #define N_MF6CTABLE 18 - { "_mf6ctable" }, + { .n_name = "_mf6ctable" }, #define N_MIF6TABLE 19 - { "_mif6table" }, + { .n_name = "_mif6table" }, #define N_PFKEYSTAT 20 - { "_pfkeystat" }, + { .n_name = "_pfkeystat" }, #define N_MBSTAT 21 - { "_mbstat" }, + { .n_name = "_mbstat" }, #define N_MBTYPES 22 - { "_mbtypes" }, + { .n_name = "_mbtypes" }, #define N_NMBCLUSTERS 23 - { "_nmbclusters" }, + { .n_name = "_nmbclusters" }, #define N_NMBUFS 24 - { "_nmbufs" }, + { .n_name = "_nmbufs" }, #define N_MBHI 25 - { "_mbuf_hiwm" }, + { .n_name = "_mbuf_hiwm" }, #define N_CLHI 26 - { "_clust_hiwm" }, + { .n_name = "_clust_hiwm" }, #define N_NCPUS 27 - { "_smp_cpus" }, + { .n_name = "_smp_cpus" }, #define N_PAGESZ 28 - { "_pagesize" }, + { .n_name = "_pagesize" }, #define N_MBPSTAT 29 - { "_mb_statpcpu" }, + { .n_name = "_mb_statpcpu" }, #define N_RTTRASH 30 - { "_rttrash" }, + { .n_name = "_rttrash" }, #define N_MBLO 31 - { "_mbuf_lowm" }, + { .n_name = "_mbuf_lowm" }, #define N_CLLO 32 - { "_clust_lowm" }, + { .n_name = "_clust_lowm" }, #define N_CARPSTAT 33 - { "_carpstats" }, + { .n_name = "_carpstats" }, #define N_PFSYNCSTAT 34 - { "_pfsyncstats" }, + { .n_name = "_pfsyncstats" }, #define N_FAST_IPSECSTAT 35 - { "_newipsecstat" }, + { .n_name = "_newipsecstat" }, #define N_AHSTAT 36 - { "_ahstat" }, + { .n_name = "_ahstat" }, #define N_ESPSTAT 37 - { "_espstat" }, + { .n_name = "_espstat" }, #define N_IPCOMPSTAT 38 - { "_ipcompstat" }, - { "" }, + { .n_name = "_ipcompstat" }, + { .n_name = NULL }, }; struct protox { @@ -276,8 +276,8 @@ struct protox *protoprotox[] = { static void printproto(struct protox *, const char *); static void usage(void); -static struct protox *name2protox(char *); -static struct protox *knownname(char *); +static struct protox *name2protox(const char *); +static struct protox *knownname(const char *); static kvm_t *kvmd; static char *nlistf = NULL, *memf = NULL; @@ -678,7 +678,7 @@ pluralies(uintmax_t n) * Find the protox for the given "well-known" name. */ static struct protox * -knownname(char *name) +knownname(const char *name) { struct protox **tpp, *tp; @@ -693,7 +693,7 @@ knownname(char *name) * Find the protox corresponding to name. */ static struct protox * -name2protox(char *name) +name2protox(const char *name) { struct protox *tp; char **alias; /* alias from p->aliases */ diff --git a/usr.bin/netstat/netgraph.c b/usr.bin/netstat/netgraph.c index 267df9d..77db23f 100644 --- a/usr.bin/netstat/netgraph.c +++ b/usr.bin/netstat/netgraph.c @@ -75,7 +75,8 @@ netgraphprotopr(u_long off, const char *name, int af1 __unused) const char *const modname = "ng_socket.ko"; /* XXX We should get "mpath" from "sysctl kern.module_path" */ const char *mpath[] = { "/", "/boot/", "/modules/", NULL }; - struct nlist sym[] = { { "_ngsocklist" }, { NULL } }; + struct nlist sym[] = { { .n_name = "_ngsocklist" }, + { .n_name = NULL } }; const char **pre; struct kld_file_stat ks; int fileid; diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c index 415a7b6..7ffbee3 100644 --- a/usr.bin/netstat/route.c +++ b/usr.bin/netstat/route.c @@ -976,8 +976,10 @@ routename6(struct sockaddr_in6 *sa6) static char line[MAXHOSTNAMELEN]; int flag = 0; /* use local variable for safety */ - struct sockaddr_in6 sa6_local = {AF_INET6, sizeof(sa6_local),}; + struct sockaddr_in6 sa6_local; + sa6_local.sin6_family = AF_INET6; + sa6_local.sin6_len = sizeof(sa6_local); sa6_local.sin6_addr = sa6->sin6_addr; sa6_local.sin6_scope_id = sa6->sin6_scope_id; |