[Spice-devel] [PATCH v2] remove a warning building a test

Christophe Fergeau cfergeau at redhat.com
Tue May 17 16:25:48 UTC 2016


On Tue, May 17, 2016 at 04:44:04PM +0100, Frediano Ziglio wrote:
> With my compile switches (which are mostly derived from RedHat spec
> file) I'm getting this warning:
> 
> stream-test.c: In function 'sock_fd_read':
> stream-test.c:66:43: warning: dereferencing type-punned pointer will
> break strict-aliasing rules [-Wstrict-aliasing]
>              *fd = *((int *) CMSG_DATA(cmsg));
>                                            ^
> 
> memcpy could decrease performance but as this is a test it's not
> an issue.

Can you avoid the warning with an additional (void *) cast?
*fd = *((int *) (void *) CMSG_DATA(cmsg))); ?

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20160517/cd76f364/attachment.sig>


More information about the Spice-devel mailing list