Unconditionally initialize sockaddrs in epoll linuxsocket (#9299)
Motivation: Compiling with -Werror,-Wuninitialized complains about the sockaddrs being uninitialized. I believe this is because the init function netty_unix_socket_initSockaddr is in a separate compilation unit. Since this code isn't on the criticial path, it's easy to just memset the variables rather than suppress the warning. Modification: Always clear the sockaddrs, even if they will be initialized later. Result: Able to compile with warnings turned on
This commit is contained in:
parent
df4e236de2
commit
dfa69f0980
@ -83,6 +83,8 @@ static void netty_epoll_linuxsocket_setInterface(JNIEnv* env, jclass clazz, jint
|
|||||||
socklen_t interfaceAddrSize;
|
socklen_t interfaceAddrSize;
|
||||||
struct sockaddr_in* interfaceIpAddr;
|
struct sockaddr_in* interfaceIpAddr;
|
||||||
|
|
||||||
|
memset(&interfaceAddr, 0, sizeof(interfaceAddr));
|
||||||
|
|
||||||
if (ipv6 == JNI_TRUE) {
|
if (ipv6 == JNI_TRUE) {
|
||||||
if (interfaceIndex == -1) {
|
if (interfaceIndex == -1) {
|
||||||
netty_unix_errors_throwIOException(env, "Unable to find network index");
|
netty_unix_errors_throwIOException(env, "Unable to find network index");
|
||||||
@ -168,6 +170,9 @@ static void netty_epoll_linuxsocket_joinGroup(JNIEnv* env, jclass clazz, jint fd
|
|||||||
struct sockaddr_in6* groupIp6Addr;
|
struct sockaddr_in6* groupIp6Addr;
|
||||||
struct ipv6_mreq mreq6;
|
struct ipv6_mreq mreq6;
|
||||||
|
|
||||||
|
memset(&groupAddr, 0, sizeof(groupAddr));
|
||||||
|
memset(&interfaceAddr, 0, sizeof(interfaceAddr));
|
||||||
|
|
||||||
if (netty_unix_socket_initSockaddr(env, ipv6, groupAddress, scopeId, 0, &groupAddr, &groupAddrSize) == -1) {
|
if (netty_unix_socket_initSockaddr(env, ipv6, groupAddress, scopeId, 0, &groupAddr, &groupAddrSize) == -1) {
|
||||||
netty_unix_errors_throwIOException(env, "Could not init sockaddr for groupAddress");
|
netty_unix_errors_throwIOException(env, "Could not init sockaddr for groupAddress");
|
||||||
return;
|
return;
|
||||||
@ -218,6 +223,10 @@ static void netty_epoll_linuxsocket_joinSsmGroup(JNIEnv* env, jclass clazz, jint
|
|||||||
|
|
||||||
struct group_source_req mreq6;
|
struct group_source_req mreq6;
|
||||||
|
|
||||||
|
memset(&groupAddr, 0, sizeof(groupAddr));
|
||||||
|
memset(&sourceAddr, 0, sizeof(sourceAddr));
|
||||||
|
memset(&interfaceAddr, 0, sizeof(interfaceAddr));
|
||||||
|
|
||||||
if (netty_unix_socket_initSockaddr(env, ipv6, groupAddress, scopeId, 0, &groupAddr, &groupAddrSize) == -1) {
|
if (netty_unix_socket_initSockaddr(env, ipv6, groupAddress, scopeId, 0, &groupAddr, &groupAddrSize) == -1) {
|
||||||
netty_unix_errors_throwIOException(env, "Could not init sockaddr for groupAddress");
|
netty_unix_errors_throwIOException(env, "Could not init sockaddr for groupAddress");
|
||||||
return;
|
return;
|
||||||
@ -271,6 +280,9 @@ static void netty_epoll_linuxsocket_leaveGroup(JNIEnv* env, jclass clazz, jint f
|
|||||||
struct sockaddr_in6* groupIp6Addr;
|
struct sockaddr_in6* groupIp6Addr;
|
||||||
struct ipv6_mreq mreq6;
|
struct ipv6_mreq mreq6;
|
||||||
|
|
||||||
|
memset(&groupAddr, 0, sizeof(groupAddr));
|
||||||
|
memset(&interfaceAddr, 0, sizeof(interfaceAddr));
|
||||||
|
|
||||||
if (netty_unix_socket_initSockaddr(env, ipv6, groupAddress, scopeId, 0, &groupAddr, &groupAddrSize) == -1) {
|
if (netty_unix_socket_initSockaddr(env, ipv6, groupAddress, scopeId, 0, &groupAddr, &groupAddrSize) == -1) {
|
||||||
netty_unix_errors_throwIOException(env, "Could not init sockaddr for groupAddress");
|
netty_unix_errors_throwIOException(env, "Could not init sockaddr for groupAddress");
|
||||||
return;
|
return;
|
||||||
@ -320,6 +332,10 @@ static void netty_epoll_linuxsocket_leaveSsmGroup(JNIEnv* env, jclass clazz, jin
|
|||||||
struct ip_mreq_source mreq;
|
struct ip_mreq_source mreq;
|
||||||
struct group_source_req mreq6;
|
struct group_source_req mreq6;
|
||||||
|
|
||||||
|
memset(&groupAddr, 0, sizeof(groupAddr));
|
||||||
|
memset(&sourceAddr, 0, sizeof(sourceAddr));
|
||||||
|
memset(&interfaceAddr, 0, sizeof(interfaceAddr));
|
||||||
|
|
||||||
|
|
||||||
if (netty_unix_socket_initSockaddr(env, ipv6, groupAddress, scopeId, 0, &groupAddr, &groupAddrSize) == -1) {
|
if (netty_unix_socket_initSockaddr(env, ipv6, groupAddress, scopeId, 0, &groupAddr, &groupAddrSize) == -1) {
|
||||||
netty_unix_errors_throwIOException(env, "Could not init sockaddr for groupAddress");
|
netty_unix_errors_throwIOException(env, "Could not init sockaddr for groupAddress");
|
||||||
@ -366,6 +382,9 @@ static void netty_epoll_linuxsocket_leaveSsmGroup(JNIEnv* env, jclass clazz, jin
|
|||||||
static void netty_epoll_linuxsocket_setTcpMd5Sig(JNIEnv* env, jclass clazz, jint fd, jboolean ipv6, jbyteArray address, jint scopeId, jbyteArray key) {
|
static void netty_epoll_linuxsocket_setTcpMd5Sig(JNIEnv* env, jclass clazz, jint fd, jboolean ipv6, jbyteArray address, jint scopeId, jbyteArray key) {
|
||||||
struct sockaddr_storage addr;
|
struct sockaddr_storage addr;
|
||||||
socklen_t addrSize;
|
socklen_t addrSize;
|
||||||
|
|
||||||
|
memset(&addr, 0, sizeof(addr));
|
||||||
|
|
||||||
if (netty_unix_socket_initSockaddr(env, ipv6, address, scopeId, 0, &addr, &addrSize) == -1) {
|
if (netty_unix_socket_initSockaddr(env, ipv6, address, scopeId, 0, &addr, &addrSize) == -1) {
|
||||||
netty_unix_errors_throwIOException(env, "Could not init sockaddr");
|
netty_unix_errors_throwIOException(env, "Could not init sockaddr");
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user