invert logic in a couple of places and return early

This commit is contained in:
Brenton Bostick 2023-02-01 11:19:01 -05:00
parent 4ee73fa272
commit e1c16a8e68
2 changed files with 12 additions and 15 deletions

View File

@ -175,22 +175,18 @@ jobject newInetSocketAddress(JNIEnv *env, const sockaddr_storage &addr)
{
LOGV("newInetSocketAddress Called");
jobject inetAddressObject = NULL;
if(addr.ss_family != 0)
if(addr.ss_family == 0)
{
inetAddressObject = newInetAddress(env, addr);
return NULL;
}
jobject inetAddressObject = newInetAddress(env, addr);
if(env->ExceptionCheck() || inetAddressObject == NULL)
{
LOGE("Error creating new inet address");
return NULL;
}
}
else
{
return NULL;
}
int port = 0;
switch(addr.ss_family)

View File

@ -233,12 +233,13 @@ namespace {
case ZT_EVENT_TRACE: {
LOGV("Trace Event");
// call onTrace()
if (data != NULL) {
if (data == NULL) {
break;
}
const char *message = (const char *) data;
jstring messageStr = env->NewStringUTF(message);
env->CallVoidMethod(ref->eventListener, EventListener_onTrace_method, messageStr);
}
}
break;
case ZT_EVENT_USER_MESSAGE:
case ZT_EVENT_REMOTE_TRACE: