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,20 +175,16 @@ 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);
if(env->ExceptionCheck() || inetAddressObject == NULL)
{
LOGE("Error creating new inet address");
return NULL;
}
return NULL;
}
else
jobject inetAddressObject = newInetAddress(env, addr);
if(env->ExceptionCheck() || inetAddressObject == NULL)
{
LOGE("Error creating new inet address");
return NULL;
}

View File

@ -233,11 +233,12 @@ namespace {
case ZT_EVENT_TRACE: {
LOGV("Trace Event");
// call onTrace()
if (data != NULL) {
const char *message = (const char *) data;
jstring messageStr = env->NewStringUTF(message);
env->CallVoidMethod(ref->eventListener, EventListener_onTrace_method, messageStr);
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: