提交 9fec27be 编写于 作者: M Mark McLoughlin

Fix bridge.c warnings with gcc-4.4

 bridge.c: In function 'brSetInetAddr':
 bridge.c:665: error: dereferencing pointer '({anonymous})' does break strict-aliasing rules
 bridge.c:665: note: initialized from here
 bridge.c:666: error: dereferencing pointer '({anonymous})' does break strict-aliasing rules
 bridge.c:666: note: initialized from here

Fix qemud.c warnings with gcc-4.4

 qemud.c: In function ‘remoteListenTCP’:
 qemud.c:675: error: dereferencing pointer ‘sa.72’ does break strict-aliasing rules
 qemud.c:675: note: initialized from here
 qemud.c:678: error: dereferencing pointer ‘sa.73’ does break strict-aliasing rules
 qemud.c:678: note: initialized from here
上级 7d2b7ad5
Fri Feb 13 19:03:30 IST 2009 Mark McLoughlin <markmc@redhat.com>
* qemud/qemud.c: fix gcc-4.4 warnings
Fri Feb 13 19:03:25 IST 2009 Mark McLoughlin <markmc@redhat.com>
* src/bridge.c: fix gcc-4.4 warnings
Fri Feb 13 16:50:35 GMT 2009 John Levon <john.levon@sun.com> Fri Feb 13 16:50:35 GMT 2009 John Levon <john.levon@sun.com>
* src/xend_internal.c: xend in 3.3 grew a couple of new options * src/xend_internal.c: xend in 3.3 grew a couple of new options
......
...@@ -649,9 +649,16 @@ remoteListenTCP (struct qemud_server *server, ...@@ -649,9 +649,16 @@ remoteListenTCP (struct qemud_server *server,
return -1; return -1;
for (i = 0; i < nfds; ++i) { for (i = 0; i < nfds; ++i) {
struct sockaddr_storage sa; union {
struct sockaddr_storage sa_stor;
struct sockaddr sa;
struct sockaddr_in sa_in;
#ifdef AF_INET6
struct sockaddr_in6 sa_in6;
#endif
} s;
char ebuf[1024]; char ebuf[1024];
socklen_t salen = sizeof(sa); socklen_t salen = sizeof(s);
if (VIR_ALLOC(sock) < 0) { if (VIR_ALLOC(sock) < 0) {
VIR_ERROR(_("remoteListenTCP: calloc: %s"), VIR_ERROR(_("remoteListenTCP: calloc: %s"),
...@@ -668,14 +675,14 @@ remoteListenTCP (struct qemud_server *server, ...@@ -668,14 +675,14 @@ remoteListenTCP (struct qemud_server *server,
sock->type = type; sock->type = type;
sock->auth = auth; sock->auth = auth;
if (getsockname(sock->fd, (struct sockaddr *)(&sa), &salen) < 0) if (getsockname(sock->fd, &s.sa, &salen) < 0)
goto cleanup; goto cleanup;
if (sa.ss_family == AF_INET) if (s.sa.sa_family == AF_INET) {
sock->port = htons(((struct sockaddr_in*)&sa)->sin_port); sock->port = htons(s.sa_in.sin_port);
#ifdef AF_INET6 #ifdef AF_INET6
else if (sa.ss_family == AF_INET6) } else if (s.sa.sa_family == AF_INET6)
sock->port = htons(((struct sockaddr_in6*)&sa)->sin6_port); sock->port = htons(s.sa_in6.sin6_port);
#endif #endif
else else
sock->port = -1; sock->port = -1;
......
...@@ -642,6 +642,10 @@ brSetInetAddr(brControl *ctl, ...@@ -642,6 +642,10 @@ brSetInetAddr(brControl *ctl,
int cmd, int cmd,
const char *addr) const char *addr)
{ {
union {
struct sockaddr sa;
struct sockaddr_in sa_in;
} s;
struct ifreq ifr; struct ifreq ifr;
struct in_addr inaddr; struct in_addr inaddr;
int len, ret; int len, ret;
...@@ -662,8 +666,10 @@ brSetInetAddr(brControl *ctl, ...@@ -662,8 +666,10 @@ brSetInetAddr(brControl *ctl,
else if (ret == 0) else if (ret == 0)
return EINVAL; return EINVAL;
((struct sockaddr_in *)&ifr.ifr_data)->sin_family = AF_INET; s.sa_in.sin_family = AF_INET;
((struct sockaddr_in *)&ifr.ifr_data)->sin_addr = inaddr; s.sa_in.sin_addr = inaddr;
ifr.ifr_addr = s.sa;
if (ioctl(ctl->fd, cmd, &ifr) < 0) if (ioctl(ctl->fd, cmd, &ifr) < 0)
return errno; return errno;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册