[PATCH] hciemu: Fix gcc 4.7 compilation error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Johan Hedberg <johan.hedberg@xxxxxxxxx>

This patch fixes the following compilation error with gcc 4.7:

  CC     test/hciemu.o
test/hciemu.c: In function 'getbdaddrbyname':
test/hciemu.c:1115:3: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
---
I'm sending this to the list since I'm not completely sure what the code
is supposed to do or if this is the right fix or not.

 test/hciemu.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/test/hciemu.c b/test/hciemu.c
index 260e29a..4c62223 100644
--- a/test/hciemu.c
+++ b/test/hciemu.c
@@ -1109,10 +1109,11 @@ static int getbdaddrbyname(char *str, bdaddr_t *ba)
 	if (n == 0) {
 		/* loopback port */
 		in_addr_t addr = INADDR_LOOPBACK;
+		uint16_t be16 = htons(atoi(str));
 		bdaddr_t b;
 
 		memcpy(&b, &addr, 4);
-		*(uint16_t *) (&b.b[4]) = htons(atoi(str));
+		memcpy(&b.b[4], &be16, sizeof(be16));
 		baswap(ba, &b);
 
 		return 0;
-- 
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux