[pulseaudio-discuss] [PATCH 2/2] bluetooth: Fix alignment warning
Arun Raghavan
arun.raghavan at collabora.co.uk
Sat Mar 19 05:01:51 PDT 2011
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
More information about the pulseaudio-discuss
mailing list