提交 2d777045 编写于 作者: D Daniel P. Berrange

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: NDaniel P. Berrange <berrange@redhat.com>
上级 e57aaa6f
......@@ -31,12 +31,14 @@ int bind(int sockfd ATTRIBUTE_UNUSED,
const struct sockaddr *addr,
socklen_t addrlen ATTRIBUTE_UNUSED)
{
struct sockaddr_in *saddr = (struct sockaddr_in *)addr;
struct sockaddr_in saddr;
if (saddr->sin_port == htons(5900) ||
saddr->sin_port == htons(5904) ||
saddr->sin_port == htons(5905) ||
saddr->sin_port == htons(5906)) {
memcpy(&saddr, addr, sizeof(saddr));
if (saddr.sin_port == htons(5900) ||
saddr.sin_port == htons(5904) ||
saddr.sin_port == htons(5905) ||
saddr.sin_port == htons(5906)) {
errno = EADDRINUSE;
return -1;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册