Avoid cast alignment warnings in port allocator test

To avoid

virportallocatortest.c: In function 'bind':
virportallocatortest.c:34:33: warning: cast increases required alignment of target type [-Wcast-align]
     struct sockaddr_in *saddr = (struct sockaddr_in *)addr;
                                 ^

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrange 2013-04-03 15:55:37 +01:00
parent e57aaa6fcf
commit 2d77704509

View File

@ -31,12 +31,14 @@ int bind(int sockfd ATTRIBUTE_UNUSED,
const struct sockaddr *addr, const struct sockaddr *addr,
socklen_t addrlen ATTRIBUTE_UNUSED) socklen_t addrlen ATTRIBUTE_UNUSED)
{ {
struct sockaddr_in *saddr = (struct sockaddr_in *)addr; struct sockaddr_in saddr;
if (saddr->sin_port == htons(5900) || memcpy(&saddr, addr, sizeof(saddr));
saddr->sin_port == htons(5904) ||
saddr->sin_port == htons(5905) || if (saddr.sin_port == htons(5900) ||
saddr->sin_port == htons(5906)) { saddr.sin_port == htons(5904) ||
saddr.sin_port == htons(5905) ||
saddr.sin_port == htons(5906)) {
errno = EADDRINUSE; errno = EADDRINUSE;
return -1; return -1;
} }