[igt-dev] [PATCH i-g-t] tests/i915/gem_ctx_persistence: fix gcc warning

Petri Latvala petri.latvala at intel.com
Tue Nov 12 08:14:17 UTC 2019


On Mon, Nov 11, 2019 at 04:23:01PM +0200, Juha-Pekka Heikkila wrote:
> casting unsigned char pointer to int pointer causes gcc to be unhappy with
> comment: "warning: dereferencing type-punned pointer will break
> strict-aliasing rules"
> 
> Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>

Deja-vu'd by, no I mean

Reviewed-by: Petri Latvala <petri.latvala at intel.com>


> ---
>  tests/i915/gem_ctx_persistence.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tests/i915/gem_ctx_persistence.c b/tests/i915/gem_ctx_persistence.c
> index a582e64..2525a85 100644
> --- a/tests/i915/gem_ctx_persistence.c
> +++ b/tests/i915/gem_ctx_persistence.c
> @@ -420,7 +420,7 @@ static void sendfd(int socket, int fd)
>  	cmsg->cmsg_level = SOL_SOCKET;
>  	cmsg->cmsg_type = SCM_RIGHTS;
>  	cmsg->cmsg_len = msg.msg_controllen;
> -	*(int *)CMSG_DATA(cmsg) = fd;
> +	memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd));
>  
>  	igt_assert(sendmsg(socket, &msg, 0) != -1);
>  }
> -- 
> 2.7.4
> 
> _______________________________________________
> igt-dev mailing list
> igt-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev


More information about the igt-dev mailing list