diff options
author | phk <phk@FreeBSD.org> | 2009-04-05 17:33:07 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2009-04-05 17:33:07 +0000 |
commit | 3ec0927e8b504ffce75ad2cc7fb80b4437f66167 (patch) | |
tree | 87151c0a577cc47d54616fd1103486ad28044478 /sbin/routed | |
parent | ad4b733279aa875e4206faa43e9fc10f80660489 (diff) | |
download | FreeBSD-src-3ec0927e8b504ffce75ad2cc7fb80b4437f66167.zip FreeBSD-src-3ec0927e8b504ffce75ad2cc7fb80b4437f66167.tar.gz |
Add some consts, remove some unused stuff and other attempts to calm
FlexeLint down.
Diffstat (limited to 'sbin/routed')
-rw-r--r-- | sbin/routed/defs.h | 1 | ||||
-rw-r--r-- | sbin/routed/input.c | 2 | ||||
-rw-r--r-- | sbin/routed/output.c | 2 | ||||
-rw-r--r-- | sbin/routed/parms.c | 20 | ||||
-rw-r--r-- | sbin/routed/radix.c | 3 | ||||
-rw-r--r-- | sbin/routed/radix.h | 1 | ||||
-rw-r--r-- | sbin/routed/rdisc.c | 3 | ||||
-rw-r--r-- | sbin/routed/table.c | 2 | ||||
-rw-r--r-- | sbin/routed/trace.c | 12 |
9 files changed, 15 insertions, 31 deletions
diff --git a/sbin/routed/defs.h b/sbin/routed/defs.h index 16a7b32..c42cd80 100644 --- a/sbin/routed/defs.h +++ b/sbin/routed/defs.h @@ -60,6 +60,7 @@ * years have been simplified and integrated. */ +#include <assert.h> #include <stdio.h> #include <netdb.h> #include <stdlib.h> diff --git a/sbin/routed/input.c b/sbin/routed/input.c index 51da12b..ebeee28 100644 --- a/sbin/routed/input.c +++ b/sbin/routed/input.c @@ -931,7 +931,7 @@ ck_passwd(struct interface *aifp, u_char hash[RIP_AUTH_PW_LEN]; int i, len; - + assert(aifp != NULL); if ((void *)NA >= lim || NA->a_family != RIP_AF_AUTH) { msglim(use_authp, from, "missing password from %s", naddr_ntoa(from)); diff --git a/sbin/routed/output.c b/sbin/routed/output.c index 66cbc29..53eb4a5 100644 --- a/sbin/routed/output.c +++ b/sbin/routed/output.c @@ -107,6 +107,7 @@ output(enum output_type type, int soc; int serrno; + assert(ifp != NULL); osin = *dst; if (osin.sin_port == 0) osin.sin_port = htons(RIP_PORT); @@ -672,6 +673,7 @@ supply(struct sockaddr_in *dst, struct rt_entry *rt; int def_metric; + assert(ifp != NULL); ws.state = 0; ws.gen_limit = 1024; diff --git a/sbin/routed/parms.c b/sbin/routed/parms.c index 7be52e0..078f886 100644 --- a/sbin/routed/parms.c +++ b/sbin/routed/parms.c @@ -437,9 +437,7 @@ parse_ts(time_t *tp, u_int bufsize) { struct tm tm; -#if defined(sgi) || defined(__NetBSD__) char *ptr; -#endif if (0 > parse_quote(valp, "| ,\n\r", delimp, buf,bufsize) @@ -450,25 +448,11 @@ parse_ts(time_t *tp, } strcat(buf,"\n"); memset(&tm, 0, sizeof(tm)); -#if defined(sgi) || defined(__NetBSD__) ptr = strptime(buf, "%y/%m/%d@%H:%M\n", &tm); if (ptr == NULL || *ptr != '\0') { sprintf(buf,"bad timestamp %.25s", val0); return buf; } -#else - if (5 != sscanf(buf, "%u/%u/%u@%u:%u\n", - &tm.tm_year, &tm.tm_mon, &tm.tm_mday, - &tm.tm_hour, &tm.tm_min) - || tm.tm_mon < 1 || tm.tm_mon > 12 - || tm.tm_mday < 1 || tm.tm_mday > 31) { - sprintf(buf,"bad timestamp %.25s", val0); - return buf; - } - tm.tm_mon--; - if (tm.tm_year <= 37) /* assume small years are in the */ - tm.tm_year += 100; /* 3rd millenium */ -#endif if ((*tp = mktime(&tm)) == -1) { sprintf(buf,"bad timestamp %.25s", val0); @@ -495,7 +479,7 @@ get_passwd(char *tgt, int i; u_long l; - + assert(val != NULL); if (!safe) return "ignore unsafe password"; @@ -658,6 +642,8 @@ parse_parms(char *line, if (0 > parse_quote(&line, " #,\n\r",&delim, buf,sizeof(buf))) return bad_str(tgt); + } else { + val0 = NULL; } if (delim != '\0') { for (;;) { diff --git a/sbin/routed/radix.c b/sbin/routed/radix.c index 5bca9d3..7685f78 100644 --- a/sbin/routed/radix.c +++ b/sbin/routed/radix.c @@ -54,12 +54,11 @@ int max_keylen; static struct radix_mask *rn_mkfreelist; static struct radix_node_head *mask_rnhead; static char *addmask_key; -static uint8_t normal_chars[] = +static const uint8_t normal_chars[] = { 0, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff}; static char *rn_zeros, *rn_ones; #define rn_masktop (mask_rnhead->rnh_treetop) -#undef Bcmp #define Bcmp(a, b, l) (l == 0 ? 0 \ : memcmp((caddr_t)(a), (caddr_t)(b), (size_t)l)) diff --git a/sbin/routed/radix.h b/sbin/routed/radix.h index 5c7c2d6..5cc177e 100644 --- a/sbin/routed/radix.h +++ b/sbin/routed/radix.h @@ -132,7 +132,6 @@ struct radix_node_head { }; -#define Bcmp(a, b, n) memcmp(((void *)(a)), ((void *)(b)), (n)) #define Bcopy(a, b, n) memmove(((void *)(b)), ((void *)(a)), (size_t)(n)) #define Bzero(p, n) memset((void *)(p), 0, (size_t)(n)); #define Free(p) free((void *)p); diff --git a/sbin/routed/rdisc.c b/sbin/routed/rdisc.c index 262b251..260f6e0 100644 --- a/sbin/routed/rdisc.c +++ b/sbin/routed/rdisc.c @@ -173,6 +173,8 @@ set_rdisc_mg(struct interface *ifp, struct group_req gr; struct sockaddr_in *sin; + assert(ifp != NULL); + if (rdisc_sock < 0) { /* Create the raw socket so that we can hear at least * broadcast router discovery packets. @@ -944,7 +946,6 @@ read_d(void) #endif union { struct ip ip; - u_short s[512/2]; u_char b[512]; } pkt; } buf; diff --git a/sbin/routed/table.c b/sbin/routed/table.c index a1f80ff..8054a49 100644 --- a/sbin/routed/table.c +++ b/sbin/routed/table.c @@ -607,8 +607,6 @@ ag_check(naddr dst, CHECK_AG(); } - -#define NAME0_LEN 14 static const char * rtm_type_name(u_char type) { diff --git a/sbin/routed/trace.c b/sbin/routed/trace.c index 6706648..8797e57 100644 --- a/sbin/routed/trace.c +++ b/sbin/routed/trace.c @@ -51,8 +51,6 @@ __RCSID("$Revision: 2.27 $"); #define stat stat64 #endif -#define NRECORDS 50 /* size of circular trace buffer */ - int tracelevel, new_tracelevel; FILE *ftrace; /* output trace file */ static const char *sigtrace_pat = "%s"; @@ -255,13 +253,13 @@ void tracelevel_msg(const char *pat, int dump) /* -1=no dump, 0=default, 1=force */ { - static const char *off_msgs[MAX_TRACELEVEL] = { + static const char * const off_msgs[MAX_TRACELEVEL] = { "Tracing actions stopped", "Tracing packets stopped", "Tracing packet contents stopped", "Tracing kernel changes stopped", }; - static const char *on_msgs[MAX_TRACELEVEL] = { + static const char * const on_msgs[MAX_TRACELEVEL] = { "Tracing actions started", "Tracing packets started", "Tracing packet contents started", @@ -473,13 +471,13 @@ struct bits { const char *bits_name; }; -static struct bits if_bits[] = { +static const struct bits if_bits[] = { { IFF_LOOPBACK, 0, "LOOPBACK" }, { IFF_POINTOPOINT, 0, "PT-TO-PT" }, { 0, 0, 0} }; -static struct bits is_bits[] = { +static const struct bits is_bits[] = { { IS_ALIAS, 0, "ALIAS" }, { IS_SUBNET, 0, "" }, { IS_REMOTE, (IS_NO_RDISC @@ -523,7 +521,7 @@ static struct bits is_bits[] = { { 0, 0, "%#x"} }; -static struct bits rs_bits[] = { +static const struct bits rs_bits[] = { { RS_IF, 0, "IF" }, { RS_NET_INT, RS_NET_SYN, "NET_INT" }, { RS_NET_SYN, 0, "NET_SYN" }, |