[c23,client] replace NULL with nullptr

This commit is contained in:
Armin Novak
2026-02-26 14:35:00 +01:00
parent 20b4cb6edc
commit 465a6353d5
69 changed files with 1544 additions and 1517 deletions

View File

@@ -51,7 +51,7 @@ UINT android_cliprdr_send_client_format_list(CliprdrClientContext* cliprdr)
if (!afc || !afc->cliprdr)
return ERROR_INVALID_PARAMETER;
pFormatIds = NULL;
pFormatIds = nullptr;
numFormats = ClipboardGetFormatIds(afc->clipboard, &pFormatIds);
formats = (CLIPRDR_FORMAT*)calloc(numFormats, sizeof(CLIPRDR_FORMAT));
@@ -63,7 +63,7 @@ UINT android_cliprdr_send_client_format_list(CliprdrClientContext* cliprdr)
formatId = pFormatIds[index];
formatName = ClipboardGetFormatName(afc->clipboard, formatId);
formats[index].formatId = formatId;
formats[index].formatName = NULL;
formats[index].formatName = nullptr;
if ((formatId > CF_MAX) && formatName)
{
@@ -222,7 +222,7 @@ static UINT android_cliprdr_server_format_list(CliprdrClientContext* cliprdr,
free(afc->serverFormats[index].formatName);
free(afc->serverFormats);
afc->serverFormats = NULL;
afc->serverFormats = nullptr;
afc->numServerFormats = 0;
}
@@ -238,7 +238,7 @@ static UINT android_cliprdr_server_format_list(CliprdrClientContext* cliprdr,
for (UINT32 index = 0; index < afc->numServerFormats; index++)
{
afc->serverFormats[index].formatId = formatList->formats[index].formatId;
afc->serverFormats[index].formatName = NULL;
afc->serverFormats[index].formatName = nullptr;
if (formatList->formats[index].formatName)
{
@@ -352,7 +352,7 @@ android_cliprdr_server_format_data_request(CliprdrClientContext* cliprdr,
{
response.common.msgFlags = CB_RESPONSE_FAIL;
response.common.dataLen = 0;
response.requestedFormatData = NULL;
response.requestedFormatData = nullptr;
}
rc = cliprdr->ClientFormatDataResponse(cliprdr, &response);
@@ -369,7 +369,7 @@ static UINT
android_cliprdr_server_format_data_response(CliprdrClientContext* cliprdr,
const CLIPRDR_FORMAT_DATA_RESPONSE* formatDataResponse)
{
CLIPRDR_FORMAT* format = NULL;
CLIPRDR_FORMAT* format = nullptr;
if (!cliprdr || !formatDataResponse)
return ERROR_INVALID_PARAMETER;
@@ -409,7 +409,7 @@ android_cliprdr_server_format_data_response(CliprdrClientContext* cliprdr,
if ((formatId == CF_TEXT) || (formatId == CF_UNICODETEXT))
{
JNIEnv* env = NULL;
JNIEnv* env = nullptr;
formatId = ClipboardRegisterFormat(afc->clipboard, "text/plain");
char* data = (char*)ClipboardGetData(afc->clipboard, formatId, &size);
jboolean attached = jni_attach_thread(&env);
@@ -462,7 +462,7 @@ BOOL android_cliprdr_init(androidContext* afc, CliprdrClientContext* cliprdr)
if (!afc || !cliprdr)
return FALSE;
if (!(hevent = CreateEvent(NULL, TRUE, FALSE, NULL)))
if (!(hevent = CreateEvent(nullptr, TRUE, FALSE, nullptr)))
return FALSE;
if (!(clipboard = ClipboardCreate()))
@@ -493,8 +493,8 @@ BOOL android_cliprdr_uninit(androidContext* afc, CliprdrClientContext* cliprdr)
if (!afc || !cliprdr)
return FALSE;
cliprdr->custom = NULL;
afc->cliprdr = NULL;
cliprdr->custom = nullptr;
afc->cliprdr = nullptr;
ClipboardDestroy(afc->clipboard);
(void)CloseHandle(afc->clipboardRequestEvent);
return TRUE;

View File

@@ -55,7 +55,7 @@ static ANDROID_EVENT* android_peek_event(ANDROID_EVENT_QUEUE* queue)
ANDROID_EVENT* event;
if (queue->count < 1)
return NULL;
return nullptr;
event = queue->events[0];
return event;
@@ -66,7 +66,7 @@ static ANDROID_EVENT* android_pop_event(ANDROID_EVENT_QUEUE* queue)
ANDROID_EVENT* event;
if (queue->count < 1)
return NULL;
return nullptr;
event = queue->events[0];
(queue->count)--;
@@ -160,12 +160,12 @@ HANDLE android_get_handle(freerdp* inst)
androidContext* aCtx;
if (!inst || !inst->context)
return NULL;
return nullptr;
aCtx = (androidContext*)inst->context;
if (!aCtx->event_queue || !aCtx->event_queue->isSet)
return NULL;
return nullptr;
return aCtx->event_queue->isSet;
}
@@ -199,7 +199,7 @@ ANDROID_EVENT_KEY* android_event_key_new(int flags, UINT16 scancode)
ANDROID_EVENT_KEY* event = (ANDROID_EVENT_KEY*)calloc(1, sizeof(ANDROID_EVENT_KEY));
if (!event)
return NULL;
return nullptr;
event->type = EVENT_TYPE_KEY;
event->flags = flags;
@@ -218,7 +218,7 @@ ANDROID_EVENT_KEY* android_event_unicodekey_new(UINT16 flags, UINT16 key)
event = (ANDROID_EVENT_KEY*)calloc(1, sizeof(ANDROID_EVENT_KEY));
if (!event)
return NULL;
return nullptr;
event->type = EVENT_TYPE_KEY_UNICODE;
event->flags = flags;
@@ -237,7 +237,7 @@ ANDROID_EVENT_CURSOR* android_event_cursor_new(UINT16 flags, UINT16 x, UINT16 y)
event = (ANDROID_EVENT_CURSOR*)calloc(1, sizeof(ANDROID_EVENT_CURSOR));
if (!event)
return NULL;
return nullptr;
event->type = EVENT_TYPE_CURSOR;
event->x = x;
@@ -257,7 +257,7 @@ ANDROID_EVENT* android_event_disconnect_new(void)
event = (ANDROID_EVENT*)calloc(1, sizeof(ANDROID_EVENT));
if (!event)
return NULL;
return nullptr;
event->type = EVENT_TYPE_DISCONNECT;
return event;
@@ -274,7 +274,7 @@ ANDROID_EVENT_CLIPBOARD* android_event_clipboard_new(const void* data, size_t da
event = (ANDROID_EVENT_CLIPBOARD*)calloc(1, sizeof(ANDROID_EVENT_CLIPBOARD));
if (!event)
return NULL;
return nullptr;
event->type = EVENT_TYPE_CLIPBOARD;
@@ -285,7 +285,7 @@ ANDROID_EVENT_CLIPBOARD* android_event_clipboard_new(const void* data, size_t da
if (!event->data)
{
free(event);
return NULL;
return nullptr;
}
memcpy(event->data, data, data_length);
@@ -318,7 +318,7 @@ BOOL android_event_queue_init(freerdp* inst)
queue->size = 16;
queue->count = 0;
queue->isSet = CreateEventA(NULL, TRUE, FALSE, NULL);
queue->isSet = CreateEventA(nullptr, TRUE, FALSE, nullptr);
if (!queue->isSet)
{
@@ -356,13 +356,13 @@ void android_event_queue_uninit(freerdp* inst)
if (queue->isSet)
{
(void)CloseHandle(queue->isSet);
queue->isSet = NULL;
queue->isSet = nullptr;
}
if (queue->events)
{
free(queue->events);
queue->events = NULL;
queue->events = nullptr;
queue->size = 0;
queue->count = 0;
}

View File

@@ -419,7 +419,7 @@ static int android_freerdp_run(freerdp* instance)
DWORD count;
DWORD status = WAIT_FAILED;
HANDLE handles[MAXIMUM_WAIT_OBJECTS];
HANDLE inputEvent = NULL;
HANDLE inputEvent = nullptr;
const rdpSettings* settings = instance->context->settings;
rdpContext* context = instance->context;
@@ -536,7 +536,7 @@ static BOOL android_client_new(freerdp* instance, rdpContext* context)
instance->GatewayAuthenticate = android_gw_authenticate;
instance->VerifyCertificateEx = android_verify_certificate_ex;
instance->VerifyChangedCertificateEx = android_verify_changed_certificate_ex;
instance->LogonErrorInfo = NULL;
instance->LogonErrorInfo = nullptr;
return TRUE;
}
@@ -556,13 +556,13 @@ static int RdpClientEntry(RDP_CLIENT_ENTRY_POINTS* pEntryPoints)
pEntryPoints->Version = RDP_CLIENT_INTERFACE_VERSION;
pEntryPoints->Size = sizeof(RDP_CLIENT_ENTRY_POINTS_V1);
pEntryPoints->GlobalInit = NULL;
pEntryPoints->GlobalUninit = NULL;
pEntryPoints->GlobalInit = nullptr;
pEntryPoints->GlobalUninit = nullptr;
pEntryPoints->ContextSize = sizeof(androidContext);
pEntryPoints->ClientNew = android_client_new;
pEntryPoints->ClientFree = android_client_free;
pEntryPoints->ClientStart = NULL;
pEntryPoints->ClientStop = NULL;
pEntryPoints->ClientStart = nullptr;
pEntryPoints->ClientStop = nullptr;
return 0;
}
@@ -590,7 +590,7 @@ JNIEXPORT jlong JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp
{
WLog_FATAL(TAG, "Failed to load class references %s=%p, %s=%p", JAVA_CONTEXT_CLASS,
(void*)contextClass, JAVA_FILE_CLASS, (void*)fileClass);
return (jlong)NULL;
return (jlong) nullptr;
}
getFilesDirID =
@@ -599,7 +599,7 @@ JNIEXPORT jlong JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp
if (!getFilesDirID)
{
WLog_FATAL(TAG, "Failed to find method ID getFilesDir ()L" JAVA_FILE_CLASS ";");
return (jlong)NULL;
return (jlong) nullptr;
}
getAbsolutePathID =
@@ -608,7 +608,7 @@ JNIEXPORT jlong JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp
if (!getAbsolutePathID)
{
WLog_FATAL(TAG, "Failed to find method ID getAbsolutePath ()Ljava/lang/String;");
return (jlong)NULL;
return (jlong) nullptr;
}
filesDirObj = (*env)->CallObjectMethod(env, context, getFilesDirID);
@@ -616,7 +616,7 @@ JNIEXPORT jlong JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp
if (!filesDirObj)
{
WLog_FATAL(TAG, "Failed to call getFilesDir");
return (jlong)NULL;
return (jlong) nullptr;
}
path = (*env)->CallObjectMethod(env, filesDirObj, getAbsolutePathID);
@@ -624,7 +624,7 @@ JNIEXPORT jlong JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp
if (!path)
{
WLog_FATAL(TAG, "Failed to call getAbsolutePath");
return (jlong)NULL;
return (jlong) nullptr;
}
raw = (*env)->GetStringUTFChars(env, path, 0);
@@ -632,7 +632,7 @@ JNIEXPORT jlong JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp
if (!raw)
{
WLog_FATAL(TAG, "Failed to get C string from java string");
return (jlong)NULL;
return (jlong) nullptr;
}
envStr = _strdup(raw);
@@ -641,7 +641,7 @@ JNIEXPORT jlong JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp
if (!envStr)
{
WLog_FATAL(TAG, "_strdup(%s) failed", raw);
return (jlong)NULL;
return (jlong) nullptr;
}
if (setenv("HOME", _strdup(envStr), 1) != 0)
@@ -649,14 +649,14 @@ JNIEXPORT jlong JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp
char ebuffer[256] = WINPR_C_ARRAY_INIT;
WLog_FATAL(TAG, "Failed to set environment HOME=%s %s [%d]", envStr,
winpr_strerror(errno, ebuffer, sizeof(ebuffer)), errno);
return (jlong)NULL;
return (jlong) nullptr;
}
RdpClientEntry(&clientEntryPoints);
ctx = freerdp_client_context_new(&clientEntryPoints);
if (!ctx)
return (jlong)NULL;
return (jlong) nullptr;
return (jlong)ctx->instance;
}
@@ -739,7 +739,7 @@ JNIEXPORT jboolean JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_free
androidContext* ctx = (androidContext*)inst->context;
if (!(ctx->thread = CreateThread(NULL, 0, android_thread_func, inst, 0, NULL)))
if (!(ctx->thread = CreateThread(nullptr, 0, android_thread_func, inst, 0, nullptr)))
{
return JNI_FALSE;
}
@@ -927,7 +927,7 @@ Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1send_1clipboard_1data(
{
ANDROID_EVENT* event;
freerdp* inst = (freerdp*)instance;
const char* data = jdata != NULL ? (*env)->GetStringUTFChars(env, jdata, NULL) : NULL;
const char* data = jdata != nullptr ? (*env)->GetStringUTFChars(env, jdata, nullptr) : nullptr;
const size_t data_length = data ? (*env)->GetStringUTFLength(env, jdata) : 0;
jboolean ret = JNI_FALSE;
event = (ANDROID_EVENT*)android_event_clipboard_new((void*)data, data_length);
@@ -987,7 +987,7 @@ Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1get_1build_1config(JNI
return (*env)->NewStringUTF(env, freerdp_get_build_config());
}
static jclass gJavaActivityClass = NULL;
static jclass gJavaActivityClass = nullptr;
jint JNI_OnLoad(JavaVM* vm, void* reserved)
{

View File

@@ -74,7 +74,7 @@ jboolean jni_attach_thread(JNIEnv** env)
if ((*jVM)->GetEnv(jVM, (void**)env, JNI_VERSION_1_4) != JNI_OK)
{
WLog_DBG(TAG, "android_java_callback: attaching current thread");
(*jVM)->AttachCurrentThread(jVM, env, NULL);
(*jVM)->AttachCurrentThread(jVM, env, nullptr);
if ((*jVM)->GetEnv(jVM, (void**)env, JNI_VERSION_1_4) != JNI_OK)
{

View File

@@ -29,11 +29,11 @@ JavaVM* getJavaVM()
JNIEnv* getJNIEnv()
{
JNIEnv* env = NULL;
JNIEnv* env = nullptr;
if ((*g_JavaVm)->GetEnv(g_JavaVm, (void**)&env, JNI_VERSION_1_4) != JNI_OK)
{
WLog_FATAL(TAG, "Failed to obtain JNIEnv");
return NULL;
return nullptr;
}
return env;
}
@@ -47,14 +47,14 @@ jobject create_string_builder(JNIEnv* env, char* initialStr)
// get class
cls = (*env)->FindClass(env, "java/lang/StringBuilder");
if (!cls)
return NULL;
return nullptr;
if (initialStr)
{
// get method id for constructor
methodId = (*env)->GetMethodID(env, cls, "<init>", "(Ljava/lang/String;)V");
if (!methodId)
return NULL;
return nullptr;
// create string that holds our initial string
jstring jstr = (*env)->NewStringUTF(env, initialStr);
@@ -67,7 +67,7 @@ jobject create_string_builder(JNIEnv* env, char* initialStr)
// get method id for constructor
methodId = (*env)->GetMethodID(env, cls, "<init>", "()V");
if (!methodId)
return NULL;
return nullptr;
// construct new StringBuilder
obj = (*env)->NewObject(env, cls, methodId);
@@ -87,20 +87,20 @@ char* get_string_from_string_builder(JNIEnv* env, jobject strBuilder)
// get class
cls = (*env)->FindClass(env, "java/lang/StringBuilder");
if (!cls)
return NULL;
return nullptr;
// get method id for constructor
methodId = (*env)->GetMethodID(env, cls, "toString", "()Ljava/lang/String;");
if (!methodId)
return NULL;
return nullptr;
// get jstring representation of our buffer
strObj = (*env)->CallObjectMethod(env, strBuilder, methodId);
// read string
native_str = (*env)->GetStringUTFChars(env, strObj, NULL);
native_str = (*env)->GetStringUTFChars(env, strObj, nullptr);
if (!native_str)
return NULL;
return nullptr;
result = _strdup(native_str);
(*env)->ReleaseStringUTFChars(env, strObj, native_str);
@@ -109,14 +109,14 @@ char* get_string_from_string_builder(JNIEnv* env, jobject strBuilder)
jstring jniNewStringUTF(JNIEnv* env, const char* in, int len)
{
jstring out = NULL;
jchar* unicode = NULL;
jstring out = nullptr;
jchar* unicode = nullptr;
jint result_size = 0;
unsigned char* utf8 = (unsigned char*)in;
if (!in)
{
return NULL;
return nullptr;
}
if (len < 0)
len = strlen(in);
@@ -124,7 +124,7 @@ jstring jniNewStringUTF(JNIEnv* env, const char* in, int len)
unicode = (jchar*)malloc(sizeof(jchar) * (len + 1));
if (!unicode)
{
return NULL;
return nullptr;
}
for (jint i = 0; i < len; i++)