quagga: Additional centos 6 -enable-werror fixes
This commit fixes these warnings:
1) bgpd/bgp_nexthop.c - dereferencing pointer 'X' does break strict-aliasing rules
2) pimd/pim_igmp_join.c - dereferencing pointer 'X' does break strict-aliasing rules
3) ripd/ripd.c - 'ifaddr.prefixlen' may be used uninitialized in this function
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c
index 33de365..183a28b 100644
--- a/bgpd/bgp_nexthop.c
+++ b/bgpd/bgp_nexthop.c
@@ -648,9 +648,9 @@
addr = ifc->address;
+ p = *(CONNECTED_PREFIX(ifc));
if (addr->family == AF_INET)
{
- PREFIX_COPY_IPV4(&p, CONNECTED_PREFIX(ifc));
apply_mask_ipv4 ((struct prefix_ipv4 *) &p);
if (prefix_ipv4_any ((struct prefix_ipv4 *) &p))
@@ -674,7 +674,6 @@
#ifdef HAVE_IPV6
else if (addr->family == AF_INET6)
{
- PREFIX_COPY_IPV6(&p, CONNECTED_PREFIX(ifc));
apply_mask_ipv6 ((struct prefix_ipv6 *) &p);
if (IN6_IS_ADDR_UNSPECIFIED (&p.u.prefix6))
@@ -715,9 +714,9 @@
addr = ifc->address;
+ p = *(CONNECTED_PREFIX(ifc));
if (addr->family == AF_INET)
{
- PREFIX_COPY_IPV4(&p, CONNECTED_PREFIX(ifc));
apply_mask_ipv4 ((struct prefix_ipv4 *) &p);
if (prefix_ipv4_any ((struct prefix_ipv4 *) &p))
@@ -742,7 +741,6 @@
#ifdef HAVE_IPV6
else if (addr->family == AF_INET6)
{
- PREFIX_COPY_IPV6(&p, CONNECTED_PREFIX(ifc));
apply_mask_ipv6 ((struct prefix_ipv6 *) &p);
if (IN6_IS_ADDR_UNSPECIFIED (&p.u.prefix6))
diff --git a/pimd/pim_igmp_join.c b/pimd/pim_igmp_join.c
index 693a42b..151b2af 100644
--- a/pimd/pim_igmp_join.c
+++ b/pimd/pim_igmp_join.c
@@ -45,18 +45,20 @@
struct in_addr source_addr)
{
struct group_source_req req;
- struct sockaddr_in *group_sa = (struct sockaddr_in *) &req.gsr_group;
- struct sockaddr_in *source_sa = (struct sockaddr_in *) &req.gsr_source;
+ struct sockaddr_in group;
+ struct sockaddr_in source;
- memset(group_sa, 0, sizeof(*group_sa));
- group_sa->sin_family = AF_INET;
- group_sa->sin_addr = group_addr;
- group_sa->sin_port = htons(0);
+ memset(&group, 0, sizeof(group));
+ group.sin_family = AF_INET;
+ group.sin_addr = group_addr;
+ group.sin_port = htons(0);
+ memcpy(&req.gsr_group, &group, sizeof(struct sockaddr_in));
- memset(source_sa, 0, sizeof(*source_sa));
- source_sa->sin_family = AF_INET;
- source_sa->sin_addr = source_addr;
- source_sa->sin_port = htons(0);
+ memset(&source, 0, sizeof(source));
+ source.sin_family = AF_INET;
+ source.sin_addr = source_addr;
+ source.sin_port = htons(0);
+ memcpy(&req.gsr_source, &source, sizeof(struct sockaddr_in));
req.gsr_interface = ifindex;
diff --git a/ripd/ripd.c b/ripd/ripd.c
index b42ca72..b708889 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -1168,7 +1168,8 @@
struct prefix_ipv4 ifaddr;
struct prefix_ipv4 ifaddrclass;
int subnetted;
-
+
+ memset(&ifaddr, 0, sizeof(ifaddr));
/* We don't know yet. */
subnetted = -1;