summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPaul Jakma <paul@opensourcerouting.org>2014-09-19 15:42:23 +0200
committerDaniel Walton <dwalton@cumulusnetworks.com>2016-05-26 20:57:39 +0200
commit1f9a9fffc1cbbdea2b50540cc316b96200d6e48c (patch)
treeff85e2555401d13df41925a99ccc85927a0bacd6 /lib
parentzebra: fix rtnh_len in the rt_netlink messages for multipath case (diff)
downloadfrr-1f9a9fffc1cbbdea2b50540cc316b96200d6e48c.tar.xz
frr-1f9a9fffc1cbbdea2b50540cc316b96200d6e48c.zip
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. (cherry picked from commit 7aa9dcef80b2ce50ecaa77653d87c8b84e009c49) Conflicts: bgpd/bgp_advertise.h bgpd/bgp_mplsvpn.c bgpd/bgp_nexthop.c bgpd/bgp_packet.c bgpd/bgp_route.c bgpd/bgp_routemap.c bgpd/bgp_vty.c lib/command.c lib/if.c lib/jhash.c lib/workqueue.c ospf6d/ospf6_lsa.c ospf6d/ospf6_neighbor.h ospf6d/ospf6_spf.c ospf6d/ospf6_top.c ospfd/ospf_api.c zebra/router-id.c zebra/rt_netlink.c zebra/rt_netlink.h
Diffstat (limited to 'lib')
-rw-r--r--lib/if.c14
-rw-r--r--lib/jhash.c2
-rw-r--r--lib/vty.c2
-rw-r--r--lib/workqueue.c2
4 files changed, 9 insertions, 11 deletions
diff --git a/lib/if.c b/lib/if.c
index d49b5acad..97edf1769 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -638,16 +638,14 @@ if_flag_dump (unsigned long flag)
static void
if_dump (const struct interface *ifp)
{
+ struct listnode *node;
+ struct connected *c __attribute__((unused));
+
+ for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, c))
zlog_info ("Interface %s vrf %u index %d metric %d mtu %d "
-#ifdef HAVE_IPV6
- "mtu6 %d "
-#endif /* HAVE_IPV6 */
- "%s",
+ "mtu6 %d %s",
ifp->name, ifp->vrf_id, ifp->ifindex, ifp->metric, ifp->mtu,
-#ifdef HAVE_IPV6
- ifp->mtu6,
-#endif /* HAVE_IPV6 */
- if_flag_dump (ifp->flags));
+ ifp->mtu6, if_flag_dump (ifp->flags));
}
/* Interface printing for all interface. */
diff --git a/lib/jhash.c b/lib/jhash.c
index decd066cd..6154c3463 100644
--- a/lib/jhash.c
+++ b/lib/jhash.c
@@ -105,7 +105,7 @@ jhash (const void *key, u_int32_t length, u_int32_t initval)
* The length parameter here is the number of u_int32_ts in the key.
*/
u_int32_t
-jhash2 (const u_int32_t * k, u_int32_t length, u_int32_t initval)
+jhash2 (const u_int32_t *k, u_int32_t length, u_int32_t initval)
{
u_int32_t a, b, c, len;
diff --git a/lib/vty.c b/lib/vty.c
index 146a20fb0..a38a7523c 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -2486,7 +2486,7 @@ vty_log_fixed (char *buf, size_t len)
if (!vtyvec)
return;
- iov[0].iov_base = (void *)buf;
+ iov[0].iov_base = buf;
iov[0].iov_len = len;
iov[1].iov_base = crlf;
iov[1].iov_len = 2;
diff --git a/lib/workqueue.c b/lib/workqueue.c
index 6fad237e1..a45a6fc09 100644
--- a/lib/workqueue.c
+++ b/lib/workqueue.c
@@ -31,7 +31,7 @@
/* master list of work_queues */
static struct list _work_queues;
-/* pointer primarly to avid an otherwise harmless warning on
+/* pointer primarily to avoid an otherwise harmless warning on
* ALL_LIST_ELEMENTS_RO
*/
static struct list *work_queues = &_work_queues;