diff --git a/adb/adb_auth_client.cpp b/adb/adb_auth_client.cpp index 463b4968a..c4ffc85a2 100644 --- a/adb/adb_auth_client.cpp +++ b/adb/adb_auth_client.cpp @@ -228,13 +228,13 @@ void adb_auth_confirm_key(unsigned char *key, size_t len, atransport *t) static void adb_auth_listener(int fd, unsigned events, void *data) { - struct sockaddr addr; + sockaddr_storage addr; socklen_t alen; int s; alen = sizeof(addr); - s = adb_socket_accept(fd, &addr, &alen); + s = adb_socket_accept(fd, reinterpret_cast(&addr), &alen); if (s < 0) { D("Failed to accept: errno=%d", errno); return; diff --git a/adb/adb_listeners.cpp b/adb/adb_listeners.cpp index 1b75090a9..94b08c78c 100644 --- a/adb/adb_listeners.cpp +++ b/adb/adb_listeners.cpp @@ -34,9 +34,10 @@ static alistener listener_list = { static void ss_listener_event_func(int _fd, unsigned ev, void *_l) { if (ev & FDE_READ) { - struct sockaddr addr; - socklen_t alen = sizeof(addr); - int fd = adb_socket_accept(_fd, &addr, &alen); + sockaddr_storage ss; + sockaddr* addrp = reinterpret_cast(&ss); + socklen_t alen = sizeof(ss); + int fd = adb_socket_accept(_fd, addrp, &alen); if (fd < 0) return; int rcv_buf_size = CHUNK_SIZE; @@ -58,12 +59,13 @@ static void listener_event_func(int _fd, unsigned ev, void* _l) asocket *s; if (ev & FDE_READ) { - struct sockaddr addr; + sockaddr_storage ss; + sockaddr* addrp = reinterpret_cast(&ss); socklen_t alen; int fd; - alen = sizeof(addr); - fd = adb_socket_accept(_fd, &addr, &alen); + alen = sizeof(ss); + fd = adb_socket_accept(_fd, addrp, &alen); if (fd < 0) { return; } @@ -79,7 +81,7 @@ static void listener_event_func(int _fd, unsigned ev, void* _l) } } -static void free_listener(alistener* l) +static void free_listener(alistener* l) { if (l->next) { l->next->prev = l->prev; diff --git a/adb/jdwp_service.cpp b/adb/jdwp_service.cpp index cc2d44e08..3c812cce7 100644 --- a/adb/jdwp_service.cpp +++ b/adb/jdwp_service.cpp @@ -460,11 +460,11 @@ jdwp_control_init( JdwpControl* control, const char* sockname, int socknamelen ) { - struct sockaddr_un addr; - socklen_t addrlen; - int s; - int maxpath = sizeof(addr.sun_path); - int pathlen = socknamelen; + sockaddr_un addr; + socklen_t addrlen; + int s; + int maxpath = sizeof(addr.sun_path); + int pathlen = socknamelen; if (pathlen >= maxpath) { D( "vm debug control socket name too long (%d extra chars)", @@ -485,7 +485,7 @@ jdwp_control_init( JdwpControl* control, addrlen = (pathlen + sizeof(addr.sun_family)); - if (bind(s, (struct sockaddr*)&addr, addrlen) < 0) { + if (bind(s, reinterpret_cast(&addr), addrlen) < 0) { D( "could not bind vm debug control socket: %d: %s", errno, strerror(errno) ); adb_close(s); @@ -523,13 +523,14 @@ jdwp_control_event( int s, unsigned events, void* _control ) JdwpControl* control = (JdwpControl*) _control; if (events & FDE_READ) { - struct sockaddr addr; - socklen_t addrlen = sizeof(addr); - int s = -1; - JdwpProcess* proc; + sockaddr_storage ss; + sockaddr* addrp = reinterpret_cast(&ss); + socklen_t addrlen = sizeof(ss); + int s = -1; + JdwpProcess* proc; do { - s = adb_socket_accept( control->listen_socket, &addr, &addrlen ); + s = adb_socket_accept(control->listen_socket, addrp, &addrlen); if (s < 0) { if (errno == EINTR) continue; diff --git a/adb/transport_local.cpp b/adb/transport_local.cpp index bf0cc3c67..8174b3771 100644 --- a/adb/transport_local.cpp +++ b/adb/transport_local.cpp @@ -143,7 +143,8 @@ static void *client_socket_thread(void *x) static void *server_socket_thread(void * arg) { int serverfd, fd; - struct sockaddr addr; + sockaddr_storage ss; + sockaddr *addrp = reinterpret_cast(&ss); socklen_t alen; int port = (int) (uintptr_t) arg; @@ -162,9 +163,9 @@ static void *server_socket_thread(void * arg) close_on_exec(serverfd); } - alen = sizeof(addr); + alen = sizeof(ss); D("server: trying to get new connection from %d", port); - fd = adb_socket_accept(serverfd, &addr, &alen); + fd = adb_socket_accept(serverfd, addrp, &alen); if(fd >= 0) { D("server: new connection on fd %d", fd); close_on_exec(fd); diff --git a/debuggerd/debuggerd.cpp b/debuggerd/debuggerd.cpp index 884d4d5e5..0afa89577 100644 --- a/debuggerd/debuggerd.cpp +++ b/debuggerd/debuggerd.cpp @@ -518,11 +518,12 @@ static int do_server() { ALOGI("debuggerd: starting\n"); for (;;) { - sockaddr addr; - socklen_t alen = sizeof(addr); + sockaddr_storage ss; + sockaddr* addrp = reinterpret_cast(&ss); + socklen_t alen = sizeof(ss); ALOGV("waiting for connection\n"); - int fd = accept(s, &addr, &alen); + int fd = accept(s, addrp, &alen); if (fd < 0) { ALOGV("accept failed: %s\n", strerror(errno)); continue; diff --git a/libsysutils/src/SocketListener.cpp b/libsysutils/src/SocketListener.cpp index 3011ed7a8..168899c56 100644 --- a/libsysutils/src/SocketListener.cpp +++ b/libsysutils/src/SocketListener.cpp @@ -199,13 +199,14 @@ void SocketListener::runListener() { continue; } if (mListen && FD_ISSET(mSock, &read_fds)) { - struct sockaddr addr; + sockaddr_storage ss; + sockaddr* addrp = reinterpret_cast(&ss); socklen_t alen; int c; do { - alen = sizeof(addr); - c = accept(mSock, &addr, &alen); + alen = sizeof(ss); + c = accept(mSock, addrp, &alen); SLOGV("%s got %d from accept", mSocketName, c); } while (c < 0 && errno == EINTR); if (c < 0) { diff --git a/lmkd/lmkd.c b/lmkd/lmkd.c index 7bbc81119..50bf6a4d5 100644 --- a/lmkd/lmkd.c +++ b/lmkd/lmkd.c @@ -410,7 +410,8 @@ static void ctrl_data_handler(uint32_t events) { } static void ctrl_connect_handler(uint32_t events __unused) { - struct sockaddr addr; + struct sockaddr_storage ss; + struct sockaddr *addrp = (struct sockaddr *)&ss; socklen_t alen; struct epoll_event epev; @@ -419,8 +420,8 @@ static void ctrl_connect_handler(uint32_t events __unused) { ctrl_dfd_reopened = 1; } - alen = sizeof(addr); - ctrl_dfd = accept(ctrl_lfd, &addr, &alen); + alen = sizeof(ss); + ctrl_dfd = accept(ctrl_lfd, addrp, &alen); if (ctrl_dfd < 0) { ALOGE("lmkd control socket accept failed; errno=%d", errno);