[PATCH BlueZ] Fix strict-aliasing rules handling for hciemu and IP ports

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

 



This fix is based on commit 97046eaf3fc44b4451157b1a1bbc166ab0f4dda8.
---

Due to some recent change, gcc 4.4.3 (from Ubuntu 10.04) started complaining
about this code:

test/hciemu.c: In function â??hci_host_controlâ??:
test/hciemu.c:431: error: dereferencing pointer â??({anonymous})â?? does break
strict-aliasing rules
test/hciemu.c:431: note: initialized from here


 test/hciemu.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/hciemu.c b/test/hciemu.c
index ccd6cc3..7eb8814 100644
--- a/test/hciemu.c
+++ b/test/hciemu.c
@@ -428,7 +428,7 @@ static int scan_enable(uint8_t *data)
 	baswap(&ba, &vdev.bdaddr);
 	sa.sin_family = AF_INET;
 	memcpy(&sa.sin_addr.s_addr, &ba, sizeof(sa.sin_addr.s_addr));
-	sa.sin_port = *(uint16_t *) &ba.b[4];
+	memcpy(&sa.sin_port, &ba.b[4], sizeof(sa.sin_port));
 	if (bind(sk, (struct sockaddr *) &sa, sizeof(sa))) {
 		syslog(LOG_ERR, "Can't bind socket: %s (%d)",
 						strerror(errno), errno);
@@ -541,7 +541,7 @@ do_connect:
 	baswap(&ba, &cp->bdaddr);
 	sa.sin_family = AF_INET;
 	memcpy(&sa.sin_addr.s_addr, &ba, sizeof(sa.sin_addr.s_addr));
-	sa.sin_port = *(uint16_t *) &ba.b[4];
+	memcpy(&sa.sin_port, &ba.b[4], sizeof(sa.sin_port));
 	if (connect(sk, (struct sockaddr *) &sa, sizeof(sa)) < 0) {
 		syslog(LOG_ERR, "Can't connect: %s (%d)",
 						strerror(errno), errno);
-- 
1.7.0.4

--
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