svn commit: r190718 - head/sbin/routed
Poul-Henning Kamp
phk at FreeBSD.org
Sun Apr 5 10:33:09 PDT 2009
Author: phk
Date: Sun Apr 5 17:33:07 2009
New Revision: 190718
URL: http://svn.freebsd.org/changeset/base/190718
Log:
Add some consts, remove some unused stuff and other attempts to calm
FlexeLint down.
Modified:
head/sbin/routed/defs.h
head/sbin/routed/input.c
head/sbin/routed/output.c
head/sbin/routed/parms.c
head/sbin/routed/radix.c
head/sbin/routed/radix.h
head/sbin/routed/rdisc.c
head/sbin/routed/table.c
head/sbin/routed/trace.c
Modified: head/sbin/routed/defs.h
==============================================================================
--- head/sbin/routed/defs.h Sun Apr 5 17:12:13 2009 (r190717)
+++ head/sbin/routed/defs.h Sun Apr 5 17:33:07 2009 (r190718)
@@ -60,6 +60,7 @@
* years have been simplified and integrated.
*/
+#include <assert.h>
#include <stdio.h>
#include <netdb.h>
#include <stdlib.h>
Modified: head/sbin/routed/input.c
==============================================================================
--- head/sbin/routed/input.c Sun Apr 5 17:12:13 2009 (r190717)
+++ head/sbin/routed/input.c Sun Apr 5 17:33:07 2009 (r190718)
@@ -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));
Modified: head/sbin/routed/output.c
==============================================================================
--- head/sbin/routed/output.c Sun Apr 5 17:12:13 2009 (r190717)
+++ head/sbin/routed/output.c Sun Apr 5 17:33:07 2009 (r190718)
@@ -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;
Modified: head/sbin/routed/parms.c
==============================================================================
--- head/sbin/routed/parms.c Sun Apr 5 17:12:13 2009 (r190717)
+++ head/sbin/routed/parms.c Sun Apr 5 17:33:07 2009 (r190718)
@@ -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 (;;) {
Modified: head/sbin/routed/radix.c
==============================================================================
--- head/sbin/routed/radix.c Sun Apr 5 17:12:13 2009 (r190717)
+++ head/sbin/routed/radix.c Sun Apr 5 17:33:07 2009 (r190718)
@@ -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))
Modified: head/sbin/routed/radix.h
==============================================================================
--- head/sbin/routed/radix.h Sun Apr 5 17:12:13 2009 (r190717)
+++ head/sbin/routed/radix.h Sun Apr 5 17:33:07 2009 (r190718)
@@ -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);
Modified: head/sbin/routed/rdisc.c
==============================================================================
--- head/sbin/routed/rdisc.c Sun Apr 5 17:12:13 2009 (r190717)
+++ head/sbin/routed/rdisc.c Sun Apr 5 17:33:07 2009 (r190718)
@@ -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;
Modified: head/sbin/routed/table.c
==============================================================================
--- head/sbin/routed/table.c Sun Apr 5 17:12:13 2009 (r190717)
+++ head/sbin/routed/table.c Sun Apr 5 17:33:07 2009 (r190718)
@@ -607,8 +607,6 @@ ag_check(naddr dst,
CHECK_AG();
}
-
-#define NAME0_LEN 14
static const char *
rtm_type_name(u_char type)
{
Modified: head/sbin/routed/trace.c
==============================================================================
--- head/sbin/routed/trace.c Sun Apr 5 17:12:13 2009 (r190717)
+++ head/sbin/routed/trace.c Sun Apr 5 17:33:07 2009 (r190718)
@@ -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" },
More information about the svn-src-all
mailing list