[Spice-commits] server/tests

Frediano Ziglio fziglio at kemper.freedesktop.org
Wed May 18 13:52:45 UTC 2016


 server/tests/stream-test.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit fa0c32f120633f8cd099b0f6c1de47de904b5714
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Sun May 15 17:12:16 2016 +0100

    remove a warning building a test
    
    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.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/server/tests/stream-test.c b/server/tests/stream-test.c
index 6317796..623a394 100644
--- a/server/tests/stream-test.c
+++ b/server/tests/stream-test.c
@@ -63,7 +63,7 @@ sock_fd_read(int sock, void *buf, ssize_t bufsize, int *fd)
                 exit(1);
             }
 
-            *fd = *((int *) CMSG_DATA(cmsg));
+            memcpy(fd, CMSG_DATA(cmsg), sizeof(*fd));
         } else
             *fd = -1;
     } else {


More information about the Spice-commits mailing list