ospfd: compile warning cleanups
A set of patches to clarify some comments as well as cleanup code that was
causing warnings. After these patches, the code can be compiled with
-Wall -Wsign-compare -Wpointer-arith -Wbad-function-cast -Wwrite-strings
-Wmissing-prototypes -Wmissing-declarations -Wchar-subscripts -Wcast-qual
-Wextra -Wno-unused-parameter -Wno-missing-field-initializers
(what is current in trunk plus -Wextra -Wno-unused-parameter
-Wno-missing-field-initializers).
Signed-off-by: Scott Feldman <sfeldma@cumulusnetworks.com>
diff --git a/ospfd/ospf_apiserver.c b/ospfd/ospf_apiserver.c
index 84d70cc..db1ccda 100644
--- a/ospfd/ospf_apiserver.c
+++ b/ospfd/ospf_apiserver.c
@@ -299,13 +299,10 @@
ospf_apiserver_event (enum event event, int fd,
struct ospf_apiserver *apiserv)
{
- struct thread *apiserver_serv_thread;
-
switch (event)
{
case OSPF_APISERVER_ACCEPT:
- apiserver_serv_thread =
- thread_add_read (master, ospf_apiserver_accept, apiserv, fd);
+ (void)thread_add_read (master, ospf_apiserver_accept, apiserv, fd);
break;
case OSPF_APISERVER_SYNC_READ:
apiserv->t_sync_read =
diff --git a/ospfd/ospf_ism.c b/ospfd/ospf_ism.c
index db53882..fa7d97f 100644
--- a/ospfd/ospf_ism.c
+++ b/ospfd/ospf_ism.c
@@ -203,7 +203,6 @@
struct in_addr old_dr, old_bdr;
int old_state, new_state;
struct list *el_list;
- struct ospf_neighbor *dr, *bdr;
/* backup current values. */
old_dr = DR (oi);
@@ -216,8 +215,8 @@
ospf_dr_eligible_routers (oi->nbrs, el_list);
/* First election of DR and BDR. */
- bdr = ospf_elect_bdr (oi, el_list);
- dr = ospf_elect_dr (oi, el_list);
+ ospf_elect_bdr (oi, el_list);
+ ospf_elect_dr (oi, el_list);
new_state = ospf_ism_state (oi);
diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c
index fb55f7f..4f7fb00 100644
--- a/ospfd/ospf_lsa.c
+++ b/ospfd/ospf_lsa.c
@@ -2733,7 +2733,9 @@
if (IS_LSA_SELF (lsa))
lsa->oi = oi; /* Specify outgoing ospf-interface for this LSA. */
else
- ; /* Incoming "oi" for this LSA has set at LSUpd reception. */
+ {
+ /* Incoming "oi" for this LSA has set at LSUpd reception. */
+ }
/* Fallthrough */
case OSPF_OPAQUE_AREA_LSA:
case OSPF_OPAQUE_AS_LSA:
diff --git a/ospfd/ospf_lsa.h b/ospfd/ospf_lsa.h
index 6c95ff1..9ff2d92 100644
--- a/ospfd/ospf_lsa.h
+++ b/ospfd/ospf_lsa.h
@@ -243,6 +243,7 @@
extern int get_age (struct ospf_lsa *);
extern u_int16_t ospf_lsa_checksum (struct lsa_header *);
+extern int ospf_lsa_checksum_valid (struct lsa_header *);
extern int ospf_lsa_refresh_delay (struct ospf_lsa *);
extern const char *dump_lsa_key (struct ospf_lsa *);
diff --git a/ospfd/ospf_network.c b/ospfd/ospf_network.c
index 3e326a8..900a566 100644
--- a/ospfd/ospf_network.c
+++ b/ospfd/ospf_network.c
@@ -228,7 +228,7 @@
}
void
-ospf_adjust_sndbuflen (struct ospf * ospf, int buflen)
+ospf_adjust_sndbuflen (struct ospf * ospf, unsigned int buflen)
{
int ret, newbuflen;
/* Check if any work has to be done at all. */
@@ -249,11 +249,11 @@
*/
ret = setsockopt_so_sendbuf (ospf->fd, buflen);
newbuflen = getsockopt_so_sendbuf (ospf->fd);
- if (ret < 0 || newbuflen < buflen)
- zlog_warn ("%s: tried to set SO_SNDBUF to %d, but got %d",
+ if (ret < 0 || newbuflen < 0 || newbuflen < (int) buflen)
+ zlog_warn ("%s: tried to set SO_SNDBUF to %u, but got %d",
__func__, buflen, newbuflen);
if (newbuflen >= 0)
- ospf->maxsndbuflen = newbuflen;
+ ospf->maxsndbuflen = (unsigned int)newbuflen;
else
zlog_warn ("%s: failed to get SO_SNDBUF", __func__);
if (ospfd_privs.change (ZPRIVS_LOWER))
diff --git a/ospfd/ospf_network.h b/ospfd/ospf_network.h
index f690991..e0a5c69 100644
--- a/ospfd/ospf_network.h
+++ b/ospfd/ospf_network.h
@@ -34,6 +34,6 @@
unsigned int);
extern int ospf_if_ipmulticast (struct ospf *, struct prefix *, unsigned int);
extern int ospf_sock_init (void);
-extern void ospf_adjust_sndbuflen (struct ospf *, int);
+extern void ospf_adjust_sndbuflen (struct ospf *, unsigned int);
#endif /* _ZEBRA_OSPF_NETWORK_H */
diff --git a/ospfd/ospf_nsm.c b/ospfd/ospf_nsm.c
index 436896c..fe4ddf5 100644
--- a/ospfd/ospf_nsm.c
+++ b/ospfd/ospf_nsm.c
@@ -72,14 +72,11 @@
static int
ospf_db_desc_timer (struct thread *thread)
{
- struct ospf_interface *oi;
struct ospf_neighbor *nbr;
nbr = THREAD_ARG (thread);
nbr->t_db_desc = NULL;
- oi = nbr->oi;
-
if (IS_DEBUG_OSPF (nsm, NSM_TIMERS))
zlog (NULL, LOG_DEBUG, "NSM[%s:%s]: Timer (DD Retransmit timer expire)",
IF_NAME (nbr->oi), inet_ntoa (nbr->src));
@@ -787,11 +784,9 @@
int event;
int next_state;
struct ospf_neighbor *nbr;
- struct in_addr router_id;
nbr = THREAD_ARG (thread);
event = THREAD_VAL (thread);
- router_id = nbr->router_id;
if (IS_DEBUG_OSPF (nsm, NSM_EVENTS))
zlog_debug ("NSM[%s:%s]: %s (%s)", IF_NAME (nbr->oi),
diff --git a/ospfd/ospf_opaque.c b/ospfd/ospf_opaque.c
index aa126e1..744952c 100644
--- a/ospfd/ospf_opaque.c
+++ b/ospfd/ospf_opaque.c
@@ -223,9 +223,15 @@
default:
if (OPAQUE_TYPE_RANGE_UNASSIGNED (opaque_type))
name = "Unassigned";
- /* XXX warning: comparison is always true due to limited range of data type */
- else if (OPAQUE_TYPE_RANGE_RESERVED (opaque_type))
- name = "Private/Experimental";
+ else
+ {
+ u_int32_t bigger_range = opaque_type;
+ /*
+ * Get around type-limits warning: comparison is always true due to limited range of data type
+ */
+ if (OPAQUE_TYPE_RANGE_RESERVED (bigger_range))
+ name = "Private/Experimental";
+ }
break;
}
return name;
diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c
index a51db24..9a4587d 100644
--- a/ospfd/ospf_packet.c
+++ b/ospfd/ospf_packet.c
@@ -1764,7 +1764,7 @@
/* Process each LSA received in the one packet.
*
* Numbers in parentheses, e.g. (1), (2), etc., and the corresponding
- * text below are from the stepsin RFC 2328, Section 13.
+ * text below are from the steps in RFC 2328, Section 13.
*/
for (ALL_LIST_ELEMENTS (lsas, node, nnode, lsa))
{
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c
index 45ddc5c..2ba8188 100644
--- a/ospfd/ospf_vty.c
+++ b/ospfd/ospf_vty.c
@@ -1742,12 +1742,11 @@
struct ospf *ospf = vty->index;
struct ospf_area *area;
struct in_addr area_id;
- u_int32_t cost;
int format;
struct prefix_ipv4 p;
VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
- VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
+ VTY_CHECK_INTEGER_RANGE ("stub default cost", argv[1], 0, OSPF_LS_INFINITY);
area = ospf_area_lookup_by_area_id (ospf, area_id);
if (area == NULL)
@@ -1933,7 +1932,6 @@
struct ospf *ospf = vty->index;
struct ospf_area *area;
struct in_addr area_id;
- struct prefix_list *plist;
int format;
VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
@@ -1941,7 +1939,6 @@
if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL)
return CMD_SUCCESS;
- plist = prefix_list_lookup (AFI_IP, argv[1]);
if (strncmp (argv[2], "in", 2) == 0)
{
if (PREFIX_NAME_IN (area))
@@ -2394,11 +2391,10 @@
{
struct ospf *ospf = vty->index;
struct in_addr nbr_addr;
- int ret;
VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
- ret = ospf_nbr_nbma_unset (ospf, nbr_addr);
+ (void)ospf_nbr_nbma_unset (ospf, nbr_addr);
return CMD_SUCCESS;
}
@@ -5408,7 +5404,7 @@
"Address of interface")
{
struct interface *ifp = vty->index;
- u_int32_t priority;
+ long priority;
struct route_node *rn;
struct in_addr addr;
int ret;
diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c
index f5f49f6..34a3b2a 100644
--- a/ospfd/ospf_zebra.c
+++ b/ospfd/ospf_zebra.c
@@ -133,8 +133,8 @@
if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE))
zlog_debug
- ("Zebra: interface delete %s index %d flags %lld metric %d mtu %d",
- ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu);
+ ("Zebra: interface delete %s index %d flags %llx metric %d mtu %d",
+ ifp->name, ifp->ifindex, (unsigned long long)ifp->flags, ifp->metric, ifp->mtu);
#ifdef HAVE_SNMP
ospf_snmp_if_delete (ifp);
@@ -1004,7 +1004,7 @@
/* Update distribute-list and set timer to apply access-list. */
void
-ospf_distribute_list_update (struct ospf *ospf, int type)
+ospf_distribute_list_update (struct ospf *ospf, uintptr_t type)
{
struct route_table *rt;
@@ -1217,7 +1217,6 @@
{
int ret;
struct prefix_ipv4 p;
- u_char distance;
struct route_node *rn;
struct ospf_distance *odistance;
@@ -1228,8 +1227,6 @@
return CMD_WARNING;
}
- distance = atoi (distance_str);
-
rn = route_node_lookup (ospf->distance_table, (struct prefix *) &p);
if (!rn)
{
diff --git a/ospfd/ospf_zebra.h b/ospfd/ospf_zebra.h
index fbb3444..148f652 100644
--- a/ospfd/ospf_zebra.h
+++ b/ospfd/ospf_zebra.h
@@ -54,7 +54,7 @@
int *);
extern int ospf_distribute_check_connected (struct ospf *,
struct external_info *);
-extern void ospf_distribute_list_update (struct ospf *, int);
+extern void ospf_distribute_list_update (struct ospf *, uintptr_t);
extern int ospf_is_type_redistributed (int);
extern void ospf_distance_reset (struct ospf *);
diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c
index d1de29d..3e2b234 100644
--- a/ospfd/ospfd.c
+++ b/ospfd/ospfd.c
@@ -223,7 +223,7 @@
}
new->maxsndbuflen = getsockopt_so_sendbuf (new->fd);
if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE))
- zlog_debug ("%s: starting with OSPF send buffer size %d",
+ zlog_debug ("%s: starting with OSPF send buffer size %u",
__func__, new->maxsndbuflen);
if ((new->ibuf = stream_new(OSPF_MAX_PACKET_SIZE+1)) == NULL)
{
diff --git a/ospfd/ospfd.h b/ospfd/ospfd.h
index cc27f66..fb57bf5 100644
--- a/ospfd/ospfd.h
+++ b/ospfd/ospfd.h
@@ -273,7 +273,7 @@
struct thread *t_write;
struct thread *t_read;
int fd;
- int maxsndbuflen;
+ unsigned int maxsndbuflen;
struct stream *ibuf;
struct list *oi_write_q;