Compiler warnings fixes round 1.

This commit is contained in:
hasso 2004-10-08 08:17:22 +00:00
parent 2e864cfa12
commit eb1ce6059a
13 changed files with 60 additions and 54 deletions

View file

@ -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> 2004-10-07 Greg Troxel <gdt@claude.ir.bbn.com>
* ospf_apiserver.c (ospf_apiserver_unregister_opaque_type): Don't * ospf_apiserver.c (ospf_apiserver_unregister_opaque_type): Don't

View file

@ -149,7 +149,7 @@ unsigned long term_debug_ospf_nssa = 0;
#define OSPF_AREA_STRING_MAXLEN 16 #define OSPF_AREA_STRING_MAXLEN 16
char * const char *
ospf_area_name_string (struct ospf_area *area) ospf_area_name_string (struct ospf_area *area)
{ {
static char buf[OSPF_AREA_STRING_MAXLEN] = ""; static char buf[OSPF_AREA_STRING_MAXLEN] = "";
@ -166,7 +166,7 @@ ospf_area_name_string (struct ospf_area *area)
} }
#define OSPF_AREA_DESC_STRING_MAXLEN 23 #define OSPF_AREA_DESC_STRING_MAXLEN 23
char * const char *
ospf_area_desc_string (struct ospf_area *area) ospf_area_desc_string (struct ospf_area *area)
{ {
static char buf[OSPF_AREA_DESC_STRING_MAXLEN] = ""; static char buf[OSPF_AREA_DESC_STRING_MAXLEN] = "";
@ -195,7 +195,7 @@ ospf_area_desc_string (struct ospf_area *area)
} }
#define OSPF_IF_STRING_MAXLEN 40 #define OSPF_IF_STRING_MAXLEN 40
char * const char *
ospf_if_name_string (struct ospf_interface *oi) ospf_if_name_string (struct ospf_interface *oi)
{ {
static char buf[OSPF_IF_STRING_MAXLEN] = ""; static char buf[OSPF_IF_STRING_MAXLEN] = "";
@ -236,7 +236,7 @@ ospf_nbr_state_message (struct ospf_neighbor *nbr, char *buf, size_t size)
LOOKUP (ospf_ism_state_msg, state)); LOOKUP (ospf_ism_state_msg, state));
} }
char * const char *
ospf_timer_dump (struct thread *t, char *buf, size_t size) ospf_timer_dump (struct thread *t, char *buf, size_t size)
{ {
struct timeval now; struct timeval now;
@ -326,7 +326,7 @@ ospf_dd_flags_dump (u_char flags, char *buf, size_t size)
void void
ospf_lsa_header_dump (struct lsa_header *lsah) 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 (" LSA Header");
zlog_info (" LS age %d", ntohs (lsah->ls_age)); zlog_info (" LS age %d", ntohs (lsah->ls_age));
@ -1484,8 +1484,8 @@ config_write_debug (struct vty *vty)
int write = 0; int write = 0;
int i, r; int i, r;
char *type_str[] = {"hello", "dd", "ls-request", "ls-update", "ls-ack"}; const char *type_str[] = {"hello", "dd", "ls-request", "ls-update", "ls-ack"};
char *detail_str[] = {"", " send", " recv", "", " detail", const char *detail_str[] = {"", " send", " recv", "", " detail",
" send detail", " recv detail", " detail"}; " send detail", " recv detail", " detail"};
/* debug ospf ism (status|events|timers). */ /* debug ospf ism (status|events|timers). */

View file

@ -121,16 +121,16 @@ extern unsigned long term_debug_ospf_zebra;
extern unsigned long term_debug_ospf_nssa; extern unsigned long term_debug_ospf_nssa;
/* Message Strings. */ /* Message Strings. */
extern char *ospf_packet_type_str[]; extern const char *ospf_packet_type_str[];
extern char *ospf_lsa_type_str[]; extern char *ospf_lsa_type_str[];
/* Prototypes. */ /* Prototypes. */
char *ospf_area_name_string (struct ospf_area *); const char *ospf_area_name_string (struct ospf_area *);
char *ospf_area_desc_string (struct ospf_area *); const char *ospf_area_desc_string (struct ospf_area *);
char *ospf_if_name_string (struct ospf_interface *); const char *ospf_if_name_string (struct ospf_interface *);
void ospf_nbr_state_message (struct ospf_neighbor *, char *, size_t); void ospf_nbr_state_message (struct ospf_neighbor *, char *, size_t);
char *ospf_options_dump (u_char); 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_ip_header_dump (struct stream *);
void ospf_packet_dump (struct stream *); void ospf_packet_dump (struct stream *);
void ospf_lsa_header_dump (struct lsa_header *); void ospf_lsa_header_dump (struct lsa_header *);

View file

@ -553,7 +553,7 @@ struct {
}, },
}; };
static char *ospf_ism_event_str[] = const static char *ospf_ism_event_str[] =
{ {
"NoEvent", "NoEvent",
"InterfaceUp", "InterfaceUp",

View file

@ -902,7 +902,7 @@ ospf_router_lsa_update_timer (struct thread *thread)
struct ospf_area *area = getdata (node); struct ospf_area *area = getdata (node);
struct ospf_lsa *lsa = area->router_lsa_self; struct ospf_lsa *lsa = area->router_lsa_self;
struct router_lsa *rl; struct router_lsa *rl;
char *area_str; const char *area_str;
/* Keep Area ID string. */ /* Keep Area ID string. */
area_str = AREA_NAME (area); area_str = AREA_NAME (area);

View file

@ -97,7 +97,7 @@ struct option longopts[] =
struct thread_master *master; struct thread_master *master;
/* Process ID saved for use by init system */ /* Process ID saved for use by init system */
char *pid_file = PATH_OSPFD_PID; const char *pid_file = PATH_OSPFD_PID;
/* Help information display. */ /* Help information display. */
static void static void

View file

@ -640,7 +640,7 @@ struct {
}, },
}; };
static char *ospf_nsm_event_str[] = const static char *ospf_nsm_event_str[] =
{ {
"NoEvent", "NoEvent",
"HelloReceived", "HelloReceived",

View file

@ -52,7 +52,7 @@ static void ospf_ls_ack_send_list (struct ospf_interface *, struct list *,
struct in_addr); struct in_addr);
/* Packet Type String. */ /* Packet Type String. */
char *ospf_packet_type_str[] = const char *ospf_packet_type_str[] =
{ {
"unknown", "unknown",
"Hello", "Hello",
@ -347,7 +347,7 @@ ospf_make_md5_digest (struct ospf_interface *oi, struct ospf_packet *op)
/* Get MD5 Authentication key from auth_key list. */ /* Get MD5 Authentication key from auth_key list. */
if (list_isempty (OSPF_IF_PARAM (oi, auth_crypt))) if (list_isempty (OSPF_IF_PARAM (oi, auth_crypt)))
auth_key = ""; auth_key = (char *) "";
else else
{ {
ck = getdata (OSPF_IF_PARAM (oi, auth_crypt)->tail); ck = getdata (OSPF_IF_PARAM (oi, auth_crypt)->tail);
@ -1991,12 +1991,11 @@ ospf_recv_packet (int fd, struct interface **ifp)
struct stream *ibuf; struct stream *ibuf;
unsigned int ifindex = 0; unsigned int ifindex = 0;
struct iovec iov; struct iovec iov;
struct cmsghdr *cmsg;
#if defined(CMSG_SPACE) #if defined(CMSG_SPACE)
/* Header and data both require alignment. */ /* Header and data both require alignment. */
char buff [CMSG_SPACE(SOPT_SIZE_CMSG_IFINDEX_IPV4())]; char buff [CMSG_SPACE(SOPT_SIZE_CMSG_IFINDEX_IPV4())];
#else #else
char buff [sizeof (*cmsg) + SOPT_SIZE_CMSG_IFINDEX_IPV4()]; char buff [sizeof (struct cmsghdr) + SOPT_SIZE_CMSG_IFINDEX_IPV4()];
#endif #endif
struct msghdr msgh; struct msghdr msgh;

View file

@ -640,7 +640,7 @@ ospf_intra_add_stub (struct route_table *rt, struct router_lsa_link *link,
zlog_info("ospf_intra_add_stub(): Stop"); zlog_info("ospf_intra_add_stub(): Stop");
} }
char *ospf_path_type_str[] = const char *ospf_path_type_str[] =
{ {
"unknown-type", "unknown-type",
"intra-area", "intra-area",

View file

@ -98,7 +98,7 @@ ospf_route_map_event (route_map_event_t event, char *name)
/* Delete rip route map rule. */ /* Delete rip route map rule. */
int int
ospf_route_match_delete (struct vty *vty, struct route_map_index *index, ospf_route_match_delete (struct vty *vty, struct route_map_index *index,
char *command, char *arg) const char *command, char *arg)
{ {
int ret; int ret;
@ -123,7 +123,7 @@ ospf_route_match_delete (struct vty *vty, struct route_map_index *index,
int int
ospf_route_match_add (struct vty *vty, struct route_map_index *index, ospf_route_match_add (struct vty *vty, struct route_map_index *index,
char *command, char *arg) const char *command, char *arg)
{ {
int ret; int ret;
@ -148,7 +148,7 @@ ospf_route_match_add (struct vty *vty, struct route_map_index *index,
int int
ospf_route_set_add (struct vty *vty, struct route_map_index *index, ospf_route_set_add (struct vty *vty, struct route_map_index *index,
char *command, char *arg) const char *command, char *arg)
{ {
int ret; int ret;
@ -174,7 +174,7 @@ ospf_route_set_add (struct vty *vty, struct route_map_index *index,
/* Delete rip route map rule. */ /* Delete rip route map rule. */
int int
ospf_route_set_delete (struct vty *vty, struct route_map_index *index, ospf_route_set_delete (struct vty *vty, struct route_map_index *index,
char *command, char *arg) const char *command, char *arg)
{ {
int ret; int ret;
@ -760,9 +760,11 @@ DEFUN (set_metric_type,
"OSPF[6] external type 2 metric\n") "OSPF[6] external type 2 metric\n")
{ {
if (strcmp (argv[0], "1") == 0) 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) 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]); return ospf_route_set_add (vty, vty->index, "metric-type", argv[0]);
} }

View file

@ -115,7 +115,7 @@ ospf_vertex_free (struct vertex *v)
} }
void void
ospf_vertex_dump(char *msg, struct vertex *v, ospf_vertex_dump(const char *msg, struct vertex *v,
int print_nexthops, int print_children) int print_nexthops, int print_children)
{ {
if ( ! IS_DEBUG_OSPF_EVENT) if ( ! IS_DEBUG_OSPF_EVENT)
@ -245,8 +245,7 @@ ospf_vertex_lookup (struct list *vlist, struct in_addr id, int type)
int int
ospf_lsa_has_link (struct lsa_header *w, struct lsa_header *v) ospf_lsa_has_link (struct lsa_header *w, struct lsa_header *v)
{ {
int i; unsigned int i, length;
int length;
struct router_lsa *rl; struct router_lsa *rl;
struct network_lsa *nl; struct network_lsa *nl;
@ -494,7 +493,6 @@ ospf_nexthop_calculation (struct ospf_area *area,
if (IS_DEBUG_OSPF_EVENT) if (IS_DEBUG_OSPF_EVENT)
{ {
char buf1[BUFSIZ]; char buf1[BUFSIZ];
char buf2[BUFSIZ];
zlog_info("ospf_nexthop_calculation(): considering link " zlog_info("ospf_nexthop_calculation(): considering link "
"type %d link_id %s link_data %s", "type %d link_id %s link_data %s",
l->m[0].type, l->m[0].type,

View file

@ -1872,8 +1872,10 @@ DEFUN (show_mpls_te_link,
/* Show All Interfaces. */ /* Show All Interfaces. */
if (argc == 0) if (argc == 0)
{
LIST_LOOP (iflist, ifp, node) LIST_LOOP (iflist, ifp, node)
show_mpls_te_link_sub (vty, ifp); show_mpls_te_link_sub (vty, ifp);
}
/* Interface name is specified. */ /* Interface name is specified. */
else else
{ {

View file

@ -49,7 +49,7 @@
#include "ospfd/ospf_dump.h" #include "ospfd/ospf_dump.h"
static char *ospf_network_type_str[] = const static char *ospf_network_type_str[] =
{ {
"Null", "Null",
"POINTOPOINT", "POINTOPOINT",
@ -2098,8 +2098,8 @@ DEFUN (ospf_neighbor,
{ {
struct ospf *ospf = vty->index; struct ospf *ospf = vty->index;
struct in_addr nbr_addr; struct in_addr nbr_addr;
int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
int interval = OSPF_POLL_INTERVAL_DEFAULT; unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
@ -2146,8 +2146,8 @@ DEFUN (ospf_neighbor_poll_interval,
{ {
struct ospf *ospf = vty->index; struct ospf *ospf = vty->index;
struct in_addr nbr_addr; struct in_addr nbr_addr;
int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT; unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
int interval = OSPF_POLL_INTERVAL_DEFAULT; unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]); VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
@ -2231,7 +2231,7 @@ DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
"Timer value in seconds\n") "Timer value in seconds\n")
{ {
struct ospf *ospf = vty->index; struct ospf *ospf = vty->index;
int interval; unsigned int interval;
VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800); VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
interval = (interval / 10) * 10; interval = (interval / 10) * 10;
@ -2248,7 +2248,7 @@ DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
"Timer value in seconds\n") "Timer value in seconds\n")
{ {
struct ospf *ospf = vty->index; struct ospf *ospf = vty->index;
int interval; unsigned int interval;
if (argc == 1) if (argc == 1)
{ {
@ -2325,7 +2325,7 @@ DEFUN (no_ospf_auto_cost_reference_bandwidth,
return CMD_SUCCESS; return CMD_SUCCESS;
} }
char *ospf_abr_type_descr_str[] = const char *ospf_abr_type_descr_str[] =
{ {
"Unknown", "Unknown",
"Standard (RFC2328)", "Standard (RFC2328)",
@ -2334,7 +2334,7 @@ char *ospf_abr_type_descr_str[] =
"Alternative Shortcut" "Alternative Shortcut"
}; };
char *ospf_shortcut_mode_descr_str[] = const char *ospf_shortcut_mode_descr_str[] =
{ {
"Default", "Default",
"Enabled", "Enabled",
@ -3132,7 +3132,7 @@ show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
return 0; return 0;
} }
char *show_database_desc[] = const char *show_database_desc[] =
{ {
"unknown", "unknown",
"Router Link States", "Router Link States",
@ -3153,7 +3153,7 @@ char *show_database_desc[] =
#define SHOW_OSPF_COMMON_HEADER \ #define SHOW_OSPF_COMMON_HEADER \
"Link ID ADV Router Age Seq# CkSum" "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", "Link ID ADV Router Age Seq# CkSum Link count",
@ -3171,7 +3171,7 @@ char *show_database_header[] =
#endif /* HAVE_OPAQUE_LSA */ #endif /* HAVE_OPAQUE_LSA */
}; };
char *show_lsa_flags[] = const char *show_lsa_flags[] =
{ {
"Self-originated", "Self-originated",
"Checked", "Checked",
@ -3222,7 +3222,7 @@ show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE); vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
} }
char *link_type_desc[] = const char *link_type_desc[] =
{ {
"(null)", "(null)",
"another Router (point-to-point)", "another Router (point-to-point)",
@ -3231,7 +3231,7 @@ char *link_type_desc[] =
"a Virtual Link", "a Virtual Link",
}; };
char *link_id_desc[] = const char *link_id_desc[] =
{ {
"(null)", "(null)",
"Neighboring Router ID", "Neighboring Router ID",
@ -3240,7 +3240,7 @@ char *link_id_desc[] =
"Neighboring Router ID", "Neighboring Router ID",
}; };
char *link_data_desc[] = const char *link_data_desc[] =
{ {
"(null)", "(null)",
"Router Interface address", "Router Interface address",
@ -6641,7 +6641,7 @@ DEFUN (show_ip_ospf_route,
} }
char *ospf_abr_type_str[] = const char *ospf_abr_type_str[] =
{ {
"unknown", "unknown",
"standard", "standard",
@ -6650,7 +6650,7 @@ char *ospf_abr_type_str[] =
"shortcut" "shortcut"
}; };
char *ospf_shortcut_mode_str[] = const char *ospf_shortcut_mode_str[] =
{ {
"default", "default",
"enable", "enable",
@ -6670,7 +6670,7 @@ area_id2str (char *buf, int length, struct ospf_area *area)
} }
char *ospf_int_type_str[] = const char *ospf_int_type_str[] =
{ {
"unknown", /* should never be used. */ "unknown", /* should never be used. */
"point-to-point", "point-to-point",
@ -6730,7 +6730,7 @@ config_write_interface (struct vty *vty)
if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) && if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
params->auth_type != OSPF_AUTH_NOTSET) params->auth_type != OSPF_AUTH_NOTSET)
{ {
char *auth_str; const char *auth_str;
/* Translation tables are not that much help here due to syntax /* Translation tables are not that much help here due to syntax
of the simple option */ of the simple option */
@ -7087,8 +7087,8 @@ config_write_virtual_link (struct vty *vty, struct ospf *ospf)
} }
char *distribute_str[] = { "system", "kernel", "connected", "static", "rip", const char *distribute_str[] = { "system", "kernel", "connected", "static",
"ripng", "ospf", "ospf6", "isis", "bgp"}; "rip", "ripng", "ospf", "ospf6", "isis", "bgp"};
int int
config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf) config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
{ {