From 982ee6499b76b21e1a7e601d02dff1c54b08c48d Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 16 May 2012 13:07:09 +0300 Subject: [PATCH] hciemu: Fix gcc 4.7 compilation error 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] --- test/hciemu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/hciemu.c b/test/hciemu.c index 260e29ae9..4c62223a8 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; -- 2.47.3