From 1d0c38de11a9e419918921345b87c673b09e2115 Mon Sep 17 00:00:00 2001 From: uqs Date: Sat, 27 Feb 2010 10:19:39 +0000 Subject: rtsol(8)/rtsold(8): make WARNS=3 clean It is actually WARNS=6 clean for non-strict alignment archs. Approved by: ed (co-mentor) --- usr.sbin/rtsold/Makefile | 4 +--- usr.sbin/rtsold/dump.c | 8 ++++---- usr.sbin/rtsold/if.c | 1 - usr.sbin/rtsold/rtsock.c | 6 +++--- usr.sbin/rtsold/rtsol.c | 17 ++++++++++------- usr.sbin/rtsold/rtsold.c | 11 ++++++----- usr.sbin/rtsold/rtsold.h | 2 +- 7 files changed, 25 insertions(+), 24 deletions(-) (limited to 'usr.sbin/rtsold') diff --git a/usr.sbin/rtsold/Makefile b/usr.sbin/rtsold/Makefile index ad4059a..efc322c 100644 --- a/usr.sbin/rtsold/Makefile +++ b/usr.sbin/rtsold/Makefile @@ -19,10 +19,8 @@ MAN= rtsold.8 MLINKS= rtsold.8 rtsol.8 SRCS= rtsold.c rtsol.c if.c probe.c dump.c rtsock.c +WARNS?= 3 CFLAGS+= -DHAVE_ARC4RANDOM -DHAVE_POLL_H - -WARNS?= 1 - DPADD= ${LIBKVM} LDADD= -lkvm diff --git a/usr.sbin/rtsold/dump.c b/usr.sbin/rtsold/dump.c index 62056ae..2756b87 100644 --- a/usr.sbin/rtsold/dump.c +++ b/usr.sbin/rtsold/dump.c @@ -52,8 +52,8 @@ static FILE *fp; extern struct ifinfo *iflist; static void dump_interface_status(void); -static char *sec2str(time_t); -char *ifstatstr[] = {"IDLE", "DELAY", "PROBE", "DOWN", "TENTATIVE"}; +static const char *sec2str(time_t); +static const char * const ifstatstr[] = {"IDLE", "DELAY", "PROBE", "DOWN", "TENTATIVE"}; static void dump_interface_status(void) @@ -97,7 +97,7 @@ dump_interface_status(void) } void -rtsold_dump_file(char *dumpfile) +rtsold_dump_file(const char *dumpfile) { if ((fp = fopen(dumpfile, "w")) == NULL) { warnmsg(LOG_WARNING, __func__, "open a dump file(%s): %s", @@ -108,7 +108,7 @@ rtsold_dump_file(char *dumpfile) fclose(fp); } -static char * +static const char * sec2str(time_t total) { static char result[256]; diff --git a/usr.sbin/rtsold/if.c b/usr.sbin/rtsold/if.c index e8786ff..c555d2a 100644 --- a/usr.sbin/rtsold/if.c +++ b/usr.sbin/rtsold/if.c @@ -82,7 +82,6 @@ interface_up(char *name) struct in6_ndireq nd; int llflag; int s; - int error; memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); diff --git a/usr.sbin/rtsold/rtsock.c b/usr.sbin/rtsold/rtsock.c index 0de6e85..726c1e6 100644 --- a/usr.sbin/rtsold/rtsock.c +++ b/usr.sbin/rtsold/rtsock.c @@ -94,9 +94,9 @@ rtsock_input(int s) char *lim, *next; struct rt_msghdr *rtm; int idx; - size_t len; + ssize_t len; int ret = 0; - const size_t lenlim = + const ssize_t lenlim = offsetof(struct rt_msghdr, rtm_msglen) + sizeof(rtm->rtm_msglen); n = read(s, msg, sizeof(msg)); @@ -135,7 +135,7 @@ rtsock_input(int s) #ifdef RTM_IFANNOUNCE /*NetBSD 1.5 or later*/ static int -rtsock_input_ifannounce(int s, struct rt_msghdr *rtm, char *lim) +rtsock_input_ifannounce(int s __unused, struct rt_msghdr *rtm, char *lim) { struct if_announcemsghdr *ifan; struct ifinfo *ifinfo; diff --git a/usr.sbin/rtsold/rtsol.c b/usr.sbin/rtsold/rtsol.c index 3420f2f..be2a9b8 100644 --- a/usr.sbin/rtsold/rtsol.c +++ b/usr.sbin/rtsold/rtsol.c @@ -72,8 +72,10 @@ static int rcvcmsglen; int rssock; -static struct sockaddr_in6 sin6_allrouters = -{sizeof(sin6_allrouters), AF_INET6}; +static struct sockaddr_in6 sin6_allrouters = { + .sin6_len = sizeof(sin6_allrouters), + .sin6_family = AF_INET6, +}; static void call_script(char *, char *); static int safefile(const char *); @@ -183,7 +185,7 @@ sendpacket(struct ifinfo *ifinfo) struct in6_pktinfo *pi; struct cmsghdr *cm; int hoplimit = 255; - int i; + ssize_t i; struct sockaddr_in6 dst; dst = sin6_allrouters; @@ -213,7 +215,7 @@ sendpacket(struct ifinfo *ifinfo) "send RS on %s, whose state is %d", ifinfo->ifname, ifinfo->state); i = sendmsg(rssock, &sndmhdr, 0); - if (i < 0 || i != ifinfo->rs_datalen) { + if (i < 0 || (size_t)i != ifinfo->rs_datalen) { /* * ENETDOWN is not so serious, especially when using several * network cards on a mobile node. We ignore it. @@ -231,7 +233,8 @@ void rtsol_input(int s) { u_char ntopbuf[INET6_ADDRSTRLEN], ifnamebuf[IFNAMSIZ]; - int ifindex = 0, i, *hlimp = NULL; + int ifindex = 0, *hlimp = NULL; + ssize_t i; struct in6_pktinfo *pi = NULL; struct ifinfo *ifi = NULL; struct icmp6_hdr *icp; @@ -272,9 +275,9 @@ rtsol_input(int s) return; } - if (i < sizeof(struct nd_router_advert)) { + if ((size_t)i < sizeof(struct nd_router_advert)) { warnmsg(LOG_INFO, __func__, - "packet size(%d) is too short", i); + "packet size(%zd) is too short", i); return; } diff --git a/usr.sbin/rtsold/rtsold.c b/usr.sbin/rtsold/rtsold.c index 12c0836..0db050c 100644 --- a/usr.sbin/rtsold/rtsold.c +++ b/usr.sbin/rtsold/rtsold.c @@ -91,10 +91,10 @@ int main(int, char **); static int mobile_node = 0; #ifndef SMALL static int do_dump; -static char *dumpfilename = "/var/run/rtsold.dump"; /* XXX: should be configurable */ +static const char *dumpfilename = "/var/run/rtsold.dump"; /* XXX: should be configurable */ #endif #if 1 -static char *pidfilename = "/var/run/rtsold.pid"; /* should be configurable */ +static const char *pidfilename = "/var/run/rtsold.pid"; /* should be configurable */ #endif #if 0 @@ -113,7 +113,8 @@ main(int argc, char **argv) { int s, ch, once = 0; struct timeval *timeout; - char *argv0, *opts; + char *argv0; + const char *opts; #ifdef HAVE_POLL_H struct pollfd set[2]; #else @@ -734,7 +735,7 @@ rtsol_timer_update(struct ifinfo *ifinfo) #ifndef SMALL static void -rtsold_set_dump_file(int sig) +rtsold_set_dump_file(int sig __unused) { do_dump = 1; } @@ -790,7 +791,7 @@ autoifprobe(void) static char **argv = NULL; static int n = 0; char **a; - int s, i, found; + int s = 0, i, found; struct ifaddrs *ifap, *ifa, *target; struct in6_ndireq nd; diff --git a/usr.sbin/rtsold/rtsold.h b/usr.sbin/rtsold/rtsold.h index 8a3cfa6..8aef490 100644 --- a/usr.sbin/rtsold/rtsold.h +++ b/usr.sbin/rtsold/rtsold.h @@ -97,7 +97,7 @@ extern int probe_init(void); extern void defrouter_probe(struct ifinfo *); /* dump.c */ -extern void rtsold_dump_file(char *); +extern void rtsold_dump_file(const char *); /* rtsock.c */ extern int rtsock_open(void); -- cgit v1.1