Compiler warnings fixes round 1.
diff --git a/ospfd/ChangeLog b/ospfd/ChangeLog
index f71479e..f326f72 100644
--- a/ospfd/ChangeLog
+++ b/ospfd/ChangeLog
@@ -1,3 +1,8 @@
+2004-10-08 Hasso Tepper <hasso at quagga.net>
+
+ * *.[c|h]: Fix compiler warnings: make some strings const, signed ->
+ unsigned, remove unused variables etc.
+
2004-10-07 Greg Troxel <gdt@claude.ir.bbn.com>
* ospf_apiserver.c (ospf_apiserver_unregister_opaque_type): Don't
diff --git a/ospfd/ospf_dump.c b/ospfd/ospf_dump.c
index 8b4e78b..e34f3f6 100644
--- a/ospfd/ospf_dump.c
+++ b/ospfd/ospf_dump.c
@@ -149,7 +149,7 @@
#define OSPF_AREA_STRING_MAXLEN 16
-char *
+const char *
ospf_area_name_string (struct ospf_area *area)
{
static char buf[OSPF_AREA_STRING_MAXLEN] = "";
@@ -166,7 +166,7 @@
}
#define OSPF_AREA_DESC_STRING_MAXLEN 23
-char *
+const char *
ospf_area_desc_string (struct ospf_area *area)
{
static char buf[OSPF_AREA_DESC_STRING_MAXLEN] = "";
@@ -195,7 +195,7 @@
}
#define OSPF_IF_STRING_MAXLEN 40
-char *
+const char *
ospf_if_name_string (struct ospf_interface *oi)
{
static char buf[OSPF_IF_STRING_MAXLEN] = "";
@@ -236,7 +236,7 @@
LOOKUP (ospf_ism_state_msg, state));
}
-char *
+const char *
ospf_timer_dump (struct thread *t, char *buf, size_t size)
{
struct timeval now;
@@ -326,7 +326,7 @@
void
ospf_lsa_header_dump (struct lsa_header *lsah)
{
- char *lsah_type = LOOKUP (ospf_lsa_type_msg, lsah->type);
+ const char *lsah_type = LOOKUP (ospf_lsa_type_msg, lsah->type);
zlog_info (" LSA Header");
zlog_info (" LS age %d", ntohs (lsah->ls_age));
@@ -1484,8 +1484,8 @@
int write = 0;
int i, r;
- char *type_str[] = {"hello", "dd", "ls-request", "ls-update", "ls-ack"};
- char *detail_str[] = {"", " send", " recv", "", " detail",
+ const char *type_str[] = {"hello", "dd", "ls-request", "ls-update", "ls-ack"};
+ const char *detail_str[] = {"", " send", " recv", "", " detail",
" send detail", " recv detail", " detail"};
/* debug ospf ism (status|events|timers). */
diff --git a/ospfd/ospf_dump.h b/ospfd/ospf_dump.h
index 29d06c9..5f625ca 100644
--- a/ospfd/ospf_dump.h
+++ b/ospfd/ospf_dump.h
@@ -121,16 +121,16 @@
extern unsigned long term_debug_ospf_nssa;
/* Message Strings. */
-extern char *ospf_packet_type_str[];
+extern const char *ospf_packet_type_str[];
extern char *ospf_lsa_type_str[];
/* Prototypes. */
-char *ospf_area_name_string (struct ospf_area *);
-char *ospf_area_desc_string (struct ospf_area *);
-char *ospf_if_name_string (struct ospf_interface *);
+const char *ospf_area_name_string (struct ospf_area *);
+const char *ospf_area_desc_string (struct ospf_area *);
+const char *ospf_if_name_string (struct ospf_interface *);
void ospf_nbr_state_message (struct ospf_neighbor *, char *, size_t);
char *ospf_options_dump (u_char);
-char *ospf_timer_dump (struct thread *, char *, size_t);
+const char *ospf_timer_dump (struct thread *, char *, size_t);
void ospf_ip_header_dump (struct stream *);
void ospf_packet_dump (struct stream *);
void ospf_lsa_header_dump (struct lsa_header *);
diff --git a/ospfd/ospf_ism.c b/ospfd/ospf_ism.c
index 7fa8b46..84a5dc5 100644
--- a/ospfd/ospf_ism.c
+++ b/ospfd/ospf_ism.c
@@ -553,7 +553,7 @@
},
};
-static char *ospf_ism_event_str[] =
+const static char *ospf_ism_event_str[] =
{
"NoEvent",
"InterfaceUp",
diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c
index 944af64..3ad6ddf 100644
--- a/ospfd/ospf_lsa.c
+++ b/ospfd/ospf_lsa.c
@@ -902,7 +902,7 @@
struct ospf_area *area = getdata (node);
struct ospf_lsa *lsa = area->router_lsa_self;
struct router_lsa *rl;
- char *area_str;
+ const char *area_str;
/* Keep Area ID string. */
area_str = AREA_NAME (area);
diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c
index 7e1567c..47873ba 100644
--- a/ospfd/ospf_main.c
+++ b/ospfd/ospf_main.c
@@ -97,7 +97,7 @@
struct thread_master *master;
/* Process ID saved for use by init system */
-char *pid_file = PATH_OSPFD_PID;
+const char *pid_file = PATH_OSPFD_PID;
/* Help information display. */
static void
diff --git a/ospfd/ospf_nsm.c b/ospfd/ospf_nsm.c
index 14c75df..dd5ba7b 100644
--- a/ospfd/ospf_nsm.c
+++ b/ospfd/ospf_nsm.c
@@ -640,7 +640,7 @@
},
};
-static char *ospf_nsm_event_str[] =
+const static char *ospf_nsm_event_str[] =
{
"NoEvent",
"HelloReceived",
diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c
index f1cb91d..357d697 100644
--- a/ospfd/ospf_packet.c
+++ b/ospfd/ospf_packet.c
@@ -52,7 +52,7 @@
struct in_addr);
/* Packet Type String. */
-char *ospf_packet_type_str[] =
+const char *ospf_packet_type_str[] =
{
"unknown",
"Hello",
@@ -347,7 +347,7 @@
/* Get MD5 Authentication key from auth_key list. */
if (list_isempty (OSPF_IF_PARAM (oi, auth_crypt)))
- auth_key = "";
+ auth_key = (char *) "";
else
{
ck = getdata (OSPF_IF_PARAM (oi, auth_crypt)->tail);
@@ -1991,12 +1991,11 @@
struct stream *ibuf;
unsigned int ifindex = 0;
struct iovec iov;
- struct cmsghdr *cmsg;
#if defined(CMSG_SPACE)
/* Header and data both require alignment. */
char buff [CMSG_SPACE(SOPT_SIZE_CMSG_IFINDEX_IPV4())];
#else
- char buff [sizeof (*cmsg) + SOPT_SIZE_CMSG_IFINDEX_IPV4()];
+ char buff [sizeof (struct cmsghdr) + SOPT_SIZE_CMSG_IFINDEX_IPV4()];
#endif
struct msghdr msgh;
diff --git a/ospfd/ospf_route.c b/ospfd/ospf_route.c
index 9280767..15331fd 100644
--- a/ospfd/ospf_route.c
+++ b/ospfd/ospf_route.c
@@ -640,7 +640,7 @@
zlog_info("ospf_intra_add_stub(): Stop");
}
-char *ospf_path_type_str[] =
+const char *ospf_path_type_str[] =
{
"unknown-type",
"intra-area",
diff --git a/ospfd/ospf_routemap.c b/ospfd/ospf_routemap.c
index 64822d6..52fa901 100644
--- a/ospfd/ospf_routemap.c
+++ b/ospfd/ospf_routemap.c
@@ -98,7 +98,7 @@
/* Delete rip route map rule. */
int
ospf_route_match_delete (struct vty *vty, struct route_map_index *index,
- char *command, char *arg)
+ const char *command, char *arg)
{
int ret;
@@ -123,7 +123,7 @@
int
ospf_route_match_add (struct vty *vty, struct route_map_index *index,
- char *command, char *arg)
+ const char *command, char *arg)
{
int ret;
@@ -148,7 +148,7 @@
int
ospf_route_set_add (struct vty *vty, struct route_map_index *index,
- char *command, char *arg)
+ const char *command, char *arg)
{
int ret;
@@ -174,7 +174,7 @@
/* Delete rip route map rule. */
int
ospf_route_set_delete (struct vty *vty, struct route_map_index *index,
- char *command, char *arg)
+ const char *command, char *arg)
{
int ret;
@@ -760,9 +760,11 @@
"OSPF[6] external type 2 metric\n")
{
if (strcmp (argv[0], "1") == 0)
- return ospf_route_set_add (vty, vty->index, "metric-type", "type-1");
+ return ospf_route_set_add (vty, vty->index, "metric-type",
+ (char *) "type-1");
if (strcmp (argv[0], "2") == 0)
- return ospf_route_set_add (vty, vty->index, "metric-type", "type-2");
+ return ospf_route_set_add (vty, vty->index, "metric-type",
+ (char *) "type-2");
return ospf_route_set_add (vty, vty->index, "metric-type", argv[0]);
}
diff --git a/ospfd/ospf_spf.c b/ospfd/ospf_spf.c
index 0fd39fa..c7c25f8 100644
--- a/ospfd/ospf_spf.c
+++ b/ospfd/ospf_spf.c
@@ -115,7 +115,7 @@
}
void
-ospf_vertex_dump(char *msg, struct vertex *v,
+ospf_vertex_dump(const char *msg, struct vertex *v,
int print_nexthops, int print_children)
{
if ( ! IS_DEBUG_OSPF_EVENT)
@@ -245,8 +245,7 @@
int
ospf_lsa_has_link (struct lsa_header *w, struct lsa_header *v)
{
- int i;
- int length;
+ unsigned int i, length;
struct router_lsa *rl;
struct network_lsa *nl;
@@ -494,7 +493,6 @@
if (IS_DEBUG_OSPF_EVENT)
{
char buf1[BUFSIZ];
- char buf2[BUFSIZ];
zlog_info("ospf_nexthop_calculation(): considering link "
"type %d link_id %s link_data %s",
l->m[0].type,
diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c
index 1d44250..a498003 100644
--- a/ospfd/ospf_te.c
+++ b/ospfd/ospf_te.c
@@ -1872,8 +1872,10 @@
/* Show All Interfaces. */
if (argc == 0)
- LIST_LOOP (iflist, ifp, node)
- show_mpls_te_link_sub (vty, ifp);
+ {
+ LIST_LOOP (iflist, ifp, node)
+ show_mpls_te_link_sub (vty, ifp);
+ }
/* Interface name is specified. */
else
{
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c
index ab73f7b..b74a304 100644
--- a/ospfd/ospf_vty.c
+++ b/ospfd/ospf_vty.c
@@ -49,7 +49,7 @@
#include "ospfd/ospf_dump.h"
-static char *ospf_network_type_str[] =
+const static char *ospf_network_type_str[] =
{
"Null",
"POINTOPOINT",
@@ -2098,8 +2098,8 @@
{
struct ospf *ospf = vty->index;
struct in_addr nbr_addr;
- int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
- int interval = OSPF_POLL_INTERVAL_DEFAULT;
+ unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
+ unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
@@ -2146,8 +2146,8 @@
{
struct ospf *ospf = vty->index;
struct in_addr nbr_addr;
- int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
- int interval = OSPF_POLL_INTERVAL_DEFAULT;
+ unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
+ unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
@@ -2231,7 +2231,7 @@
"Timer value in seconds\n")
{
struct ospf *ospf = vty->index;
- int interval;
+ unsigned int interval;
VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
interval = (interval / 10) * 10;
@@ -2248,7 +2248,7 @@
"Timer value in seconds\n")
{
struct ospf *ospf = vty->index;
- int interval;
+ unsigned int interval;
if (argc == 1)
{
@@ -2325,7 +2325,7 @@
return CMD_SUCCESS;
}
-char *ospf_abr_type_descr_str[] =
+const char *ospf_abr_type_descr_str[] =
{
"Unknown",
"Standard (RFC2328)",
@@ -2334,7 +2334,7 @@
"Alternative Shortcut"
};
-char *ospf_shortcut_mode_descr_str[] =
+const char *ospf_shortcut_mode_descr_str[] =
{
"Default",
"Enabled",
@@ -3132,7 +3132,7 @@
return 0;
}
-char *show_database_desc[] =
+const char *show_database_desc[] =
{
"unknown",
"Router Link States",
@@ -3153,7 +3153,7 @@
#define SHOW_OSPF_COMMON_HEADER \
"Link ID ADV Router Age Seq# CkSum"
-char *show_database_header[] =
+const char *show_database_header[] =
{
"",
"Link ID ADV Router Age Seq# CkSum Link count",
@@ -3171,7 +3171,7 @@
#endif /* HAVE_OPAQUE_LSA */
};
-char *show_lsa_flags[] =
+const char *show_lsa_flags[] =
{
"Self-originated",
"Checked",
@@ -3222,7 +3222,7 @@
vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
}
-char *link_type_desc[] =
+const char *link_type_desc[] =
{
"(null)",
"another Router (point-to-point)",
@@ -3231,7 +3231,7 @@
"a Virtual Link",
};
-char *link_id_desc[] =
+const char *link_id_desc[] =
{
"(null)",
"Neighboring Router ID",
@@ -3240,7 +3240,7 @@
"Neighboring Router ID",
};
-char *link_data_desc[] =
+const char *link_data_desc[] =
{
"(null)",
"Router Interface address",
@@ -6641,7 +6641,7 @@
}
-char *ospf_abr_type_str[] =
+const char *ospf_abr_type_str[] =
{
"unknown",
"standard",
@@ -6650,7 +6650,7 @@
"shortcut"
};
-char *ospf_shortcut_mode_str[] =
+const char *ospf_shortcut_mode_str[] =
{
"default",
"enable",
@@ -6670,7 +6670,7 @@
}
-char *ospf_int_type_str[] =
+const char *ospf_int_type_str[] =
{
"unknown", /* should never be used. */
"point-to-point",
@@ -6730,7 +6730,7 @@
if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
params->auth_type != OSPF_AUTH_NOTSET)
{
- char *auth_str;
+ const char *auth_str;
/* Translation tables are not that much help here due to syntax
of the simple option */
@@ -7087,8 +7087,8 @@
}
-char *distribute_str[] = { "system", "kernel", "connected", "static", "rip",
- "ripng", "ospf", "ospf6", "isis", "bgp"};
+const char *distribute_str[] = { "system", "kernel", "connected", "static",
+ "rip", "ripng", "ospf", "ospf6", "isis", "bgp"};
int
config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
{