From 772c97bbad386c942a318aaf781578172addd764 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 17 Feb 2015 08:07:34 -0800 Subject: Fix aliasing --- src/core/iomgr/tcp_server_posix.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/core') diff --git a/src/core/iomgr/tcp_server_posix.c b/src/core/iomgr/tcp_server_posix.c index 355a040ff2..6a96163718 100644 --- a/src/core/iomgr/tcp_server_posix.c +++ b/src/core/iomgr/tcp_server_posix.c @@ -75,7 +75,11 @@ typedef struct { int fd; grpc_fd *emfd; grpc_tcp_server *server; - gpr_uint8 addr[GRPC_MAX_SOCKADDR_SIZE]; + union { + gpr_uint8 untyped[GRPC_MAX_SOCKADDR_SIZE]; + struct sockaddr sockaddr; + struct sockaddr_un un; + } addr; int addr_len; } server_port; @@ -125,9 +129,8 @@ void grpc_tcp_server_destroy(grpc_tcp_server *s) { /* delete ALL the things */ for (i = 0; i < s->nports; i++) { server_port *sp = &s->ports[i]; - if (((struct sockaddr *)sp->addr)->sa_family == AF_UNIX) { - struct sockaddr_un *un = (struct sockaddr_un *)sp->addr; - unlink(un->sun_path); + if (sp->addr.sockaddr.sa_family == AF_UNIX) { + unlink(sp->addr.un.sun_path); } grpc_fd_orphan(sp->emfd, NULL, NULL); } @@ -273,7 +276,7 @@ static int add_socket_to_server(grpc_tcp_server *s, int fd, sp->server = s; sp->fd = fd; sp->emfd = grpc_fd_create(fd); - memcpy(sp->addr, addr, addr_len); + memcpy(sp->addr.untyped, addr, addr_len); sp->addr_len = addr_len; GPR_ASSERT(sp->emfd); gpr_mu_unlock(&s->mu); -- cgit v1.2.3