[PATCH 2/2] bluetooth: Fix alignment warning

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

 



'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/]




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

  Powered by Linux