Merge pull request #1799 from zerotier/cleanup/suggest-braces

Fix warning: suggest braces around initialization of subobject
This commit is contained in:
Adam Ierymenko 2022-12-01 11:03:26 -05:00 committed by GitHub
commit a25da7f771
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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)