Fix most compiler warnings in default GCC build.
Fix lots of warnings. Some const and type-pun breaks strict-aliasing
warnings left but much reduced.
* bgp_advertise.h: (struct bgp_advertise_fifo) is functionally identical to
(struct fifo), so just use that. Makes it clearer the beginning of
(struct bgp_advertise) is compatible with with (struct fifo), which seems
to be enough for gcc.
Add a BGP_ADV_FIFO_HEAD macro to contain the right cast to try shut up
type-punning breaks strict aliasing warnings.
* bgp_packet.c: Use BGP_ADV_FIFO_HEAD.
(bgp_route_refresh_receive) fix an interesting logic error in
(!ok || (ret != BLAH)) where ret is only well-defined if ok.
* bgp_vty.c: Peer commands should use bgp_vty_return to set their return.
* jhash.{c,h}: Can take const on * args without adding issues & fix warnings.
* libospf.h: LSA sequence numbers use the unsigned range of values, and
constants need to be set to unsigned, or it causes warnings in ospf6d.
* md5.h: signedness of caddr_t is implementation specific, change to an
explicit (uint_8 *), fix sign/unsigned comparison warnings.
* vty.c: (vty_log_fixed) const on level is well-intentioned, but not going
to fly given iov_base.
* workqueue.c: ALL_LIST_ELEMENTS_RO tests for null pointer, which is always
true for address of static variable. Correct but pointless warning in
this case, but use a 2nd pointer to shut it up.
* ospf6_route.h: Add a comment about the use of (struct prefix) to stuff 2
different 32 bit IDs into in (struct ospf6_route), and the resulting
type-pun strict-alias breakage warnings this causes. Need to use 2
different fields to fix that warning?
general:
* remove unused variables, other than a few cases where they serve a
sufficiently useful documentary purpose (e.g. for code that needs
fixing), or they're required dummies. In those cases, try mark them as
unused.
* Remove dead code that can't be reached.
* Quite a few 'no ...' forms of vty commands take arguments, but do not
check the argument matches the command being negated. E.g., should
'distance X <prefix>' succeed if previously 'distance Y <prefix>' was set?
Or should it be required that the distance match the previously configured
distance for the prefix?
Ultimately, probably better to be strict about this. However, changing
from slack to strict might expose problems in command aliases and tools.
* Fix uninitialised use of variables.
* Fix sign/unsigned comparison warnings by making signedness of types consistent.
* Mark functions as static where their use is restricted to the same compilation
unit.
* Add required headers
* Move constants defined in headers into code.
* remove dead, unused functions that have no debug purpose.
diff --git a/zebra/irdp_interface.c b/zebra/irdp_interface.c
index 6403830..43c63a8 100644
--- a/zebra/irdp_interface.c
+++ b/zebra/irdp_interface.c
@@ -638,7 +638,6 @@
{
struct listnode *node, *nnode;
struct in_addr ip;
- int pref;
int ret;
struct interface *ifp;
struct zebra_if *zi;
@@ -657,8 +656,6 @@
if (!ret)
return CMD_WARNING;
- pref = atoi(argv[1]);
-
for (ALL_LIST_ELEMENTS (irdp->AdvPrefList, node, nnode, adv))
{
if(adv->ip.s_addr == ip.s_addr )
diff --git a/zebra/router-id.c b/zebra/router-id.c
index b738027..94a2941 100644
--- a/zebra/router-id.c
+++ b/zebra/router-id.c
@@ -41,8 +41,13 @@
#include "zebra/router-id.h"
#include "zebra/redistribute.h"
-static struct list rid_all_sorted_list;
-static struct list rid_lo_sorted_list;
+/* 2nd pointer type used primarily to quell a warning on
+ * ALL_LIST_ELEMENTS_RO
+ */
+static struct list _rid_all_sorted_list;
+static struct list _rid_lo_sorted_list;
+static struct list *rid_all_sorted_list = &_rid_all_sorted_list;
+static struct list *rid_lo_sorted_list = &_rid_lo_sorted_list;
static struct prefix rid_user_assigned;
/* master zebra server structure */
@@ -86,15 +91,15 @@
if (rid_user_assigned.u.prefix4.s_addr)
p->u.prefix4.s_addr = rid_user_assigned.u.prefix4.s_addr;
- else if (!list_isempty (&rid_lo_sorted_list))
+ else if (!list_isempty (rid_lo_sorted_list))
{
- node = listtail (&rid_lo_sorted_list);
+ node = listtail (rid_lo_sorted_list);
c = listgetdata (node);
p->u.prefix4.s_addr = c->address->u.prefix4.s_addr;
}
- else if (!list_isempty (&rid_all_sorted_list))
+ else if (!list_isempty (rid_all_sorted_list))
{
- node = listtail (&rid_all_sorted_list);
+ node = listtail (rid_all_sorted_list);
c = listgetdata (node);
p->u.prefix4.s_addr = c->address->u.prefix4.s_addr;
}
@@ -131,9 +136,9 @@
if (!strncmp (ifc->ifp->name, "lo", 2)
|| !strncmp (ifc->ifp->name, "dummy", 5))
- l = &rid_lo_sorted_list;
+ l = rid_lo_sorted_list;
else
- l = &rid_all_sorted_list;
+ l = rid_all_sorted_list;
if (!router_id_find_node (l, ifc))
listnode_add_sort (l, ifc);
@@ -164,9 +169,9 @@
if (!strncmp (ifc->ifp->name, "lo", 2)
|| !strncmp (ifc->ifp->name, "dummy", 5))
- l = &rid_lo_sorted_list;
+ l = rid_lo_sorted_list;
else
- l = &rid_all_sorted_list;
+ l = rid_all_sorted_list;
if ((c = router_id_find_node (l, ifc)))
listnode_delete (l, c);
@@ -240,12 +245,12 @@
install_element (CONFIG_NODE, &router_id_cmd);
install_element (CONFIG_NODE, &no_router_id_cmd);
- memset (&rid_all_sorted_list, 0, sizeof (rid_all_sorted_list));
- memset (&rid_lo_sorted_list, 0, sizeof (rid_lo_sorted_list));
+ memset (rid_all_sorted_list, 0, sizeof (rid_all_sorted_list));
+ memset (rid_lo_sorted_list, 0, sizeof (rid_lo_sorted_list));
memset (&rid_user_assigned, 0, sizeof (rid_user_assigned));
- rid_all_sorted_list.cmp = router_id_cmp;
- rid_lo_sorted_list.cmp = router_id_cmp;
+ rid_all_sorted_list->cmp = router_id_cmp;
+ rid_lo_sorted_list->cmp = router_id_cmp;
rid_user_assigned.family = AF_INET;
rid_user_assigned.prefixlen = 32;
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index f3cdcdc..12dbd1a 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -1246,9 +1246,9 @@
/* Utility function comes from iproute2.
Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> */
int
-addattr_l (struct nlmsghdr *n, int maxlen, int type, void *data, int alen)
+addattr_l (struct nlmsghdr *n, size_t maxlen, int type, void *data, int alen)
{
- int len;
+ size_t len;
struct rtattr *rta;
len = RTA_LENGTH (alen);
@@ -1288,9 +1288,9 @@
/* Utility function comes from iproute2.
Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> */
int
-addattr32 (struct nlmsghdr *n, int maxlen, int type, int data)
+addattr32 (struct nlmsghdr *n, size_t maxlen, int type, int data)
{
- int len;
+ size_t len;
struct rtattr *rta;
len = RTA_LENGTH (4);
diff --git a/zebra/rt_netlink.h b/zebra/rt_netlink.h
index 452b397..0facd49 100644
--- a/zebra/rt_netlink.h
+++ b/zebra/rt_netlink.h
@@ -27,9 +27,9 @@
#define NL_PKT_BUF_SIZE 8192
extern int
-addattr32 (struct nlmsghdr *n, int maxlen, int type, int data);
+addattr32 (struct nlmsghdr *n, size_t maxlen, int type, int data);
extern int
-addattr_l (struct nlmsghdr *n, int maxlen, int type, void *data, int alen);
+addattr_l (struct nlmsghdr *n, size_t maxlen, int type, void *data, int alen);
extern int
rta_addattr_l (struct rtattr *rta, int maxlen, int type, void *data, int alen);