Re: [pulseaudio-discuss] [PATCH 2/2] bluetooth: Fix alignment warning

2011-03-20 Thread Colin Guthrie
'Twas brillig, and Arun Raghavan at 19/03/11 12:01 did gyre and gimble:
 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.

I've not applied this specific patch as I've just run make update-sbc
and that's pulled in upstream bluez changes that also included a similar
patch (it just reuses ret variable rather than introducing a new fd
var, but is otherwise the same.

Col

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


-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mageia Contributor [http://www.mageia.org/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]

___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] [PATCH 2/2] bluetooth: Fix alignment warning

2011-03-19 Thread Arun Raghavan
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

___
pulseaudio-discuss mailing list
pulseaudio-discuss@mail.0pointer.de
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss