ospf6d: use existing union, avoid strict-aliasing
There are preexisting fields u.lp.id and u.lp.adv_router in struct
prefix that do the same thing as these type-punning pointer derefs.
Use these and shut up the strict-aliasing warnings.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
diff --git a/ospf6d/ospf6_route.h b/ospf6d/ospf6_route.h
index c0dcf9f..42eb69e 100644
--- a/ospf6d/ospf6_route.h
+++ b/ospf6d/ospf6_route.h
@@ -239,16 +239,15 @@
sizeof (struct ospf6_nexthop) * OSPF6_MULTI_PATH_LIMIT) == 0)
#define ospf6_route_is_best(r) (CHECK_FLAG ((r)->flag, OSPF6_ROUTE_BEST))
-/* XXX: This gives GCC heartburn aboutbreaking aliasing rules. */
#define ospf6_linkstate_prefix_adv_router(x) \
- (*(u_int32_t *)(&(x)->u.prefix6.s6_addr[0]))
+ ((x)->u.lp.id.s_addr)
#define ospf6_linkstate_prefix_id(x) \
- (*(u_int32_t *)(&(x)->u.prefix6.s6_addr[4]))
+ ((x)->u.lp.adv_router.s_addr)
#define ADV_ROUTER_IN_PREFIX(x) \
- (*(u_int32_t *)(&(x)->u.prefix6.s6_addr[0]))
+ ((x)->u.lp.id.s_addr)
#define ID_IN_PREFIX(x) \
- (*(u_int32_t *)(&(x)->u.prefix6.s6_addr[4]))
+ ((x)->u.lp.adv_router.s_addr)
/* Function prototype */
extern void ospf6_linkstate_prefix (u_int32_t adv_router, u_int32_t id,