[PATCH 2/2] bluetooth: Fix alignment warning

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

 



While it seems to be common practice to just work around the cast to
integer and assume alignment is fine, let's play it safe and do it right
by memcpy'ing.
---
 src/modules/bluetooth/ipc.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/modules/bluetooth/ipc.c b/src/modules/bluetooth/ipc.c
index dcecad8..fdca7a3 100644
--- a/src/modules/bluetooth/ipc.c
+++ b/src/modules/bluetooth/ipc.c
@@ -106,8 +106,11 @@ int bt_audio_service_get_data_fd(int sk)
 	for (cmsg = CMSG_FIRSTHDR(&msgh); cmsg != NULL;
 			cmsg = CMSG_NXTHDR(&msgh, cmsg)) {
 		if (cmsg->cmsg_level == SOL_SOCKET
-				&& cmsg->cmsg_type == SCM_RIGHTS)
-			return (*(int *) CMSG_DATA(cmsg));
+				&& cmsg->cmsg_type == SCM_RIGHTS) {
+			int fd;
+			memcpy(&fd, CMSG_DATA(cmsg), sizeof(int));
+			return fd;
+		}
 	}
 
 	errno = EINVAL;
-- 
1.7.4.1




[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux