Fix warning: suggest braces around initialization of subobject

This commit is contained in:
Brenton Bostick 2022-11-30 12:44:32 -05:00
parent 85da0b419c
commit 9ac2cfe611

View File

@ -573,7 +573,26 @@ namespace {
return true;
}
struct sockaddr_storage nullAddress = {0};
//
// was:
// struct sockaddr_storage nullAddress = {0};
//
// but was getting this warning:
// warning: suggest braces around initialization of subobject
//
// when building ZeroTierOne
//
struct sockaddr_storage nullAddress;
//
// It is possible to assume knowledge about internals of sockaddr_storage and construct
// correct 0-initializer, but it is simpler to just treat sockaddr_storage as opaque and
// use memset here to fill with 0
//
// This is also done in InetAddress.hpp for InetAddress
//
memset(&nullAddress, 0, sizeof(sockaddr_storage));
jobject remoteAddressObj = NULL;
if(memcmp(remoteAddress, &nullAddress, sizeof(sockaddr_storage)) != 0)