[PATCH 1/3] udhcpc6: fix aliasing warnings

Josef Bacik jbacik at fb.com
Tue May 17 16:29:49 UTC 2016


Add the fix_aliasing attribute to the client6 data and then move things around a
bit to make the casting explicit as GCC still complains even though it's
perfectly fine.

Signed-off-by: Josef Bacik <jbacik at fb.com>
---
 networking/udhcp/d6_common.h | 2 +-
 networking/udhcp/d6_dhcpc.c  | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/networking/udhcp/d6_common.h b/networking/udhcp/d6_common.h
index eb211ea..e1ee2e8 100644
--- a/networking/udhcp/d6_common.h
+++ b/networking/udhcp/d6_common.h
@@ -91,7 +91,7 @@ struct client6_data_t {
 	struct d6_option *ia_na;
 	char **env_ptr;
 	unsigned env_idx;
-};
+} FIX_ALIASING;
 
 #define client6_data (*(struct client6_data_t*)(&bb_common_bufsiz1[COMMON_BUFSIZE - sizeof(struct client6_data_t)]))
 
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c
index c77669a..4466ebb 100644
--- a/networking/udhcp/d6_dhcpc.c
+++ b/networking/udhcp/d6_dhcpc.c
@@ -402,6 +402,7 @@ static int d6_mcast_from_client_config_ifindex(struct d6_packet *packet, uint8_t
 static NOINLINE int send_d6_discover(uint32_t xid, struct in6_addr *requested_ipv6)
 {
 	struct d6_packet packet;
+	uint32_t *iaid;
 	uint8_t *opt_ptr;
 	unsigned len;
 
@@ -414,7 +415,8 @@ static NOINLINE int send_d6_discover(uint32_t xid, struct in6_addr *requested_ip
 	client6_data.ia_na = xzalloc(len);
 	client6_data.ia_na->code = D6_OPT_IA_NA;
 	client6_data.ia_na->len = len - 4;
-	*(uint32_t*)client6_data.ia_na->data = rand(); /* IAID */
+	iaid = (uint32_t *)client6_data.ia_na->data;
+	*iaid = rand(); /* IAID */
 	if (requested_ipv6) {
 		struct d6_option *iaaddr = (void*)(client6_data.ia_na->data + 4+4+4);
 		iaaddr->code = D6_OPT_IAADDR;
-- 
2.5.0



More information about the busybox mailing list