From e5816d65cec1742729c0dbdccae974c586fad9cc Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Thu, 26 Feb 2026 14:34:11 +0100 Subject: [PATCH] [c23,server] replace NULL with nullptr --- server/Mac/mf_audin.c | 4 +- server/Mac/mf_event.c | 14 +- server/Mac/mf_info.c | 14 +- server/Mac/mf_mountain_lion.c | 18 +- server/Mac/mf_peer.c | 10 +- server/Mac/mf_rdpsnd.c | 10 +- server/Mac/mfreerdp.c | 2 +- server/Sample/sf_audin.c | 4 +- server/Sample/sfreerdp.c | 84 ++++---- server/Windows/cli/wfreerdp.c | 6 +- server/Windows/wf_directsound.c | 16 +- server/Windows/wf_dxgi.c | 60 +++--- server/Windows/wf_info.c | 37 ++-- server/Windows/wf_interface.c | 19 +- server/Windows/wf_mirage.c | 17 +- server/Windows/wf_peer.c | 29 +-- server/Windows/wf_rdpsnd.c | 8 +- server/Windows/wf_settings.c | 13 +- server/Windows/wf_update.c | 4 +- server/Windows/wf_wasapi.c | 60 +++--- server/common/server.c | 64 +++--- server/proxy/channels/pf_channel_drdynvc.c | 24 +-- server/proxy/channels/pf_channel_rdpdr.c | 56 +++--- server/proxy/channels/pf_channel_smartcard.c | 20 +- server/proxy/cli/freerdp_proxy.c | 2 +- server/proxy/pf_channel.c | 10 +- server/proxy/pf_client.c | 82 ++++---- server/proxy/pf_config.c | 76 ++++---- server/proxy/pf_context.c | 38 ++-- server/proxy/pf_input.c | 28 +-- server/proxy/pf_modules.c | 28 +-- server/proxy/pf_server.c | 63 +++--- server/proxy/pf_update.c | 106 +++++----- server/proxy/pf_utils.h | 4 +- server/proxy/proxy_modules.h | 2 +- server/shadow/Mac/mac_shadow.c | 19 +- server/shadow/Sample/sample_shadow.c | 2 +- server/shadow/Win/win_dxgi.c | 58 +++--- server/shadow/Win/win_rdp.c | 10 +- server/shadow/Win/win_shadow.c | 13 +- server/shadow/Win/win_wds.c | 62 +++--- server/shadow/X11/x11_shadow.c | 82 ++++---- server/shadow/cli/shadow.c | 92 ++++----- server/shadow/shadow_audin.c | 10 +- server/shadow/shadow_capture.c | 12 +- server/shadow/shadow_client.c | 195 ++++++++++--------- server/shadow/shadow_encoder.c | 26 +-- server/shadow/shadow_encomsp.c | 2 +- server/shadow/shadow_lobby.c | 6 +- server/shadow/shadow_mcevent.c | 28 +-- server/shadow/shadow_rdpgfx.c | 2 +- server/shadow/shadow_rdpsnd.c | 2 +- server/shadow/shadow_remdesk.c | 2 +- server/shadow/shadow_screen.c | 6 +- server/shadow/shadow_server.c | 122 ++++++------ server/shadow/shadow_subsystem.c | 28 +-- server/shadow/shadow_subsystem_builtin.c | 4 +- server/shadow/shadow_surface.c | 10 +- 58 files changed, 919 insertions(+), 906 deletions(-) diff --git a/server/Mac/mf_audin.c b/server/Mac/mf_audin.c index df560e66e..abd0a0e6d 100644 --- a/server/Mac/mf_audin.c +++ b/server/Mac/mf_audin.c @@ -53,7 +53,7 @@ BOOL mf_peer_audin_init(mfPeerContext* context) context->audin->Data = mf_peer_audin_data; - return audin_server_set_formats(context->audin, -1, NULL); + return audin_server_set_formats(context->audin, -1, nullptr); } void mf_peer_audin_uninit(mfPeerContext* context) @@ -61,5 +61,5 @@ void mf_peer_audin_uninit(mfPeerContext* context) WINPR_ASSERT(context); audin_server_context_free(context->audin); - context->audin = NULL; + context->audin = nullptr; } diff --git a/server/Mac/mf_event.c b/server/Mac/mf_event.c index 5fba6ed2b..5462def66 100644 --- a/server/Mac/mf_event.c +++ b/server/Mac/mf_event.c @@ -112,7 +112,7 @@ mfEvent* mf_event_peek(mfEventQueue* event_queue) pthread_mutex_lock(&(event_queue->mutex)); if (event_queue->count < 1) - event = NULL; + event = nullptr; else event = event_queue->events[0]; @@ -128,7 +128,7 @@ mfEvent* mf_event_pop(mfEventQueue* event_queue) pthread_mutex_lock(&(event_queue->mutex)); if (event_queue->count < 1) - return NULL; + return nullptr; /* remove event signal */ mf_clear_event(event_queue); @@ -147,7 +147,7 @@ mfEventRegion* mf_event_region_new(int x, int y, int width, int height) { mfEventRegion* event_region = malloc(sizeof(mfEventRegion)); - if (event_region != NULL) + if (event_region != nullptr) { event_region->x = x; event_region->y = y; @@ -167,7 +167,7 @@ mfEvent* mf_event_new(int type) { mfEvent* event = malloc(sizeof(mfEvent)); if (!event) - return NULL; + return nullptr; event->type = type; return event; } @@ -181,7 +181,7 @@ mfEventQueue* mf_event_queue_new() { mfEventQueue* event_queue = malloc(sizeof(mfEventQueue)); - if (event_queue != NULL) + if (event_queue != nullptr) { event_queue->pipe_fd[0] = -1; event_queue->pipe_fd[1] = -1; @@ -193,10 +193,10 @@ mfEventQueue* mf_event_queue_new() if (pipe(event_queue->pipe_fd) < 0) { free(event_queue); - return NULL; + return nullptr; } - pthread_mutex_init(&(event_queue->mutex), NULL); + pthread_mutex_init(&(event_queue->mutex), nullptr); } return event_queue; diff --git a/server/Mac/mf_info.c b/server/Mac/mf_info.c index 17127833f..44931fe20 100644 --- a/server/Mac/mf_info.c +++ b/server/Mac/mf_info.c @@ -28,7 +28,7 @@ #define MF_INFO_DEFAULT_FPS 30 #define MF_INFO_MAXPEERS 32 -static mfInfo* mfInfoInstance = NULL; +static mfInfo* mfInfoInstance = nullptr; int mf_info_lock(mfInfo* mfi) { @@ -93,15 +93,15 @@ static mfInfo* mf_info_init(void) { mfInfo* mfi = (mfInfo*)calloc(1, sizeof(mfInfo)); - if (mfi != NULL) + if (mfi != nullptr) { - pthread_mutex_init(&mfi->mutex, NULL); + pthread_mutex_init(&mfi->mutex, nullptr); mfi->peers = (freerdp_peer**)calloc(MF_INFO_MAXPEERS, sizeof(freerdp_peer*)); if (!mfi->peers) { free(mfi); - return NULL; + return nullptr; } mfi->framesPerSecond = MF_INFO_DEFAULT_FPS; @@ -113,7 +113,7 @@ static mfInfo* mf_info_init(void) mfInfo* mf_info_get_instance(void) { - if (mfInfoInstance == NULL) + if (mfInfoInstance == nullptr) mfInfoInstance = mf_info_init(); return mfInfoInstance; @@ -145,7 +145,7 @@ void mf_info_peer_register(mfInfo* mfi, mfPeerContext* context) for (int i = 0; i < MF_INFO_MAXPEERS; ++i) { // empty index will be our peer id - if (mfi->peers[i] == NULL) + if (mfi->peers[i] == nullptr) { peerId = i; break; @@ -167,7 +167,7 @@ void mf_info_peer_unregister(mfInfo* mfi, mfPeerContext* context) int peerId; peerId = ((rdpContext*)context)->peer->pId; - mfi->peers[peerId] = NULL; + mfi->peers[peerId] = nullptr; mfi->peerCount--; if (mfi->peerCount == 0) diff --git a/server/Mac/mf_mountain_lion.c b/server/Mac/mf_mountain_lion.c index 9db86b899..77b57f13e 100644 --- a/server/Mac/mf_mountain_lion.c +++ b/server/Mac/mf_mountain_lion.c @@ -30,9 +30,9 @@ dispatch_semaphore_t data_sem; dispatch_queue_t screen_update_q; CGDisplayStreamRef stream; -CGDisplayStreamUpdateRef lastUpdate = NULL; +CGDisplayStreamUpdateRef lastUpdate = nullptr; -BYTE* localBuf = NULL; +BYTE* localBuf = nullptr; BOOL ready = FALSE; @@ -57,7 +57,7 @@ void (^streamHandler)(CGDisplayStreamFrameStatus, uint64_t, IOSurfaceRef, mf_mlion_peek_dirty_region(&rect); // lock surface - IOSurfaceLock(frameSurface, kIOSurfaceLockReadOnly, NULL); + IOSurfaceLock(frameSurface, kIOSurfaceLockReadOnly, nullptr); // get pointer void* baseAddress = IOSurfaceGetBaseAddress(frameSurface); // copy region @@ -71,7 +71,7 @@ void (^streamHandler)(CGDisplayStreamFrameStatus, uint64_t, IOSurfaceRef, } // unlock surface - IOSurfaceUnlock(frameSurface, kIOSurfaceLockReadOnly, NULL); + IOSurfaceUnlock(frameSurface, kIOSurfaceLockReadOnly, nullptr); ready = FALSE; dispatch_semaphore_signal(data_sem); @@ -94,7 +94,7 @@ void (^streamHandler)(CGDisplayStreamFrameStatus, uint64_t, IOSurfaceRef, break; } } - else if (lastUpdate == NULL) + else if (lastUpdate == nullptr) { CFRetain(updateRef); lastUpdate = updateRef; @@ -139,7 +139,7 @@ int mf_mlion_screen_updates_init() display_id = CGMainDisplayID(); - screen_update_q = dispatch_queue_create("mfreerdp.server.screenUpdate", NULL); + screen_update_q = dispatch_queue_create("mfreerdp.server.screenUpdate", nullptr); region_sem = dispatch_semaphore_create(1); data_sem = dispatch_semaphore_create(1); @@ -163,7 +163,7 @@ int mf_mlion_screen_updates_init() values[0] = (void*)kCFBooleanFalse; opts = CFDictionaryCreate(kCFAllocatorDefault, (const void**)keys, (const void**)values, 1, - NULL, NULL); + nullptr, nullptr); stream = CGDisplayStreamCreateWithDispatchQueue(display_id, pixelWidth, pixelHeight, 'BGRA', opts, screen_update_q, streamHandler); @@ -204,7 +204,7 @@ int mf_mlion_get_dirty_region(RFX_RECT* invalid) { dispatch_semaphore_wait(region_sem, DISPATCH_TIME_FOREVER); - if (lastUpdate != NULL) + if (lastUpdate != nullptr) { mf_mlion_peek_dirty_region(invalid); } @@ -246,7 +246,7 @@ int mf_mlion_clear_dirty_region() dispatch_semaphore_wait(region_sem, DISPATCH_TIME_FOREVER); CFRelease(lastUpdate); - lastUpdate = NULL; + lastUpdate = nullptr; dispatch_semaphore_signal(region_sem); diff --git a/server/Mac/mf_peer.c b/server/Mac/mf_peer.c index 7dbbb69f0..4b08859af 100644 --- a/server/Mac/mf_peer.c +++ b/server/Mac/mf_peer.c @@ -87,7 +87,7 @@ static void mf_peer_rfx_update(freerdp_peer* client) long width; long height; int pitch; - BYTE* dataBits = NULL; + BYTE* dataBits = nullptr; mf_info_getScreenData(mfi, &width, &height, &dataBits, &pitch); mf_info_clear_invalid_region(mfi); // encode @@ -151,7 +151,7 @@ static BOOL mf_peer_check_fds(freerdp_peer* client) event = mf_event_peek(info_event_queue); - if (event != NULL) + if (event != nullptr) { if (event->type == FREERDP_SERVER_MAC_EVENT_TYPE_REGION) { @@ -193,7 +193,7 @@ static BOOL mf_peer_context_new(freerdp_peer* client, rdpContext* context) rfx_context_set_mode(peer->rfx_context, RLGR3); rfx_context_set_pixel_format(peer->rfx_context, PIXEL_FORMAT_BGRA32); - if (!(peer->s = Stream_New(NULL, 0xFFFF))) + if (!(peer->s = Stream_New(nullptr, 0xFFFF))) goto fail; peer->vcm = WTSOpenServerA((LPSTR)client->context); @@ -387,7 +387,7 @@ static void* mf_peer_main_loop(void* arg) WINPR_ASSERT(settings); /* Initialize the real server settings here */ - rdpPrivateKey* key = freerdp_key_new_from_file_enc(info->key, NULL); + rdpPrivateKey* key = freerdp_key_new_from_file_enc(info->key, nullptr); if (!key) goto fail; if (!freerdp_settings_set_pointer_len(settings, FreeRDP_RdpServerRsaKey, key, 1)) @@ -475,7 +475,7 @@ static void* mf_peer_main_loop(void* arg) freerdp_peer_context_free(client); fail: freerdp_peer_free(client); - return NULL; + return nullptr; } BOOL mf_peer_accepted(freerdp_listener* instance, freerdp_peer* client) diff --git a/server/Mac/mf_rdpsnd.c b/server/Mac/mf_rdpsnd.c index 4962f0c68..0570dd2ee 100644 --- a/server/Mac/mf_rdpsnd.c +++ b/server/Mac/mf_rdpsnd.c @@ -38,7 +38,7 @@ static void mf_peer_rdpsnd_activated(RdpsndServerContext* context) { OSStatus status; BOOL formatAgreed = FALSE; - AUDIO_FORMAT* agreedFormat = NULL; + AUDIO_FORMAT* agreedFormat = nullptr; // we should actually loop through the list of client formats here // and see if we can send the client something that it supports... WLog_DBG(TAG, "Client supports the following %d formats: ", context->num_client_formats); @@ -100,7 +100,7 @@ static void mf_peer_rdpsnd_activated(RdpsndServerContext* context) recorderState.snd_context = context; status = AudioQueueNewInput(&recorderState.dataFormat, mf_peer_rdpsnd_input_callback, &recorderState, - NULL, kCFRunLoopCommonModes, 0, &recorderState.queue); + nullptr, kCFRunLoopCommonModes, 0, &recorderState.queue); if (status != noErr) { @@ -117,12 +117,12 @@ static void mf_peer_rdpsnd_activated(RdpsndServerContext* context) { AudioQueueAllocateBuffer(recorderState.queue, recorderState.bufferByteSize, &recorderState.buffers[x]); - AudioQueueEnqueueBuffer(recorderState.queue, recorderState.buffers[x], 0, NULL); + AudioQueueEnqueueBuffer(recorderState.queue, recorderState.buffers[x], 0, nullptr); } recorderState.currentPacket = 0; recorderState.isRunning = true; - AudioQueueStart(recorderState.queue, NULL); + AudioQueueStart(recorderState.queue, nullptr); } BOOL mf_peer_rdpsnd_init(mfPeerContext* context) @@ -171,7 +171,7 @@ void mf_peer_rdpsnd_input_callback(void* inUserData, AudioQueueRef inAQ, rState->snd_context->SendSamples(rState->snd_context, inBuffer->mAudioData, inBuffer->mAudioDataByteSize / 4, (UINT16)(GetTickCount() & 0xffff)); - status = AudioQueueEnqueueBuffer(rState->queue, inBuffer, 0, NULL); + status = AudioQueueEnqueueBuffer(rState->queue, inBuffer, 0, nullptr); if (status != noErr) { diff --git a/server/Mac/mfreerdp.c b/server/Mac/mfreerdp.c index 7d0983d46..1229d3ce8 100644 --- a/server/Mac/mfreerdp.c +++ b/server/Mac/mfreerdp.c @@ -97,7 +97,7 @@ int main(int argc, char* argv[]) instance->info = &info; instance->PeerAccepted = mf_peer_accepted; - if (instance->Open(instance, NULL, 3389)) + if (instance->Open(instance, nullptr, 3389)) { mf_server_main_loop(instance); } diff --git a/server/Sample/sf_audin.c b/server/Sample/sf_audin.c index fe711f346..94a721dae 100644 --- a/server/Sample/sf_audin.c +++ b/server/Sample/sf_audin.c @@ -61,7 +61,7 @@ BOOL sf_peer_audin_init(testPeerContext* context) context->audin->Data = sf_peer_audin_data; - return audin_server_set_formats(context->audin, -1, NULL); + return audin_server_set_formats(context->audin, -1, nullptr); #else return TRUE; #endif @@ -109,6 +109,6 @@ void sf_peer_audin_uninit(testPeerContext* context) #if defined(CHANNEL_AUDIN_SERVER) audin_server_context_free(context->audin); - context->audin = NULL; + context->audin = nullptr; #endif } diff --git a/server/Sample/sfreerdp.c b/server/Sample/sfreerdp.c index 0c1bbf8db..5242d1670 100644 --- a/server/Sample/sfreerdp.c +++ b/server/Sample/sfreerdp.c @@ -138,7 +138,7 @@ static BOOL test_peer_context_new(freerdp_peer* client, rdpContext* ctx) if (!(context->nsc_context = nsc_context_new())) goto fail; - if (!(context->s = Stream_New(NULL, 65536))) + if (!(context->s = Stream_New(nullptr, 65536))) goto fail; context->icon_x = UINT32_MAX; @@ -178,9 +178,9 @@ static wStream* test_peer_stream_init(testPeerContext* context) static void test_peer_begin_frame(freerdp_peer* client) { - rdpUpdate* update = NULL; + rdpUpdate* update = nullptr; SURFACE_FRAME_MARKER fm = WINPR_C_ARRAY_INIT; - testPeerContext* context = NULL; + testPeerContext* context = nullptr; WINPR_ASSERT(client); WINPR_ASSERT(client->context); @@ -200,9 +200,9 @@ static void test_peer_begin_frame(freerdp_peer* client) static void test_peer_end_frame(freerdp_peer* client) { - rdpUpdate* update = NULL; + rdpUpdate* update = nullptr; SURFACE_FRAME_MARKER fm = WINPR_C_ARRAY_INIT; - testPeerContext* context = NULL; + testPeerContext* context = nullptr; WINPR_ASSERT(client); @@ -350,8 +350,8 @@ static int open_icon(wImage* img) WINPR_ATTR_NODISCARD static BOOL test_peer_load_icon(freerdp_peer* client) { - testPeerContext* context = NULL; - rdpSettings* settings = NULL; + testPeerContext* context = nullptr; + rdpSettings* settings = nullptr; WINPR_ASSERT(client); @@ -379,7 +379,7 @@ static BOOL test_peer_load_icon(freerdp_peer* client) memset(context->bg_data, 0xA0, 3ULL * context->image->height * context->image->width); return TRUE; out_fail: - context->bg_data = NULL; + context->bg_data = nullptr; return FALSE; } @@ -546,11 +546,11 @@ static BOOL test_sleep_tsdiff(UINT32* old_sec, UINT32* old_usec, UINT32 new_sec, static BOOL tf_peer_dump_rfx(freerdp_peer* client) { BOOL rc = FALSE; - wStream* s = NULL; + wStream* s = nullptr; UINT32 prev_seconds = 0; UINT32 prev_useconds = 0; - rdpUpdate* update = NULL; - rdpPcap* pcap_rfx = NULL; + rdpUpdate* update = nullptr; + rdpPcap* pcap_rfx = nullptr; pcap_record record = WINPR_C_ARRAY_INIT; WINPR_ASSERT(client); @@ -559,7 +559,7 @@ static BOOL tf_peer_dump_rfx(freerdp_peer* client) struct server_info* info = client->ContextExtra; WINPR_ASSERT(info); - s = Stream_New(NULL, 512); + s = Stream_New(nullptr, 512); if (!s) return FALSE; @@ -610,8 +610,8 @@ fail: WINPR_ATTR_NODISCARD static DWORD WINAPI tf_debug_channel_thread_func(LPVOID arg) { - void* fd = NULL; - void* buffer = NULL; + void* fd = nullptr; + void* buffer = nullptr; DWORD BytesReturned = 0; ULONG written = 0; testPeerContext* context = (testPeerContext*)arg; @@ -623,11 +623,11 @@ static DWORD WINAPI tf_debug_channel_thread_func(LPVOID arg) fd = *((void**)buffer); WTSFreeMemory(buffer); - if (!(context->event = CreateWaitObjectEvent(NULL, TRUE, FALSE, fd))) + if (!(context->event = CreateWaitObjectEvent(nullptr, TRUE, FALSE, fd))) return 0; } - wStream* s = Stream_New(NULL, 4096); + wStream* s = Stream_New(nullptr, 4096); if (!s) goto fail; @@ -682,8 +682,8 @@ fail: WINPR_ATTR_NODISCARD static BOOL tf_peer_post_connect(freerdp_peer* client) { - testPeerContext* context = NULL; - rdpSettings* settings = NULL; + testPeerContext* context = nullptr; + rdpSettings* settings = nullptr; WINPR_ASSERT(client); @@ -748,22 +748,22 @@ static BOOL tf_peer_post_connect(freerdp_peer* client) { context->debug_channel = WTSVirtualChannelOpen(context->vcm, WTS_CURRENT_SESSION, "rdpdbg"); - if (context->debug_channel != NULL) + if (context->debug_channel != nullptr) { WLog_DBG(TAG, "Open channel rdpdbg."); - if (!(context->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL))) + if (!(context->stopEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr))) { WLog_ERR(TAG, "Failed to create stop event"); return FALSE; } - if (!(context->debug_channel_thread = - CreateThread(NULL, 0, tf_debug_channel_thread_func, (void*)context, 0, NULL))) + if (!(context->debug_channel_thread = CreateThread( + nullptr, 0, tf_debug_channel_thread_func, (void*)context, 0, nullptr))) { WLog_ERR(TAG, "Failed to create debug channel thread"); (void)CloseHandle(context->stopEvent); - context->stopEvent = NULL; + context->stopEvent = nullptr; return FALSE; } } @@ -815,7 +815,7 @@ static BOOL tf_peer_activate(freerdp_peer* client) if (!freerdp_settings_set_uint32(settings, FreeRDP_CompressionLevel, PACKET_COMPR_TYPE_RDP8)) return FALSE; - if (info->test_pcap_file != NULL) + if (info->test_pcap_file != nullptr) { if (!freerdp_settings_set_bool(settings, FreeRDP_DumpRemoteFx, TRUE)) return FALSE; @@ -851,11 +851,11 @@ static BOOL tf_peer_synchronize_event(rdpInput* input, UINT32 flags) WINPR_ATTR_NODISCARD static BOOL tf_peer_keyboard_event(rdpInput* input, UINT16 flags, UINT8 code) { - freerdp_peer* client = NULL; - rdpUpdate* update = NULL; - rdpContext* context = NULL; - testPeerContext* tcontext = NULL; - rdpSettings* settings = NULL; + freerdp_peer* client = nullptr; + rdpUpdate* update = nullptr; + rdpContext* context = nullptr; + testPeerContext* tcontext = nullptr; + rdpSettings* settings = nullptr; WINPR_ASSERT(input); @@ -1056,7 +1056,7 @@ WINPR_ATTR_NODISCARD static int hook_peer_write_pdu(rdpTransport* transport, wStream* s) { UINT64 ts = 0; - wStream* ls = NULL; + wStream* ls = nullptr; UINT64 last_ts = 0; size_t offset = 0; UINT32 flags = 0; @@ -1083,7 +1083,7 @@ static int hook_peer_write_pdu(rdpTransport* transport, wStream* s) if (state < CONNECTION_STATE_NEGO) return peerCtx->io.WritePdu(transport, s); - ls = Stream_New(NULL, 4096); + ls = Stream_New(nullptr, 4096); if (!ls) goto fail; @@ -1124,10 +1124,10 @@ static DWORD WINAPI test_peer_mainloop(LPVOID arg) HANDLE handles[MAXIMUM_WAIT_OBJECTS] = WINPR_C_ARRAY_INIT; DWORD count = 0; DWORD status = 0; - testPeerContext* context = NULL; - rdpSettings* settings = NULL; - rdpInput* input = NULL; - rdpUpdate* update = NULL; + testPeerContext* context = nullptr; + rdpSettings* settings = nullptr; + rdpInput* input = nullptr; + rdpUpdate* update = nullptr; freerdp_peer* client = (freerdp_peer*)arg; WINPR_ASSERT(client); @@ -1153,7 +1153,7 @@ static DWORD WINAPI test_peer_mainloop(LPVOID arg) } { - rdpPrivateKey* key = freerdp_key_new_from_file_enc(info->key, NULL); + rdpPrivateKey* key = freerdp_key_new_from_file_enc(info->key, nullptr); if (!key) goto fail; if (!freerdp_settings_set_pointer_len(settings, FreeRDP_RdpServerRsaKey, key, 1)) @@ -1325,7 +1325,7 @@ fail: WINPR_ATTR_NODISCARD static BOOL test_peer_accepted(freerdp_listener* instance, freerdp_peer* client) { - HANDLE hThread = NULL; + HANDLE hThread = nullptr; WINPR_UNUSED(instance); @@ -1335,7 +1335,7 @@ static BOOL test_peer_accepted(freerdp_listener* instance, freerdp_peer* client) struct server_info* info = instance->info; client->ContextExtra = info; - if (!(hThread = CreateThread(NULL, 0, test_peer_mainloop, (void*)client, 0, NULL))) + if (!(hThread = CreateThread(nullptr, 0, test_peer_mainloop, (void*)client, 0, nullptr))) return FALSE; (void)CloseHandle(hThread); @@ -1428,8 +1428,8 @@ int main(int argc, char* argv[]) int rc = -1; BOOL started = FALSE; WSADATA wsaData = WINPR_C_ARRAY_INIT; - freerdp_listener* instance = NULL; - char* file = NULL; + freerdp_listener* instance = nullptr; + char* file = nullptr; char name[MAX_PATH] = WINPR_C_ARRAY_INIT; long port = 3389; BOOL localOnly = FALSE; @@ -1449,7 +1449,7 @@ int main(int argc, char* argv[]) else if (strncmp(arg, options.sport, sizeof(options.sport)) == 0) { const char* sport = &arg[sizeof(options.sport)]; - port = strtol(sport, NULL, 10); + port = strtol(sport, nullptr, 10); if ((port < 1) || (port > UINT16_MAX) || (errno != 0)) return usage(app, arg); @@ -1511,7 +1511,7 @@ int main(int argc, char* argv[]) else { WINPR_ASSERT(instance->Open); - started = instance->Open(instance, NULL, (UINT16)port); + started = instance->Open(instance, nullptr, (UINT16)port); } if (started) diff --git a/server/Windows/cli/wfreerdp.c b/server/Windows/cli/wfreerdp.c index eb0582d89..ed5358e9c 100644 --- a/server/Windows/cli/wfreerdp.c +++ b/server/Windows/cli/wfreerdp.c @@ -91,7 +91,7 @@ int main(int argc, char* argv[]) vscreen_w = GetSystemMetrics(SM_CXVIRTUALSCREEN); vscreen_h = GetSystemMetrics(SM_CYVIRTUALSCREEN); WLog_INFO(TAG, ""); - EnumDisplayMonitors(NULL, NULL, moncb, 0); + EnumDisplayMonitors(nullptr, nullptr, moncb, 0); IDcount = 0; WLog_INFO(TAG, "Virtual Screen = %dx%d", vscreen_w, vscreen_h); } @@ -111,7 +111,7 @@ int main(int argc, char* argv[]) return 0; } - val = strtoul(argv[index], NULL, 0); + val = strtoul(argv[index], nullptr, 0); if ((errno != 0) || (val > UINT32_MAX)) return -1; @@ -122,7 +122,7 @@ int main(int argc, char* argv[]) if (index == argc - 1) { - UINT32 val = strtoul(argv[index], NULL, 0); + UINT32 val = strtoul(argv[index], nullptr, 0); if ((errno != 0) || (val > UINT32_MAX)) return -1; diff --git a/server/Windows/wf_directsound.c b/server/Windows/wf_directsound.c index e116f4089..9234e0e91 100644 --- a/server/Windows/wf_directsound.c +++ b/server/Windows/wf_directsound.c @@ -43,7 +43,7 @@ int wf_directsound_activate(RdpsndServerContext* context) return 1; } WLog_DBG(TAG, "RDPSND (direct sound) Activated"); - hr = DirectSoundCaptureCreate8(NULL, &cap, NULL); + hr = DirectSoundCaptureCreate8(nullptr, &cap, nullptr); if (FAILED(hr)) { @@ -58,9 +58,9 @@ int wf_directsound_activate(RdpsndServerContext* context) dscbd.dwReserved = 0; dscbd.lpwfxFormat = wfi->agreed_format; dscbd.dwFXCount = 0; - dscbd.lpDSCFXDesc = NULL; + dscbd.lpDSCFXDesc = nullptr; - hr = cap->lpVtbl->CreateCaptureBuffer(cap, &dscbd, &pDSCB, NULL); + hr = cap->lpVtbl->CreateCaptureBuffer(cap, &dscbd, &pDSCB, nullptr); if (FAILED(hr)) { @@ -77,7 +77,7 @@ int wf_directsound_activate(RdpsndServerContext* context) pDSCB->lpVtbl->Release(pDSCB); lastPos = 0; - if (!(hThread = CreateThread(NULL, 0, wf_rdpsnd_directsound_thread, latestPeer, 0, NULL))) + if (!(hThread = CreateThread(nullptr, 0, wf_rdpsnd_directsound_thread, latestPeer, 0, nullptr))) { WLog_ERR(TAG, "Failed to create direct sound thread"); return 1; @@ -96,11 +96,11 @@ static DWORD WINAPI wf_rdpsnd_directsound_thread(LPVOID lpParam) wfPeerContext* context; wfInfo* wfi; - VOID* pbCaptureData = NULL; + VOID* pbCaptureData = nullptr; DWORD dwCaptureLength = 0; - VOID* pbCaptureData2 = NULL; + VOID* pbCaptureData2 = nullptr; DWORD dwCaptureLength2 = 0; - VOID* pbPlayData = NULL; + VOID* pbPlayData = nullptr; DWORD dwReadPos = 0; LONG lLockSize = 0; @@ -143,7 +143,7 @@ static DWORD WINAPI wf_rdpsnd_directsound_thread(LPVOID lpParam) break; } - hr = capBuf->lpVtbl->GetCurrentPosition(capBuf, NULL, &dwReadPos); + hr = capBuf->lpVtbl->GetCurrentPosition(capBuf, nullptr, &dwReadPos); if (FAILED(hr)) { WLog_ERR(TAG, "Failed to get read pos"); diff --git a/server/Windows/wf_dxgi.c b/server/Windows/wf_dxgi.c index 627da473b..71142cb96 100644 --- a/server/Windows/wf_dxgi.c +++ b/server/Windows/wf_dxgi.c @@ -50,10 +50,10 @@ UINT NumFeatureLevels = ARRAYSIZE(FeatureLevels); D3D_FEATURE_LEVEL FeatureLevel; -ID3D11Device* gDevice = NULL; -ID3D11DeviceContext* gContext = NULL; -IDXGIOutputDuplication* gOutputDuplication = NULL; -ID3D11Texture2D* gAcquiredDesktopImage = NULL; +ID3D11Device* gDevice = nullptr; +ID3D11DeviceContext* gContext = nullptr; +IDXGIOutputDuplication* gOutputDuplication = nullptr; +ID3D11Texture2D* gAcquiredDesktopImage = nullptr; IDXGISurface* surf; ID3D11Texture2D* sStage; @@ -62,7 +62,7 @@ DXGI_OUTDUPL_FRAME_INFO FrameInfo; int wf_dxgi_init(wfInfo* wfi) { - gAcquiredDesktopImage = NULL; + gAcquiredDesktopImage = nullptr; if (wf_dxgi_createDevice(wfi) != 0) { @@ -84,7 +84,7 @@ int wf_dxgi_createDevice(wfInfo* wfi) for (DriverTypeIndex = 0; DriverTypeIndex < NumDriverTypes; ++DriverTypeIndex) { - status = D3D11CreateDevice(NULL, DriverTypes[DriverTypeIndex], NULL, 0, FeatureLevels, + status = D3D11CreateDevice(nullptr, DriverTypes[DriverTypeIndex], nullptr, 0, FeatureLevels, NumFeatureLevels, D3D11_SDK_VERSION, &gDevice, &FeatureLevel, &gContext); if (SUCCEEDED(status)) @@ -109,10 +109,10 @@ int wf_dxgi_getDuplication(wfInfo* wfi) UINT dTop, i = 0; DXGI_OUTPUT_DESC desc = WINPR_C_ARRAY_INIT; IDXGIOutput* pOutput; - IDXGIDevice* DxgiDevice = NULL; - IDXGIAdapter* DxgiAdapter = NULL; - IDXGIOutput* DxgiOutput = NULL; - IDXGIOutput1* DxgiOutput1 = NULL; + IDXGIDevice* DxgiDevice = nullptr; + IDXGIAdapter* DxgiAdapter = nullptr; + IDXGIOutput* DxgiOutput = nullptr; + IDXGIOutput1* DxgiOutput1 = nullptr; status = gDevice->lpVtbl->QueryInterface(gDevice, &IID_IDXGIDevice, (void**)&DxgiDevice); @@ -124,7 +124,7 @@ int wf_dxgi_getDuplication(wfInfo* wfi) status = DxgiDevice->lpVtbl->GetParent(DxgiDevice, &IID_IDXGIAdapter, (void**)&DxgiAdapter); DxgiDevice->lpVtbl->Release(DxgiDevice); - DxgiDevice = NULL; + DxgiDevice = nullptr; if (FAILED(status)) { @@ -132,7 +132,7 @@ int wf_dxgi_getDuplication(wfInfo* wfi) return 1; } - pOutput = NULL; + pOutput = nullptr; while (DxgiAdapter->lpVtbl->EnumOutputs(DxgiAdapter, i, &pOutput) != DXGI_ERROR_NOT_FOUND) { @@ -159,7 +159,7 @@ int wf_dxgi_getDuplication(wfInfo* wfi) status = DxgiAdapter->lpVtbl->EnumOutputs(DxgiAdapter, dTop, &DxgiOutput); DxgiAdapter->lpVtbl->Release(DxgiAdapter); - DxgiAdapter = NULL; + DxgiAdapter = nullptr; if (FAILED(status)) { @@ -170,7 +170,7 @@ int wf_dxgi_getDuplication(wfInfo* wfi) status = DxgiOutput->lpVtbl->QueryInterface(DxgiOutput, &IID_IDXGIOutput1, (void**)&DxgiOutput1); DxgiOutput->lpVtbl->Release(DxgiOutput); - DxgiOutput = NULL; + DxgiOutput = nullptr; if (FAILED(status)) { @@ -181,7 +181,7 @@ int wf_dxgi_getDuplication(wfInfo* wfi) status = DxgiOutput1->lpVtbl->DuplicateOutput(DxgiOutput1, (IUnknown*)gDevice, &gOutputDuplication); DxgiOutput1->lpVtbl->Release(DxgiOutput1); - DxgiOutput1 = NULL; + DxgiOutput1 = nullptr; if (FAILED(status)) { @@ -211,25 +211,25 @@ int wf_dxgi_cleanup(wfInfo* wfi) if (gAcquiredDesktopImage) { gAcquiredDesktopImage->lpVtbl->Release(gAcquiredDesktopImage); - gAcquiredDesktopImage = NULL; + gAcquiredDesktopImage = nullptr; } if (gOutputDuplication) { gOutputDuplication->lpVtbl->Release(gOutputDuplication); - gOutputDuplication = NULL; + gOutputDuplication = nullptr; } if (gContext) { gContext->lpVtbl->Release(gContext); - gContext = NULL; + gContext = nullptr; } if (gDevice) { gDevice->lpVtbl->Release(gDevice); - gDevice = NULL; + gDevice = nullptr; } return 0; @@ -240,8 +240,8 @@ int wf_dxgi_nextFrame(wfInfo* wfi, UINT timeout) HRESULT status = 0; UINT i = 0; UINT DataBufferSize = 0; - BYTE* DataBuffer = NULL; - IDXGIResource* DesktopResource = NULL; + BYTE* DataBuffer = nullptr; + IDXGIResource* DesktopResource = nullptr; if (wfi->framesWaiting > 0) { @@ -251,7 +251,7 @@ int wf_dxgi_nextFrame(wfInfo* wfi, UINT timeout) if (gAcquiredDesktopImage) { gAcquiredDesktopImage->lpVtbl->Release(gAcquiredDesktopImage); - gAcquiredDesktopImage = NULL; + gAcquiredDesktopImage = nullptr; } status = gOutputDuplication->lpVtbl->AcquireNextFrame(gOutputDuplication, timeout, &FrameInfo, @@ -272,13 +272,13 @@ int wf_dxgi_nextFrame(wfInfo* wfi, UINT timeout) if (gAcquiredDesktopImage) { gAcquiredDesktopImage->lpVtbl->Release(gAcquiredDesktopImage); - gAcquiredDesktopImage = NULL; + gAcquiredDesktopImage = nullptr; } if (gOutputDuplication) { gOutputDuplication->lpVtbl->Release(gOutputDuplication); - gOutputDuplication = NULL; + gOutputDuplication = nullptr; } wf_dxgi_getDuplication(wfi); @@ -302,7 +302,7 @@ int wf_dxgi_nextFrame(wfInfo* wfi, UINT timeout) status = DesktopResource->lpVtbl->QueryInterface(DesktopResource, &IID_ID3D11Texture2D, (void**)&gAcquiredDesktopImage); DesktopResource->lpVtbl->Release(DesktopResource); - DesktopResource = NULL; + DesktopResource = nullptr; if (FAILED(status)) { @@ -350,7 +350,7 @@ int wf_dxgi_getPixelData(wfInfo* wfi, BYTE** data, int* pitch, RECT* invalid) Box.front = 0; Box.back = 1; - status = gDevice->lpVtbl->CreateTexture2D(gDevice, &tDesc, NULL, &sStage); + status = gDevice->lpVtbl->CreateTexture2D(gDevice, &tDesc, nullptr, &sStage); if (FAILED(status)) { @@ -392,9 +392,9 @@ int wf_dxgi_releasePixelData(wfInfo* wfi) surf->lpVtbl->Unmap(surf); surf->lpVtbl->Release(surf); - surf = NULL; + surf = nullptr; sStage->lpVtbl->Release(sStage); - sStage = NULL; + sStage = nullptr; status = gOutputDuplication->lpVtbl->ReleaseFrame(gOutputDuplication); @@ -417,7 +417,7 @@ int wf_dxgi_getInvalidRegion(RECT* invalid) RECT* pRect; BYTE* DirtyRects; UINT DataBufferSize = 0; - BYTE* DataBuffer = NULL; + BYTE* DataBuffer = nullptr; if (FrameInfo.AccumulatedFrames == 0) { @@ -432,7 +432,7 @@ int wf_dxgi_getInvalidRegion(RECT* invalid) if (DataBuffer) { free(DataBuffer); - DataBuffer = NULL; + DataBuffer = nullptr; } DataBuffer = (BYTE*)malloc(FrameInfo.TotalMetadataBufferSize); diff --git a/server/Windows/wf_info.c b/server/Windows/wf_info.c index f0d053b04..3b04aa63e 100644 --- a/server/Windows/wf_info.c +++ b/server/Windows/wf_info.c @@ -36,7 +36,7 @@ #define SERVER_KEY "Software\\" FREERDP_VENDOR_STRING "\\" FREERDP_PRODUCT_STRING "\\Server" -static wfInfo* wfInfoInstance = NULL; +static wfInfo* wfInfoInstance = nullptr; static int _IDcount = 0; BOOL wf_info_lock(wfInfo* wfi) @@ -99,33 +99,34 @@ wfInfo* wf_info_init() wfInfo* wfi; wfi = (wfInfo*)calloc(1, sizeof(wfInfo)); - if (wfi != NULL) + if (wfi != nullptr) { HKEY hKey; LONG status; DWORD dwType; DWORD dwSize; DWORD dwValue; - wfi->mutex = CreateMutex(NULL, FALSE, NULL); + wfi->mutex = CreateMutex(nullptr, FALSE, nullptr); - if (wfi->mutex == NULL) + if (wfi->mutex == nullptr) { WLog_ERR(TAG, "CreateMutex error: %lu", GetLastError()); free(wfi); - return NULL; + return nullptr; } - wfi->updateSemaphore = CreateSemaphore(NULL, 0, 32, NULL); + wfi->updateSemaphore = CreateSemaphore(nullptr, 0, 32, nullptr); if (!wfi->updateSemaphore) { WLog_ERR(TAG, "CreateSemaphore error: %lu", GetLastError()); (void)CloseHandle(wfi->mutex); free(wfi); - return NULL; + return nullptr; } - wfi->updateThread = CreateThread(NULL, 0, wf_update_thread, wfi, CREATE_SUSPENDED, NULL); + wfi->updateThread = + CreateThread(nullptr, 0, wf_update_thread, wfi, CREATE_SUSPENDED, nullptr); if (!wfi->updateThread) { @@ -133,7 +134,7 @@ wfInfo* wf_info_init() (void)CloseHandle(wfi->mutex); (void)CloseHandle(wfi->updateSemaphore); free(wfi); - return NULL; + return nullptr; } wfi->peers = @@ -146,7 +147,7 @@ wfInfo* wf_info_init() (void)CloseHandle(wfi->updateSemaphore); (void)CloseHandle(wfi->updateThread); free(wfi); - return NULL; + return nullptr; } // Set FPS @@ -156,7 +157,7 @@ wfInfo* wf_info_init() if (status == ERROR_SUCCESS) { - if (RegQueryValueEx(hKey, _T("FramesPerSecond"), NULL, &dwType, (BYTE*)&dwValue, + if (RegQueryValueEx(hKey, _T("FramesPerSecond"), nullptr, &dwType, (BYTE*)&dwValue, &dwSize) == ERROR_SUCCESS) wfi->framesPerSecond = dwValue; } @@ -169,7 +170,7 @@ wfInfo* wf_info_init() if (status == ERROR_SUCCESS) { - if (RegQueryValueEx(hKey, _T("DisableInput"), NULL, &dwType, (BYTE*)&dwValue, + if (RegQueryValueEx(hKey, _T("DisableInput"), nullptr, &dwType, (BYTE*)&dwValue, &dwSize) == ERROR_SUCCESS) { if (dwValue != 0) @@ -185,7 +186,7 @@ wfInfo* wf_info_init() wfInfo* wf_info_get_instance() { - if (wfInfoInstance == NULL) + if (wfInfoInstance == nullptr) wfInfoInstance = wf_info_init(); return wfInfoInstance; @@ -206,11 +207,11 @@ BOOL wf_info_peer_register(wfInfo* wfi, wfPeerContext* context) context->info = wfi; - if (!(context->updateEvent = CreateEvent(NULL, TRUE, FALSE, NULL))) + if (!(context->updateEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr))) goto fail_update_event; // get the offset of the top left corner of selected screen - EnumDisplayMonitors(NULL, NULL, wf_info_monEnumCB, 0); + EnumDisplayMonitors(nullptr, nullptr, wf_info_monEnumCB, 0); _IDcount = 0; #ifdef WITH_DXGI_1_2 @@ -229,7 +230,7 @@ BOOL wf_info_peer_register(wfInfo* wfi, wfPeerContext* context) for (int i = 0; i < FREERDP_SERVER_WIN_INFO_MAXPEERS; ++i) { // empty index will be our peer id - if (wfi->peers[i] == NULL) + if (wfi->peers[i] == nullptr) { peerId = i; break; @@ -245,7 +246,7 @@ BOOL wf_info_peer_register(wfInfo* wfi, wfPeerContext* context) return TRUE; fail_driver_init: (void)CloseHandle(context->updateEvent); - context->updateEvent = NULL; + context->updateEvent = nullptr; fail_update_event: fail_peer_count: context->socketClose = TRUE; @@ -259,7 +260,7 @@ void wf_info_peer_unregister(wfInfo* wfi, wfPeerContext* context) { int peerId; peerId = ((rdpContext*)context)->peer->pId; - wfi->peers[peerId] = NULL; + wfi->peers[peerId] = nullptr; wfi->peerCount--; (void)CloseHandle(context->updateEvent); WLog_INFO(TAG, "Unregistering Peer: id=%d, #=%d", peerId, wfi->peerCount); diff --git a/server/Windows/wf_interface.c b/server/Windows/wf_interface.c index c541c0cd7..4426b9bea 100644 --- a/server/Windows/wf_interface.c +++ b/server/Windows/wf_interface.c @@ -43,7 +43,7 @@ #define SERVER_KEY "Software\\" FREERDP_VENDOR_STRING "\\" FREERDP_PRODUCT_STRING "\\Server" -static cbCallback cbEvent = NULL; +static cbCallback cbEvent = nullptr; int get_screen_info(int id, _TCHAR* name, size_t length, int* width, int* height, int* bpp) { @@ -51,18 +51,18 @@ int get_screen_info(int id, _TCHAR* name, size_t length, int* width, int* height dd.cb = sizeof(DISPLAY_DEVICE); - if (EnumDisplayDevices(NULL, id, &dd, 0) != 0) + if (EnumDisplayDevices(nullptr, id, &dd, 0) != 0) { HDC dc; - if (name != NULL) + if (name != nullptr) _stprintf_s(name, length, _T("%s (%s)"), dd.DeviceName, dd.DeviceString); - dc = CreateDC(dd.DeviceName, NULL, NULL, NULL); + dc = CreateDC(dd.DeviceName, nullptr, nullptr, nullptr); *width = GetDeviceCaps(dc, HORZRES); *height = GetDeviceCaps(dc, VERTRES); *bpp = GetDeviceCaps(dc, BITSPIXEL); - // ReleaseDC(NULL, dc); + // ReleaseDC(nullptr, dc); DeleteDC(dc); } else @@ -146,10 +146,11 @@ BOOL wfreerdp_server_start(wfServer* server) wf_settings_read_dword(HKEY_LOCAL_MACHINE, SERVER_KEY, _T("DefaultPort"), &server->port); - if (!instance->Open(instance, NULL, (UINT16)server->port)) + if (!instance->Open(instance, nullptr, (UINT16)server->port)) return FALSE; - if (!(server->thread = CreateThread(NULL, 0, wf_server_main_loop, (void*)instance, 0, NULL))) + if (!(server->thread = + CreateThread(nullptr, 0, wf_server_main_loop, (void*)instance, 0, nullptr))) return FALSE; return TRUE; @@ -174,7 +175,7 @@ wfServer* wfreerdp_server_new() wfServer* server; if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) - return NULL; + return nullptr; server = (wfServer*)calloc(1, sizeof(wfServer)); @@ -185,7 +186,7 @@ wfServer* wfreerdp_server_new() WTSRegisterWtsApiFunctionTable(FreeRDP_InitWtsApi()); - cbEvent = NULL; + cbEvent = nullptr; return server; } diff --git a/server/Windows/wf_mirage.c b/server/Windows/wf_mirage.c index 8ce6f0096..af09dc4fb 100644 --- a/server/Windows/wf_mirage.c +++ b/server/Windows/wf_mirage.c @@ -43,7 +43,7 @@ BOOL wf_mirror_driver_find_display_device(wfInfo* wfi) deviceNumber = 0; deviceInfo.cb = sizeof(deviceInfo); - while (result = EnumDisplayDevices(NULL, deviceNumber, &deviceInfo, 0)) + while (result = EnumDisplayDevices(nullptr, deviceNumber, &deviceInfo, 0)) { if (_tcscmp(deviceInfo.DeviceString, _T("Mirage Driver")) == 0) { @@ -104,7 +104,8 @@ BOOL wf_mirror_driver_display_device_attach(wfInfo* wfi, DWORD mode) } dwSize = sizeof(DWORD); - status = RegQueryValueEx(hKey, _T("Attach.ToDesktop"), NULL, &dwType, (BYTE*)&dwValue, &dwSize); + status = + RegQueryValueEx(hKey, _T("Attach.ToDesktop"), nullptr, &dwType, (BYTE*)&dwValue, &dwSize); if (status != ERROR_SUCCESS) { @@ -236,7 +237,7 @@ BOOL wf_mirror_driver_update(wfInfo* wfi, int mode) deviceMode->dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_POSITION; _tcsncpy_s(deviceMode->dmDeviceName, 32, wfi->deviceName, _tcslen(wfi->deviceName)); disp_change_status = - ChangeDisplaySettingsEx(wfi->deviceName, deviceMode, NULL, CDS_UPDATEREGISTRY, NULL); + ChangeDisplaySettingsEx(wfi->deviceName, deviceMode, nullptr, CDS_UPDATEREGISTRY, nullptr); status = (disp_change_status == DISP_CHANGE_SUCCESSFUL) ? TRUE : FALSE; if (!status) @@ -248,9 +249,9 @@ BOOL wf_mirror_driver_update(wfInfo* wfi, int mode) BOOL wf_mirror_driver_map_memory(wfInfo* wfi) { int status; - wfi->driverDC = CreateDC(wfi->deviceName, NULL, NULL, NULL); + wfi->driverDC = CreateDC(wfi->deviceName, nullptr, nullptr, nullptr); - if (wfi->driverDC == NULL) + if (wfi->driverDC == nullptr) { WLog_ERR(TAG, "Could not create device driver context!"); { @@ -258,8 +259,8 @@ BOOL wf_mirror_driver_map_memory(wfInfo* wfi) DWORD dw = GetLastError(); FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, - NULL); + nullptr, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, + 0, nullptr); // Display the error message and exit the process WLog_ERR(TAG, "CreateDC failed on device [%s] with error %lu: %s", wfi->deviceName, dw, lpMsgBuf); @@ -298,7 +299,7 @@ BOOL wf_mirror_driver_cleanup(wfInfo* wfi) WLog_ERR(TAG, "Failed to unmap shared memory from the driver! code %d", status); } - if (wfi->driverDC != NULL) + if (wfi->driverDC != nullptr) { status = DeleteDC(wfi->driverDC); diff --git a/server/Windows/wf_peer.c b/server/Windows/wf_peer.c index edd32cdcc..6fc9b5b15 100644 --- a/server/Windows/wf_peer.c +++ b/server/Windows/wf_peer.c @@ -63,7 +63,7 @@ static BOOL wf_peer_context_new(freerdp_peer* client, rdpContext* ctx) if (!wf_info_peer_register(context->info, context)) { WTSCloseServer(context->vcm); - context->vcm = NULL; + context->vcm = nullptr; return FALSE; } @@ -113,7 +113,7 @@ static BOOL wf_peer_post_connect(freerdp_peer* client) settings = client->context->settings; WINPR_ASSERT(settings); - if ((get_screen_info(wfi->screenID, NULL, 0, &wfi->servscreen_width, &wfi->servscreen_height, + if ((get_screen_info(wfi->screenID, nullptr, 0, &wfi->servscreen_width, &wfi->servscreen_height, &wfi->bitsPerPixel) == 0) || (wfi->servscreen_width == 0) || (wfi->servscreen_height == 0) || (wfi->bitsPerPixel == 0)) { @@ -179,7 +179,7 @@ BOOL wf_peer_accepted(freerdp_listener* instance, freerdp_peer* client) { HANDLE hThread; - if (!(hThread = CreateThread(NULL, 0, wf_peer_main_loop, client, 0, NULL))) + if (!(hThread = CreateThread(nullptr, 0, wf_peer_main_loop, client, 0, nullptr))) return FALSE; (void)CloseHandle(hThread); @@ -237,7 +237,7 @@ static BOOL wf_peer_read_settings(freerdp_peer* client) settings = client->context->settings; WINPR_ASSERT(settings); - char* CertificateFile = NULL; + char* CertificateFile = nullptr; if (!wf_settings_read_string_ascii(HKEY_LOCAL_MACHINE, SERVER_KEY, _T("CertificateFile"), &(CertificateFile))) CertificateFile = _strdup("server.crt"); @@ -250,12 +250,12 @@ static BOOL wf_peer_read_settings(freerdp_peer* client) if (!freerdp_settings_set_pointer_len(settings, FreeRDP_RdpServerCertificate, cert, 1)) return FALSE; - char* PrivateKeyFile = NULL; + char* PrivateKeyFile = nullptr; if (!wf_settings_read_string_ascii(HKEY_LOCAL_MACHINE, SERVER_KEY, _T("PrivateKeyFile"), &(PrivateKeyFile))) PrivateKeyFile = _strdup("server.key"); - rdpPrivateKey* key = freerdp_key_new_from_file_enc(PrivateKeyFile, NULL); + rdpPrivateKey* key = freerdp_key_new_from_file_enc(PrivateKeyFile, nullptr); free(PrivateKeyFile); if (!key) @@ -328,13 +328,14 @@ DWORD WINAPI wf_peer_main_loop(LPVOID lpParam) client->context->input->ExtendedMouseEvent = wf_peer_extended_mouse_event_dummy; } - if (!(context->socketEvent = CreateEvent(NULL, TRUE, FALSE, NULL))) + if (!(context->socketEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr))) goto fail_socket_event; - if (!(context->socketSemaphore = CreateSemaphore(NULL, 0, 1, NULL))) + if (!(context->socketSemaphore = CreateSemaphore(nullptr, 0, 1, nullptr))) goto fail_socket_semaphore; - if (!(context->socketThread = CreateThread(NULL, 0, wf_peer_socket_listener, client, 0, NULL))) + if (!(context->socketThread = + CreateThread(nullptr, 0, wf_peer_socket_listener, client, 0, nullptr))) goto fail_socket_thread; WLog_INFO(TAG, "We've got a client %s", client->local ? "(local)" : client->hostname); @@ -358,7 +359,7 @@ DWORD WINAPI wf_peer_main_loop(LPVOID lpParam) wf_update_peer_send(wfi, context); (void)ResetEvent(context->updateEvent); - ReleaseSemaphore(wfi->updateSemaphore, 1, NULL); + ReleaseSemaphore(wfi->updateSemaphore, 1, nullptr); } if (WaitForSingleObject(context->socketEvent, 0) == 0) @@ -370,7 +371,7 @@ DWORD WINAPI wf_peer_main_loop(LPVOID lpParam) } (void)ResetEvent(context->socketEvent); - ReleaseSemaphore(context->socketSemaphore, 1, NULL); + ReleaseSemaphore(context->socketSemaphore, 1, nullptr); if (context->socketClose) break; @@ -393,17 +394,17 @@ DWORD WINAPI wf_peer_main_loop(LPVOID lpParam) if (WaitForSingleObject(context->updateEvent, 0) == 0) { (void)ResetEvent(context->updateEvent); - ReleaseSemaphore(wfi->updateSemaphore, 1, NULL); + ReleaseSemaphore(wfi->updateSemaphore, 1, nullptr); } wf_update_peer_deactivate(wfi, context); client->Disconnect(client); fail_socket_thread: (void)CloseHandle(context->socketSemaphore); - context->socketSemaphore = NULL; + context->socketSemaphore = nullptr; fail_socket_semaphore: (void)CloseHandle(context->socketEvent); - context->socketEvent = NULL; + context->socketEvent = nullptr; fail_socket_event: fail_socked_closed: fail_client_initialize: diff --git a/server/Windows/wf_rdpsnd.c b/server/Windows/wf_rdpsnd.c index cb961e550..7c46da454 100644 --- a/server/Windows/wf_rdpsnd.c +++ b/server/Windows/wf_rdpsnd.c @@ -46,7 +46,7 @@ static void wf_peer_rdpsnd_activated(RdpsndServerContext* context) { wfInfo* wfi; wfi = wf_info_get_instance(); - wfi->agreed_format = NULL; + wfi->agreed_format = nullptr; WLog_DBG(TAG, "Client supports the following %d formats:", context->num_client_formats); size_t i = 0; @@ -66,11 +66,11 @@ static void wf_peer_rdpsnd_activated(RdpsndServerContext* context) } } - if (wfi->agreed_format != NULL) + if (wfi->agreed_format != nullptr) break; } - if (wfi->agreed_format == NULL) + if (wfi->agreed_format == nullptr) { WLog_ERR(TAG, "Could not agree on a audio format with the server"); return; @@ -133,7 +133,7 @@ BOOL wf_peer_rdpsnd_init(wfPeerContext* context) if (!wfi) return FALSE; - if (!(wfi->snd_mutex = CreateMutex(NULL, FALSE, NULL))) + if (!(wfi->snd_mutex = CreateMutex(nullptr, FALSE, nullptr))) return FALSE; context->rdpsnd = rdpsnd_server_context_new(context->vcm); diff --git a/server/Windows/wf_settings.c b/server/Windows/wf_settings.c index 63d232770..6c48edc27 100644 --- a/server/Windows/wf_settings.c +++ b/server/Windows/wf_settings.c @@ -38,7 +38,7 @@ BOOL wf_settings_read_dword(HKEY key, LPCSTR subkey, LPTSTR name, DWORD* value) { dwSize = sizeof(DWORD); - status = RegQueryValueEx(hKey, name, NULL, &dwType, (BYTE*)&dwValue, &dwSize); + status = RegQueryValueEx(hKey, name, nullptr, &dwType, (BYTE*)&dwValue, &dwSize); if (status == ERROR_SUCCESS) *value = dwValue; @@ -59,21 +59,21 @@ BOOL wf_settings_read_string_ascii(HKEY key, LPCSTR subkey, LPTSTR name, char** DWORD dwType; DWORD dwSize; char* strA; - TCHAR* strX = NULL; + TCHAR* strX = nullptr; status = RegOpenKeyExA(key, subkey, 0, KEY_READ | KEY_WOW64_64KEY, &hKey); if (status != ERROR_SUCCESS) return FALSE; - status = RegQueryValueEx(hKey, name, NULL, &dwType, NULL, &dwSize); + status = RegQueryValueEx(hKey, name, nullptr, &dwType, nullptr, &dwSize); if (status == ERROR_SUCCESS) { strX = (LPTSTR)malloc(dwSize + sizeof(TCHAR)); if (!strX) return FALSE; - status = RegQueryValueEx(hKey, name, NULL, &dwType, (BYTE*)strX, &dwSize); + status = RegQueryValueEx(hKey, name, nullptr, &dwType, (BYTE*)strX, &dwSize); if (status != ERROR_SUCCESS) { @@ -86,9 +86,10 @@ BOOL wf_settings_read_string_ascii(HKEY key, LPCSTR subkey, LPTSTR name, char** if (strX) { #ifdef UNICODE - length = WideCharToMultiByte(CP_UTF8, 0, strX, lstrlenW(strX), NULL, 0, NULL, NULL); + length = + WideCharToMultiByte(CP_UTF8, 0, strX, lstrlenW(strX), nullptr, 0, nullptr, nullptr); strA = (char*)malloc(length + 1); - WideCharToMultiByte(CP_UTF8, 0, strX, lstrlenW(strX), strA, length, NULL, NULL); + WideCharToMultiByte(CP_UTF8, 0, strX, lstrlenW(strX), strA, length, nullptr, nullptr); strA[length] = '\0'; free(strX); #else diff --git a/server/Windows/wf_update.c b/server/Windows/wf_update.c index 8867efb84..18265ca79 100644 --- a/server/Windows/wf_update.c +++ b/server/Windows/wf_update.c @@ -108,7 +108,7 @@ void wf_update_encode(wfInfo* wfi) { RFX_RECT rect; long height, width; - BYTE* pDataBits = NULL; + BYTE* pDataBits = nullptr; int stride; SURFACE_BITS_COMMAND* cmd; wf_info_find_invalid_region(wfi); @@ -202,7 +202,7 @@ void wf_update_encoder_reset(wfInfo* wfi) rfx_context_set_mode(wfi->rfx_context, RLGR3); rfx_context_reset(wfi->rfx_context, wfi->servscreen_width, wfi->servscreen_height); rfx_context_set_pixel_format(wfi->rfx_context, PIXEL_FORMAT_BGRA32); - wfi->s = Stream_New(NULL, 0xFFFF); + wfi->s = Stream_New(nullptr, 0xFFFF); } wf_info_invalidate_full_screen(wfi); diff --git a/server/Windows/wf_wasapi.c b/server/Windows/wf_wasapi.c index a3490b1c9..7f9771973 100644 --- a/server/Windows/wf_wasapi.c +++ b/server/Windows/wf_wasapi.c @@ -30,8 +30,8 @@ DEFINE_GUID(IID_IAudioCaptureClient, 0xc8adbd64, 0xe71e, 0x48a0, 0xa4, 0xde, 0x1 0xd3, 0x17); #endif -LPWSTR devStr = NULL; -wfPeerContext* latestPeer = NULL; +LPWSTR devStr = nullptr; +wfPeerContext* latestPeer = nullptr; int wf_rdpsnd_set_latest_peer(wfPeerContext* peer) { @@ -46,14 +46,14 @@ int wf_wasapi_activate(RdpsndServerContext* context) wf_wasapi_get_device_string(pattern, &devStr); - if (devStr == NULL) + if (devStr == nullptr) { WLog_ERR(TAG, "Failed to match for output device! Disabling rdpsnd."); return 1; } WLog_DBG(TAG, "RDPSND (WASAPI) Activated"); - if (!(hThread = CreateThread(NULL, 0, wf_rdpsnd_wasapi_thread, latestPeer, 0, NULL))) + if (!(hThread = CreateThread(nullptr, 0, wf_rdpsnd_wasapi_thread, latestPeer, 0, nullptr))) { WLog_ERR(TAG, "CreateThread failed"); return 1; @@ -66,15 +66,15 @@ int wf_wasapi_activate(RdpsndServerContext* context) int wf_wasapi_get_device_string(LPWSTR pattern, LPWSTR* deviceStr) { HRESULT hr; - IMMDeviceEnumerator* pEnumerator = NULL; - IMMDeviceCollection* pCollection = NULL; - IMMDevice* pEndpoint = NULL; - IPropertyStore* pProps = NULL; - LPWSTR pwszID = NULL; + IMMDeviceEnumerator* pEnumerator = nullptr; + IMMDeviceCollection* pCollection = nullptr; + IMMDevice* pEndpoint = nullptr; + IPropertyStore* pProps = nullptr; + LPWSTR pwszID = nullptr; unsigned int count; - CoInitialize(NULL); - hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, &IID_IMMDeviceEnumerator, + CoInitialize(nullptr); + hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, nullptr, CLSCTX_ALL, &IID_IMMDeviceEnumerator, (void**)&pEnumerator); if (FAILED(hr)) { @@ -145,21 +145,21 @@ int wf_wasapi_get_device_string(LPWSTR pattern, LPWSTR* deviceStr) wcscpy_s(*deviceStr, devStrLen + 1, pwszID); } CoTaskMemFree(pwszID); - pwszID = NULL; + pwszID = nullptr; PropVariantClear(&nameVar); pProps->lpVtbl->Release(pProps); - pProps = NULL; + pProps = nullptr; pEndpoint->lpVtbl->Release(pEndpoint); - pEndpoint = NULL; + pEndpoint = nullptr; } pCollection->lpVtbl->Release(pCollection); - pCollection = NULL; + pCollection = nullptr; pEnumerator->lpVtbl->Release(pEnumerator); - pEnumerator = NULL; + pEnumerator = nullptr; CoUninitialize(); return 0; @@ -167,11 +167,11 @@ int wf_wasapi_get_device_string(LPWSTR pattern, LPWSTR* deviceStr) DWORD WINAPI wf_rdpsnd_wasapi_thread(LPVOID lpParam) { - IMMDeviceEnumerator* pEnumerator = NULL; - IMMDevice* pDevice = NULL; - IAudioClient* pAudioClient = NULL; - IAudioCaptureClient* pCaptureClient = NULL; - WAVEFORMATEX* pwfx = NULL; + IMMDeviceEnumerator* pEnumerator = nullptr; + IMMDevice* pDevice = nullptr; + IAudioClient* pAudioClient = nullptr; + IAudioCaptureClient* pCaptureClient = nullptr; + WAVEFORMATEX* pwfx = nullptr; HRESULT hr; REFERENCE_TIME hnsRequestedDuration = REFTIMES_PER_SEC; REFERENCE_TIME hnsActualDuration; @@ -187,8 +187,8 @@ DWORD WINAPI wf_rdpsnd_wasapi_thread(LPVOID lpParam) wfi = wf_info_get_instance(); context = (wfPeerContext*)lpParam; - CoInitialize(NULL); - hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, &IID_IMMDeviceEnumerator, + CoInitialize(nullptr); + hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, nullptr, CLSCTX_ALL, &IID_IMMDeviceEnumerator, (void**)&pEnumerator); if (FAILED(hr)) { @@ -203,7 +203,7 @@ DWORD WINAPI wf_rdpsnd_wasapi_thread(LPVOID lpParam) exit(1); } - hr = pDevice->lpVtbl->Activate(pDevice, &IID_IAudioClient, CLSCTX_ALL, NULL, + hr = pDevice->lpVtbl->Activate(pDevice, &IID_IAudioClient, CLSCTX_ALL, nullptr, (void**)&pAudioClient); if (FAILED(hr)) { @@ -227,7 +227,7 @@ DWORD WINAPI wf_rdpsnd_wasapi_thread(LPVOID lpParam) pwfx->cbSize = wfi->agreed_format->cbSize; hr = pAudioClient->lpVtbl->Initialize(pAudioClient, AUDCLNT_SHAREMODE_SHARED, 0, - hnsRequestedDuration, 0, pwfx, NULL); + hnsRequestedDuration, 0, pwfx, nullptr); if (FAILED(hr)) { @@ -277,7 +277,7 @@ DWORD WINAPI wf_rdpsnd_wasapi_thread(LPVOID lpParam) while (packetLength != 0) { hr = pCaptureClient->lpVtbl->GetBuffer(pCaptureClient, &pData, &numFramesAvailable, - &flags, NULL, NULL); + &flags, nullptr, nullptr); if (FAILED(hr)) { WLog_ERR(TAG, "Failed to get buffer"); @@ -315,16 +315,16 @@ DWORD WINAPI wf_rdpsnd_wasapi_thread(LPVOID lpParam) CoTaskMemFree(pwfx); - if (pEnumerator != NULL) + if (pEnumerator != nullptr) pEnumerator->lpVtbl->Release(pEnumerator); - if (pDevice != NULL) + if (pDevice != nullptr) pDevice->lpVtbl->Release(pDevice); - if (pAudioClient != NULL) + if (pAudioClient != nullptr) pAudioClient->lpVtbl->Release(pAudioClient); - if (pCaptureClient != NULL) + if (pCaptureClient != nullptr) pCaptureClient->lpVtbl->Release(pCaptureClient); CoUninitialize(); diff --git a/server/common/server.c b/server/common/server.c index 83c4575a8..6a4af102d 100644 --- a/server/common/server.c +++ b/server/common/server.c @@ -46,14 +46,14 @@ size_t server_audin_get_formats(AUDIO_FORMAT** dst_formats) BYTE gsm610_data[] = { 0x40, 0x01 }; const AUDIO_FORMAT default_supported_audio_formats[] = { /* Formats sent by windows 10 server */ - { WAVE_FORMAT_AAC_MS, 2, 44100, 24000, 4, 16, 0, NULL }, - { WAVE_FORMAT_AAC_MS, 2, 44100, 20000, 4, 16, 0, NULL }, - { WAVE_FORMAT_AAC_MS, 2, 44100, 16000, 4, 16, 0, NULL }, - { WAVE_FORMAT_AAC_MS, 2, 44100, 12000, 4, 16, 0, NULL }, - { WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0, NULL }, + { WAVE_FORMAT_AAC_MS, 2, 44100, 24000, 4, 16, 0, nullptr }, + { WAVE_FORMAT_AAC_MS, 2, 44100, 20000, 4, 16, 0, nullptr }, + { WAVE_FORMAT_AAC_MS, 2, 44100, 16000, 4, 16, 0, nullptr }, + { WAVE_FORMAT_AAC_MS, 2, 44100, 12000, 4, 16, 0, nullptr }, + { WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0, nullptr }, { WAVE_FORMAT_ADPCM, 2, 44100, 44359, 2048, 4, 32, adpcm_data_7 }, { WAVE_FORMAT_DVI_ADPCM, 2, 44100, 44251, 2048, 4, 2, adpcm_dvi_data_7 }, - { WAVE_FORMAT_ALAW, 2, 22050, 44100, 2, 8, 0, NULL }, + { WAVE_FORMAT_ALAW, 2, 22050, 44100, 2, 8, 0, nullptr }, { WAVE_FORMAT_ADPCM, 2, 22050, 22311, 1024, 4, 32, adpcm_data_3 }, { WAVE_FORMAT_DVI_ADPCM, 2, 22050, 22201, 1024, 4, 2, adpcm_dvi_data_3 }, { WAVE_FORMAT_ADPCM, 1, 44100, 22179, 1024, 4, 32, adpcm_data_7 }, @@ -74,22 +74,22 @@ size_t server_audin_get_formats(AUDIO_FORMAT** dst_formats) { WAVE_FORMAT_GSM610, 1, 8000, 1625, 65, 0, 2, gsm610_data }, /* Formats added for others */ - { WAVE_FORMAT_MSG723, 2, 44100, 0, 4, 16, 0, NULL }, - { WAVE_FORMAT_MSG723, 2, 22050, 0, 4, 16, 0, NULL }, - { WAVE_FORMAT_MSG723, 1, 44100, 0, 4, 16, 0, NULL }, - { WAVE_FORMAT_MSG723, 1, 22050, 0, 4, 16, 0, NULL }, - { WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0, NULL }, - { WAVE_FORMAT_PCM, 2, 22050, 88200, 4, 16, 0, NULL }, - { WAVE_FORMAT_PCM, 1, 44100, 88200, 4, 16, 0, NULL }, - { WAVE_FORMAT_PCM, 1, 22050, 44100, 4, 16, 0, NULL }, - { WAVE_FORMAT_MULAW, 2, 44100, 88200, 4, 16, 0, NULL }, - { WAVE_FORMAT_MULAW, 2, 22050, 44100, 4, 16, 0, NULL }, - { WAVE_FORMAT_MULAW, 1, 44100, 44100, 4, 16, 0, NULL }, - { WAVE_FORMAT_MULAW, 1, 22050, 22050, 4, 16, 0, NULL }, - { WAVE_FORMAT_ALAW, 2, 44100, 88200, 2, 8, 0, NULL }, - { WAVE_FORMAT_ALAW, 2, 22050, 44100, 2, 8, 0, NULL }, - { WAVE_FORMAT_ALAW, 1, 44100, 44100, 2, 8, 0, NULL }, - { WAVE_FORMAT_ALAW, 1, 22050, 22050, 2, 8, 0, NULL } + { WAVE_FORMAT_MSG723, 2, 44100, 0, 4, 16, 0, nullptr }, + { WAVE_FORMAT_MSG723, 2, 22050, 0, 4, 16, 0, nullptr }, + { WAVE_FORMAT_MSG723, 1, 44100, 0, 4, 16, 0, nullptr }, + { WAVE_FORMAT_MSG723, 1, 22050, 0, 4, 16, 0, nullptr }, + { WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0, nullptr }, + { WAVE_FORMAT_PCM, 2, 22050, 88200, 4, 16, 0, nullptr }, + { WAVE_FORMAT_PCM, 1, 44100, 88200, 4, 16, 0, nullptr }, + { WAVE_FORMAT_PCM, 1, 22050, 44100, 4, 16, 0, nullptr }, + { WAVE_FORMAT_MULAW, 2, 44100, 88200, 4, 16, 0, nullptr }, + { WAVE_FORMAT_MULAW, 2, 22050, 44100, 4, 16, 0, nullptr }, + { WAVE_FORMAT_MULAW, 1, 44100, 44100, 4, 16, 0, nullptr }, + { WAVE_FORMAT_MULAW, 1, 22050, 22050, 4, 16, 0, nullptr }, + { WAVE_FORMAT_ALAW, 2, 44100, 88200, 2, 8, 0, nullptr }, + { WAVE_FORMAT_ALAW, 2, 22050, 44100, 2, 8, 0, nullptr }, + { WAVE_FORMAT_ALAW, 1, 44100, 44100, 2, 8, 0, nullptr }, + { WAVE_FORMAT_ALAW, 1, 22050, 22050, 2, 8, 0, nullptr } }; const size_t nrDefaultFormatsMax = ARRAYSIZE(default_supported_audio_formats); size_t nr_formats = 0; @@ -98,7 +98,7 @@ size_t server_audin_get_formats(AUDIO_FORMAT** dst_formats) if (!dst_formats) goto fail; - *dst_formats = NULL; + *dst_formats = nullptr; if (!formats) goto fail; @@ -127,14 +127,14 @@ size_t server_rdpsnd_get_formats(AUDIO_FORMAT** dst_formats) { /* Default supported audio formats */ static const AUDIO_FORMAT default_supported_audio_formats[] = { - { WAVE_FORMAT_AAC_MS, 2, 44100, 176400, 4, 16, 0, NULL }, - { WAVE_FORMAT_MPEGLAYER3, 2, 44100, 176400, 4, 16, 0, NULL }, - { WAVE_FORMAT_MSG723, 2, 44100, 176400, 4, 16, 0, NULL }, - { WAVE_FORMAT_GSM610, 2, 44100, 176400, 4, 16, 0, NULL }, - { WAVE_FORMAT_ADPCM, 2, 44100, 176400, 4, 16, 0, NULL }, - { WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0, NULL }, - { WAVE_FORMAT_ALAW, 2, 22050, 44100, 2, 8, 0, NULL }, - { WAVE_FORMAT_MULAW, 2, 22050, 44100, 2, 8, 0, NULL }, + { WAVE_FORMAT_AAC_MS, 2, 44100, 176400, 4, 16, 0, nullptr }, + { WAVE_FORMAT_MPEGLAYER3, 2, 44100, 176400, 4, 16, 0, nullptr }, + { WAVE_FORMAT_MSG723, 2, 44100, 176400, 4, 16, 0, nullptr }, + { WAVE_FORMAT_GSM610, 2, 44100, 176400, 4, 16, 0, nullptr }, + { WAVE_FORMAT_ADPCM, 2, 44100, 176400, 4, 16, 0, nullptr }, + { WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0, nullptr }, + { WAVE_FORMAT_ALAW, 2, 22050, 44100, 2, 8, 0, nullptr }, + { WAVE_FORMAT_MULAW, 2, 22050, 44100, 2, 8, 0, nullptr }, }; AUDIO_FORMAT* supported_audio_formats = audio_formats_new(ARRAYSIZE(default_supported_audio_formats)); @@ -160,7 +160,7 @@ fail: audio_formats_free(supported_audio_formats, ARRAYSIZE(default_supported_audio_formats)); if (dst_formats) - *dst_formats = NULL; + *dst_formats = nullptr; return 0; } diff --git a/server/proxy/channels/pf_channel_drdynvc.c b/server/proxy/channels/pf_channel_drdynvc.c index 29d22985d..25ce2fed5 100644 --- a/server/proxy/channels/pf_channel_drdynvc.c +++ b/server/proxy/channels/pf_channel_drdynvc.c @@ -125,13 +125,13 @@ static void dyn_log_(wLog* log, DWORD level, const pServerDynamicChannelContext* if (!WLog_IsLevelActive(log, level)) return; - char* prefix = NULL; - char* msg = NULL; + char* prefix = nullptr; + char* msg = nullptr; size_t prefixlen = 0; size_t msglen = 0; uint32_t channelId = dynChannel ? dynChannel->channelId : UINT32_MAX; - const char* channelName = dynChannel ? dynChannel->channelName : ""; + const char* channelName = dynChannel ? dynChannel->channelName : ""; (void)winpr_asprintf(&prefix, &prefixlen, "DynvcTracker[%s](%s [%s:%" PRIu32 "])", getDirection(isBackData), channelName, drdynvc_get_packet_type(cmd), channelId); @@ -206,7 +206,7 @@ static pServerDynamicChannelContext* DynamicChannelContext_new(wLog* log, pServe if (!ret) { WLog_Print(log, WLOG_ERROR, "error allocating dynamic channel context '%s'", name); - return NULL; + return nullptr; } ret->channelId = id; @@ -215,7 +215,7 @@ static pServerDynamicChannelContext* DynamicChannelContext_new(wLog* log, pServe { WLog_Print(log, WLOG_ERROR, "error allocating name in dynamic channel context '%s'", name); free(ret); - return NULL; + return nullptr; } ret->frontTracker.dataCallback = data_cb; @@ -389,7 +389,7 @@ static PfChannelResult DynvcTrackerHandleCreateBack(ChannelStateTracker* tracker DynvcTrackerLog(dynChannelContext->log, WLOG_ERROR, dynChannel, cmd, isBackData, "channel id %" PRIu64 ", name=%s [%" PRIuz "|%" PRIuz "], status=%s", dynChannelId, namebuffer, len, nameLen, - dynChannel ? openstatus2str(dynChannel->openStatus) : "NULL"); + dynChannel ? openstatus2str(dynChannel->openStatus) : "nullptr"); return PF_CHANNEL_RESULT_ERROR; } @@ -518,7 +518,7 @@ static PfChannelResult DynvcTrackerHandleCmdDATA(ChannelStateTracker* tracker, if (!dynChannel) { DynvcTrackerLog(dynChannelContext->log, WLOG_WARN, dynChannel, cmd, isBackData, - "channel is NULL, dropping packet"); + "channel is nullptr, dropping packet"); return PF_CHANNEL_RESULT_DROP; } @@ -573,7 +573,7 @@ static PfChannelResult DynvcTrackerHandleCmdDATA(ChannelStateTracker* tracker, { if (!trackerState->currentPacket) { - trackerState->currentPacket = Stream_New(NULL, 1024); + trackerState->currentPacket = Stream_New(nullptr, 1024); if (!trackerState->currentPacket) { DynvcTrackerLog(dynChannelContext->log, WLOG_ERROR, dynChannel, cmd, @@ -702,13 +702,13 @@ WINPR_ATTR_NODISCARD static PfChannelResult DynvcTrackerPeekFn(ChannelStateTracker* tracker, BOOL firstPacket, BOOL lastPacket) { - wStream* s = NULL; + wStream* s = nullptr; wStream sbuffer; BOOL haveChannelId = 0; BOOL haveLength = 0; UINT64 dynChannelId = 0; UINT64 Length = 0; - pServerDynamicChannelContext* dynChannel = NULL; + pServerDynamicChannelContext* dynChannel = nullptr; WINPR_ASSERT(tracker); @@ -836,7 +836,7 @@ static DynChannelContext* DynChannelContext_new(proxyData* pdata, { DynChannelContext* dyn = calloc(1, sizeof(DynChannelContext)); if (!dyn) - return NULL; + return nullptr; dyn->log = WLog_Get(DTAG); WINPR_ASSERT(dyn->log); @@ -877,7 +877,7 @@ static DynChannelContext* DynChannelContext_new(proxyData* pdata, fail: DynChannelContext_free(dyn); - return NULL; + return nullptr; } WINPR_ATTR_NODISCARD diff --git a/server/proxy/channels/pf_channel_rdpdr.c b/server/proxy/channels/pf_channel_rdpdr.c index c258182e8..57326b1ba 100644 --- a/server/proxy/channels/pf_channel_rdpdr.c +++ b/server/proxy/channels/pf_channel_rdpdr.c @@ -200,9 +200,9 @@ static wStream* rdpdr_get_send_buffer(pf_channel_common_context* rdpdr, UINT16 c WINPR_ASSERT(rdpdr); WINPR_ASSERT(rdpdr->s); if (!Stream_SetPosition(rdpdr->s, 0)) - return NULL; + return nullptr; if (!Stream_EnsureCapacity(rdpdr->s, capacity + 4)) - return NULL; + return nullptr; Stream_Write_UINT16(rdpdr->s, component); Stream_Write_UINT16(rdpdr->s, PacketID); return rdpdr->s; @@ -271,7 +271,7 @@ static UINT rdpdr_seal_send_free_request(pf_channel_server_context* context, wSt WINPR_ASSERT(len <= UINT32_MAX); rdpdr_dump_send_packet(context->log, WLOG_TRACE, s, proxy_client_tx); - status = WTSVirtualChannelWrite(context->handle, Stream_BufferAs(s, char), (ULONG)len, NULL); + status = WTSVirtualChannelWrite(context->handle, Stream_BufferAs(s, char), (ULONG)len, nullptr); return (status) ? CHANNEL_RC_OK : ERROR_INTERNAL_ERROR; } @@ -507,7 +507,7 @@ static UINT rdpdr_process_client_name_request(pf_channel_server_context* rdpdr, WINPR_ATTR_NODISCARD static UINT rdpdr_send_client_name_request(pClientContext* pc, pf_channel_client_context* rdpdr) { - wStream* s = NULL; + wStream* s = nullptr; WINPR_ASSERT(rdpdr); WINPR_ASSERT(pc); @@ -826,7 +826,7 @@ WINPR_ATTR_NODISCARD static UINT rdpdr_send_client_capability_response(pClientContext* pc, pf_channel_client_context* rdpdr) { - wStream* s = NULL; + wStream* s = nullptr; WINPR_ASSERT(rdpdr); s = rdpdr_client_get_send_buffer(rdpdr, RDPDR_CTYP_CORE, PAKID_CORE_CLIENT_CAPABILITY, 4); @@ -851,7 +851,7 @@ static UINT rdpdr_send_client_capability_response(pClientContext* pc, WINPR_ATTR_NODISCARD static UINT rdpdr_send_server_clientid_confirm(pf_channel_server_context* rdpdr) { - wStream* s = NULL; + wStream* s = nullptr; s = rdpdr_server_get_send_buffer(rdpdr, RDPDR_CTYP_CORE, PAKID_CORE_CLIENTID_CONFIRM, 8); if (!s) @@ -973,7 +973,7 @@ WINPR_ATTR_NODISCARD static UINT rdpdr_send_emulated_scard_device_list_announce_request(pClientContext* pc, pf_channel_client_context* rdpdr) { - wStream* s = NULL; + wStream* s = nullptr; s = rdpdr_client_get_send_buffer(rdpdr, RDPDR_CTYP_CORE, PAKID_CORE_DEVICELIST_ANNOUNCE, 24); if (!s) @@ -994,7 +994,7 @@ WINPR_ATTR_NODISCARD static UINT rdpdr_send_emulated_scard_device_remove(pClientContext* pc, pf_channel_client_context* rdpdr) { - wStream* s = NULL; + wStream* s = nullptr; s = rdpdr_client_get_send_buffer(rdpdr, RDPDR_CTYP_CORE, PAKID_CORE_DEVICELIST_REMOVE, 24); if (!s) @@ -1059,7 +1059,7 @@ static BOOL pf_channel_rdpdr_rewrite_device_list_to(wStream* s, UINT32 fromVersi return TRUE; const size_t cap = Stream_GetRemainingLength(s); - wStream* clone = Stream_New(NULL, cap); + wStream* clone = Stream_New(nullptr, cap); if (!clone) goto fail; @@ -1356,9 +1356,9 @@ static BOOL rdpdr_handle_server_announce_request(pClientContext* pc, BOOL pf_channel_rdpdr_client_handle(pClientContext* pc, UINT16 channelId, const char* channel_name, const BYTE* xdata, size_t xsize, UINT32 flags, size_t totalSize) { - pf_channel_client_context* rdpdr = NULL; - pServerContext* ps = NULL; - wStream* s = NULL; + pf_channel_client_context* rdpdr = nullptr; + pServerContext* ps = nullptr; + wStream* s = nullptr; #if defined(WITH_PROXY_EMULATE_SMARTCARD) UINT16 packetid = 0; #endif @@ -1529,14 +1529,14 @@ static BOOL pf_channel_rdpdr_common_context_new(pf_channel_common_context* commo if (!common) return FALSE; common->base.free = fkt; - common->s = Stream_New(NULL, 1024); + common->s = Stream_New(nullptr, 1024); if (!common->s) return FALSE; - common->buffer = Stream_New(NULL, 1024); + common->buffer = Stream_New(nullptr, 1024); if (!common->buffer) return FALSE; common->computerNameUnicode = 1; - common->computerName.v = NULL; + common->computerName.v = nullptr; common->versionMajor = RDPDR_VERSION_MAJOR; common->versionMinor = RDPDR_VERSION_MINOR_RDP10X; common->clientID = SCARD_DEVICE_ID; @@ -1557,7 +1557,7 @@ static BOOL pf_channel_rdpdr_client_pass_message(pServerContext* ps, pClientCont WINPR_ATTR_UNUSED UINT16 channelId, const char* channel_name, wStream* s) { - pf_channel_client_context* rdpdr = NULL; + pf_channel_client_context* rdpdr = nullptr; WINPR_ASSERT(ps); WINPR_ASSERT(pc); @@ -1739,9 +1739,9 @@ WINPR_ATTR_NODISCARD static void* stream_copy(const void* obj) { const wStream* src = obj; - wStream* dst = Stream_New(NULL, Stream_Capacity(src)); + wStream* dst = Stream_New(nullptr, Stream_Capacity(src)); if (!dst) - return NULL; + return nullptr; memcpy(Stream_Buffer(dst), Stream_ConstBuffer(src), Stream_Capacity(dst)); Stream_SetLength(dst, Stream_Length(src)); Stream_SetPosition(dst, Stream_GetPosition(src)); @@ -1767,8 +1767,8 @@ static const char* pf_channel_rdpdr_client_context(void* arg) BOOL pf_channel_rdpdr_client_new(pClientContext* pc) { - wObject* obj = NULL; - pf_channel_client_context* rdpdr = NULL; + wObject* obj = nullptr; + pf_channel_client_context* rdpdr = nullptr; WINPR_ASSERT(pc); WINPR_ASSERT(pc->interceptContextMap); @@ -1835,8 +1835,8 @@ static const char* pf_channel_rdpdr_server_context(void* arg) BOOL pf_channel_rdpdr_server_new(pServerContext* ps) { - pf_channel_server_context* rdpdr = NULL; - PULONG pSessionId = NULL; + pf_channel_server_context* rdpdr = nullptr; + PULONG pSessionId = nullptr; DWORD BytesReturned = 0; WINPR_ASSERT(ps); @@ -1866,7 +1866,7 @@ BOOL pf_channel_rdpdr_server_new(pServerContext* ps) } rdpdr->handle = WTSVirtualChannelOpenEx(rdpdr->SessionId, RDPDR_SVC_CHANNEL_NAME, 0); - if (rdpdr->handle == 0) + if (rdpdr->handle == nullptr) goto fail; if (!HashTable_Insert(ps->interceptContextMap, RDPDR_SVC_CHANNEL_NAME, rdpdr)) goto fail; @@ -1888,7 +1888,7 @@ void pf_channel_rdpdr_server_free(pServerContext* ps) WINPR_ATTR_NODISCARD static pf_channel_server_context* get_channel(pServerContext* ps, BOOL send) { - pf_channel_server_context* rdpdr = NULL; + pf_channel_server_context* rdpdr = nullptr; WINPR_ASSERT(ps); WINPR_ASSERT(ps->interceptContextMap); @@ -1898,7 +1898,7 @@ static pf_channel_server_context* get_channel(pServerContext* ps, BOOL send) SERVER_RXTX_LOG(send, WLog_Get(RTAG), WLOG_ERROR, "Channel %s missing context in interceptContextMap", RDPDR_SVC_CHANNEL_NAME); - return NULL; + return nullptr; } return rdpdr; @@ -1907,8 +1907,8 @@ static pf_channel_server_context* get_channel(pServerContext* ps, BOOL send) BOOL pf_channel_rdpdr_server_handle(pServerContext* ps, UINT16 channelId, const char* channel_name, const BYTE* xdata, size_t xsize, UINT32 flags, size_t totalSize) { - wStream* s = NULL; - pClientContext* pc = NULL; + wStream* s = nullptr; + pClientContext* pc = nullptr; pf_channel_server_context* rdpdr = get_channel(ps, FALSE); if (!rdpdr) return FALSE; @@ -2002,7 +2002,7 @@ BOOL pf_channel_rdpdr_server_announce(pServerContext* ps) BOOL pf_channel_rdpdr_client_reset(pClientContext* pc) { - pf_channel_client_context* rdpdr = NULL; + pf_channel_client_context* rdpdr = nullptr; WINPR_ASSERT(pc); WINPR_ASSERT(pc->pdata); diff --git a/server/proxy/channels/pf_channel_smartcard.c b/server/proxy/channels/pf_channel_smartcard.c index 06e854f66..da1a9c3f2 100644 --- a/server/proxy/channels/pf_channel_smartcard.c +++ b/server/proxy/channels/pf_channel_smartcard.c @@ -59,7 +59,7 @@ typedef struct WINPR_ATTR_NODISCARD static pf_channel_client_context* scard_get_client_context(pClientContext* pc) { - pf_channel_client_context* scard = NULL; + pf_channel_client_context* scard = nullptr; WINPR_ASSERT(pc); WINPR_ASSERT(pc->interceptContextMap); @@ -140,7 +140,7 @@ WINPR_ATTR_NODISCARD static BOOL start_irp_thread(pf_channel_client_context* scard, const pf_channel_client_queue_element* e) { - PTP_WORK work = NULL; + PTP_WORK work = nullptr; struct thread_arg* arg = calloc(1, sizeof(struct thread_arg)); if (!arg) return FALSE; @@ -149,7 +149,7 @@ static BOOL start_irp_thread(pf_channel_client_context* scard, if (!arg->e) goto fail; - work = CreateThreadpoolWork(irp_thread, arg, NULL); + work = CreateThreadpoolWork(irp_thread, arg, nullptr); if (!work) goto fail; ArrayList_Append(scard->workObjects, work); @@ -315,22 +315,22 @@ WINPR_ATTR_NODISCARD static void* queue_copy(const void* obj) { const pf_channel_client_queue_element* other = obj; - pf_channel_client_queue_element* copy = NULL; + pf_channel_client_queue_element* copy = nullptr; if (!other) - return NULL; + return nullptr; copy = calloc(1, sizeof(pf_channel_client_queue_element)); if (!copy) - return NULL; + return nullptr; *copy = *other; - copy->out = Stream_New(NULL, Stream_Capacity(other->out)); + copy->out = Stream_New(nullptr, Stream_Capacity(other->out)); if (!copy->out) goto fail; Stream_Write(copy->out, Stream_Buffer(other->out), Stream_GetPosition(other->out)); return copy; fail: queue_free(copy); - return NULL; + return nullptr; } static void work_object_free(void* arg) @@ -341,8 +341,8 @@ static void work_object_free(void* arg) BOOL pf_channel_smartcard_client_new(pClientContext* pc) { - pf_channel_client_context* scard = NULL; - wObject* obj = NULL; + pf_channel_client_context* scard = nullptr; + wObject* obj = nullptr; WINPR_ASSERT(pc); WINPR_ASSERT(pc->interceptContextMap); diff --git a/server/proxy/cli/freerdp_proxy.c b/server/proxy/cli/freerdp_proxy.c index 1ead04905..f7a676e2b 100644 --- a/server/proxy/cli/freerdp_proxy.c +++ b/server/proxy/cli/freerdp_proxy.c @@ -32,7 +32,7 @@ #define TAG PROXY_TAG("server") -static proxyServer* server = NULL; +static proxyServer* server = nullptr; #if defined(_WIN32) WINPR_ATTR_NODISCARD diff --git a/server/proxy/pf_channel.c b/server/proxy/pf_channel.c index 8fe1847f2..cefdc9bb2 100644 --- a/server/proxy/pf_channel.c +++ b/server/proxy/pf_channel.c @@ -57,7 +57,7 @@ static BOOL channelTracker_resetCurrentPacket(ChannelStateTracker* tracker) } if (create) - tracker->currentPacket = Stream_New(NULL, 10ULL * 1024ULL); + tracker->currentPacket = Stream_New(nullptr, 10ULL * 1024ULL); if (!tracker->currentPacket) return FALSE; Stream_SetPosition(tracker->currentPacket, 0); @@ -89,7 +89,7 @@ fail: WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC channelTracker_free(ret); WINPR_PRAGMA_DIAG_POP - return NULL; + return nullptr; } PfChannelResult channelTracker_update(ChannelStateTracker* tracker, const BYTE* xdata, size_t xsize, @@ -177,9 +177,9 @@ void channelTracker_free(ChannelStateTracker* t) PfChannelResult channelTracker_flushCurrent(ChannelStateTracker* t, BOOL first, BOOL last, BOOL toBack) { - proxyData* pdata = NULL; - pServerContext* ps = NULL; - pServerStaticChannelContext* channel = NULL; + proxyData* pdata = nullptr; + pServerContext* ps = nullptr; + pServerStaticChannelContext* channel = nullptr; UINT32 flags = CHANNEL_FLAG_FIRST; BOOL r = 0; const char* direction = toBack ? "F->B" : "B->F"; diff --git a/server/proxy/pf_client.c b/server/proxy/pf_client.c index 2fcf7ec9f..51b95db56 100644 --- a/server/proxy/pf_client.c +++ b/server/proxy/pf_client.c @@ -73,7 +73,7 @@ static BOOL proxy_server_reactivate(rdpContext* ps, const rdpContext* pc) static void pf_client_on_error_info(void* ctx, const ErrorInfoEventArgs* e) { pClientContext* pc = (pClientContext*)ctx; - pServerContext* ps = NULL; + pServerContext* ps = nullptr; WINPR_ASSERT(pc); WINPR_ASSERT(pc->pdata); @@ -99,8 +99,8 @@ static void pf_client_on_error_info(void* ctx, const ErrorInfoEventArgs* e) static void pf_client_on_activated(void* ctx, WINPR_ATTR_UNUSED const ActivatedEventArgs* e) { pClientContext* pc = (pClientContext*)ctx; - pServerContext* ps = NULL; - freerdp_peer* peer = NULL; + pServerContext* ps = nullptr; + freerdp_peer* peer = nullptr; WINPR_ASSERT(pc); WINPR_ASSERT(pc->pdata); @@ -144,10 +144,10 @@ static BOOL pf_client_load_rdpsnd(pClientContext* pc) WINPR_ATTR_NODISCARD static BOOL pf_client_use_peer_load_balance_info(pClientContext* pc) { - pServerContext* ps = NULL; - rdpSettings* settings = NULL; + pServerContext* ps = nullptr; + rdpSettings* settings = nullptr; DWORD lb_info_len = 0; - const char* lb_info = NULL; + const char* lb_info = nullptr; WINPR_ASSERT(pc); WINPR_ASSERT(pc->pdata); @@ -196,10 +196,10 @@ static BOOL pf_client_use_proxy_smartcard_auth(const rdpSettings* settings) WINPR_ATTR_NODISCARD static BOOL pf_client_pre_connect(freerdp* instance) { - pClientContext* pc = NULL; - pServerContext* ps = NULL; - const proxyConfig* config = NULL; - rdpSettings* settings = NULL; + pClientContext* pc = nullptr; + pServerContext* ps = nullptr; + const proxyConfig* config = nullptr; + rdpSettings* settings = nullptr; WINPR_ASSERT(instance); pc = (pClientContext*)instance->context; @@ -333,10 +333,10 @@ static BOOL pf_client_update_back_id(pServerContext* ps, const char* name, UINT3 WINPR_ATTR_NODISCARD static BOOL pf_client_load_channels(freerdp* instance) { - pClientContext* pc = NULL; - pServerContext* ps = NULL; - const proxyConfig* config = NULL; - rdpSettings* settings = NULL; + pClientContext* pc = nullptr; + pServerContext* ps = nullptr; + const proxyConfig* config = nullptr; + rdpSettings* settings = nullptr; WINPR_ASSERT(instance); pc = (pClientContext*)instance->context; @@ -431,10 +431,10 @@ static BOOL pf_client_receive_channel_data_hook(freerdp* instance, UINT16 channe const BYTE* xdata, size_t xsize, UINT32 flags, size_t totalSize) { - pClientContext* pc = NULL; - pServerContext* ps = NULL; - proxyData* pdata = NULL; - pServerStaticChannelContext* channel = NULL; + pClientContext* pc = nullptr; + pServerContext* ps = nullptr; + proxyData* pdata = nullptr; + pServerStaticChannelContext* channel = nullptr; UINT64 channelId64 = channelId; WINPR_ASSERT(instance); @@ -478,8 +478,8 @@ static BOOL pf_client_receive_channel_data_hook(freerdp* instance, UINT16 channe WINPR_ATTR_NODISCARD static BOOL pf_client_on_server_heartbeat(freerdp* instance, BYTE period, BYTE count1, BYTE count2) { - pClientContext* pc = NULL; - pServerContext* ps = NULL; + pClientContext* pc = nullptr; + pServerContext* ps = nullptr; WINPR_ASSERT(instance); pc = (pClientContext*)instance->context; @@ -509,7 +509,7 @@ static BOOL sendQueuedChannelData(pClientContext* pc) if (pc->connected) { - proxyChannelDataEventInfo* ev = NULL; + proxyChannelDataEventInfo* ev = nullptr; Queue_Lock(pc->cached_server_channel_data); while (rc && (ev = Queue_Dequeue(pc->cached_server_channel_data))) @@ -595,8 +595,8 @@ static BOOL pf_client_post_connect(freerdp* instance) */ static void pf_client_post_disconnect(freerdp* instance) { - pClientContext* pc = NULL; - proxyData* pdata = NULL; + pClientContext* pc = nullptr; + proxyData* pdata = nullptr; if (!instance) return; @@ -655,8 +655,8 @@ static BOOL pf_client_redirect(freerdp* instance) WINPR_ATTR_NODISCARD static BOOL pf_client_should_retry_without_nla(pClientContext* pc) { - rdpSettings* settings = NULL; - const proxyConfig* config = NULL; + rdpSettings* settings = nullptr; + const proxyConfig* config = nullptr; WINPR_ASSERT(pc); WINPR_ASSERT(pc->pdata); @@ -696,9 +696,9 @@ static BOOL pf_client_set_security_settings(pClientContext* pc) return FALSE; /* Reset username/domain, we will get that info later from the sc cert */ - if (!freerdp_settings_set_string(settings, FreeRDP_Username, NULL)) + if (!freerdp_settings_set_string(settings, FreeRDP_Username, nullptr)) return FALSE; - if (!freerdp_settings_set_string(settings, FreeRDP_Domain, NULL)) + if (!freerdp_settings_set_string(settings, FreeRDP_Domain, nullptr)) return FALSE; } @@ -708,8 +708,8 @@ static BOOL pf_client_set_security_settings(pClientContext* pc) WINPR_ATTR_NODISCARD static BOOL pf_client_connect_without_nla(pClientContext* pc) { - freerdp* instance = NULL; - rdpSettings* settings = NULL; + freerdp* instance = nullptr; + rdpSettings* settings = nullptr; WINPR_ASSERT(pc); instance = pc->context.instance; @@ -737,8 +737,8 @@ static BOOL pf_client_connect_without_nla(pClientContext* pc) WINPR_ATTR_NODISCARD static BOOL pf_client_connect(freerdp* instance) { - pClientContext* pc = NULL; - rdpSettings* settings = NULL; + pClientContext* pc = nullptr; + rdpSettings* settings = nullptr; BOOL rc = FALSE; BOOL retry = FALSE; @@ -793,8 +793,8 @@ out: WINPR_ATTR_NODISCARD static DWORD WINAPI pf_client_thread_proc(pClientContext* pc) { - freerdp* instance = NULL; - proxyData* pdata = NULL; + freerdp* instance = nullptr; + proxyData* pdata = nullptr; DWORD nCount = 0; DWORD status = 0; HANDLE handles[MAXIMUM_WAIT_OBJECTS] = WINPR_C_ARRAY_INIT; @@ -897,7 +897,7 @@ static void pf_client_context_free(freerdp* instance, rdpContext* context) if (!pc) return; - pc->sendChannelData = NULL; + pc->sendChannelData = nullptr; Queue_Free(pc->cached_server_channel_data); Stream_Free(pc->remote_pem, TRUE); free(pc->remote_hostname); @@ -909,7 +909,7 @@ WINPR_ATTR_NODISCARD static int pf_client_verify_X509_certificate(freerdp* instance, const BYTE* data, size_t length, const char* hostname, UINT16 port, DWORD flags) { - pClientContext* pc = NULL; + pClientContext* pc = nullptr; WINPR_ASSERT(instance); WINPR_ASSERT(data); @@ -924,7 +924,7 @@ static int pf_client_verify_X509_certificate(freerdp* instance, const BYTE* data Stream_SetPosition(pc->remote_pem, 0); free(pc->remote_hostname); - pc->remote_hostname = NULL; + pc->remote_hostname = nullptr; if (length > 0) Stream_Write(pc->remote_pem, data, length); @@ -969,7 +969,7 @@ static void* channel_data_copy(const void* obj) void* pv; } cnv; const proxyChannelDataEventInfo* src = obj; - proxyChannelDataEventInfo* dst = NULL; + proxyChannelDataEventInfo* dst = nullptr; WINPR_ASSERT(src); @@ -994,13 +994,13 @@ static void* channel_data_copy(const void* obj) fail: channel_data_free(dst); - return NULL; + return nullptr; } WINPR_ATTR_NODISCARD static BOOL pf_client_client_new(freerdp* instance, rdpContext* context) { - wObject* obj = NULL; + wObject* obj = nullptr; pClientContext* pc = (pClientContext*)context; if (!instance || !context) @@ -1014,7 +1014,7 @@ static BOOL pf_client_client_new(freerdp* instance, rdpContext* context) instance->LogonErrorInfo = pf_logon_error_info; instance->VerifyX509Certificate = pf_client_verify_X509_certificate; - pc->remote_pem = Stream_New(NULL, 4096); + pc->remote_pem = Stream_New(nullptr, 4096); if (!pc->remote_pem) return FALSE; @@ -1045,7 +1045,7 @@ WINPR_ATTR_NODISCARD static int pf_client_client_stop(rdpContext* context) { pClientContext* pc = (pClientContext*)context; - proxyData* pdata = NULL; + proxyData* pdata = nullptr; WINPR_ASSERT(pc); pdata = pc->pdata; diff --git a/server/proxy/pf_config.c b/server/proxy/pf_config.c index fc055f577..b27ecafe6 100644 --- a/server/proxy/pf_config.c +++ b/server/proxy/pf_config.c @@ -52,7 +52,7 @@ #define CONFIG_PRINT_SECTION_KEY(section, key) WLog_INFO(TAG, "\t%s/%s:", section, key) #define CONFIG_PRINT_STR(config, key) WLog_INFO(TAG, "\t\t%s: %s", #key, (config)->key) #define CONFIG_PRINT_STR_CONTENT(config, key) \ - WLog_INFO(TAG, "\t\t%s: %s", #key, (config)->key ? "set" : NULL) + WLog_INFO(TAG, "\t\t%s: %s", #key, (config)->key ? "set" : nullptr) #define CONFIG_PRINT_BOOL(config, key) WLog_INFO(TAG, "\t\t%s: %s", #key, boolstr((config)->key)) #define CONFIG_PRINT_UINT16(config, key) WLog_INFO(TAG, "\t\t%s: %" PRIu16 "", #key, (config)->key) #define CONFIG_PRINT_UINT32(config, key) WLog_INFO(TAG, "\t\t%s: %" PRIu32 "", #key, (config)->key) @@ -120,12 +120,12 @@ WINPR_ATTR_NODISCARD static char** pf_config_parse_comma_separated_list(const char* list, size_t* count) { if (!list || !count) - return NULL; + return nullptr; if (strlen(list) == 0) { *count = 0; - return NULL; + return nullptr; } return CommandLineParseCommaSeparatedValues(list, count); @@ -136,7 +136,7 @@ static BOOL pf_config_get_uint16(wIniFile* ini, const char* section, const char* UINT16* result, BOOL required) { int val = 0; - const char* strval = NULL; + const char* strval = nullptr; WINPR_ASSERT(result); @@ -186,7 +186,7 @@ WINPR_ATTR_NODISCARD static BOOL pf_config_get_bool(wIniFile* ini, const char* section, const char* key, BOOL fallback) { int num_value = 0; - const char* str_value = NULL; + const char* str_value = nullptr; str_value = IniFile_GetKeyValueString(ini, section, key); if (!str_value) @@ -210,7 +210,7 @@ WINPR_ATTR_NODISCARD static const char* pf_config_get_str(wIniFile* ini, const char* section, const char* key, BOOL required) { - const char* value = NULL; + const char* value = nullptr; value = IniFile_GetKeyValueString(ini, section, key); @@ -218,7 +218,7 @@ static const char* pf_config_get_str(wIniFile* ini, const char* section, const c { if (required) WLog_ERR(TAG, "key '%s.%s' not found.", section, key); - return NULL; + return nullptr; } return value; @@ -248,7 +248,7 @@ static BOOL pf_config_load_server(wIniFile* ini, proxyConfig* config) WINPR_ATTR_NODISCARD static BOOL pf_config_load_target(wIniFile* ini, proxyConfig* config) { - const char* target_value = NULL; + const char* target_value = nullptr; WINPR_ASSERT(config); config->FixedTarget = pf_config_get_bool(ini, section_target, key_target_fixed, FALSE); @@ -364,8 +364,8 @@ static BOOL pf_config_load_security(wIniFile* ini, proxyConfig* config) WINPR_ATTR_NODISCARD static BOOL pf_config_load_modules(wIniFile* ini, proxyConfig* config) { - const char* modules_to_load = NULL; - const char* required_modules = NULL; + const char* modules_to_load = nullptr; + const char* required_modules = nullptr; modules_to_load = pf_config_get_str(ini, section_plugins, key_plugins_modules, FALSE); required_modules = pf_config_get_str(ini, section_plugins, key_plugins_required, FALSE); @@ -386,11 +386,11 @@ static char* pf_config_decode_base64(const char* data, const char* name, size_t* "-----BEGIN RSA PRIVATE KEY-----" }; size_t decoded_length = 0; - char* decoded = NULL; + char* decoded = nullptr; if (!data) { - WLog_ERR(TAG, "Invalid base64 data [NULL] for %s", name); - return NULL; + WLog_ERR(TAG, "Invalid base64 data [nullptr] for %s", name); + return nullptr; } WINPR_ASSERT(name); @@ -442,7 +442,7 @@ static char* pf_config_decode_base64(const char* data, const char* name, size_t* { WLog_ERR(TAG, "Failed to decode base64 data of length %" PRIuz " for %s", length, name); free(decoded); - return NULL; + return nullptr; } *pLength = strnlen(decoded, decoded_length) + 1; @@ -452,8 +452,8 @@ static char* pf_config_decode_base64(const char* data, const char* name, size_t* WINPR_ATTR_NODISCARD static BOOL pf_config_load_certificates(wIniFile* ini, proxyConfig* config) { - const char* tmp1 = NULL; - const char* tmp2 = NULL; + const char* tmp1 = nullptr; + const char* tmp2 = nullptr; WINPR_ASSERT(ini); WINPR_ASSERT(config); @@ -561,7 +561,7 @@ static BOOL pf_config_load_certificates(wIniFile* ini, proxyConfig* config) proxyConfig* server_config_load_ini(wIniFile* ini) { - proxyConfig* config = NULL; + proxyConfig* config = nullptr; WINPR_ASSERT(ini); @@ -603,7 +603,7 @@ out: pf_server_config_free(config); WINPR_PRAGMA_DIAG_POP - return NULL; + return nullptr; } BOOL pf_server_config_dump(const char* file) @@ -724,15 +724,15 @@ fail: proxyConfig* pf_server_config_load_buffer(const char* buffer) { - proxyConfig* config = NULL; - wIniFile* ini = NULL; + proxyConfig* config = nullptr; + wIniFile* ini = nullptr; ini = IniFile_New(); if (!ini) { WLog_ERR(TAG, "IniFile_New() failed!"); - return NULL; + return nullptr; } if (IniFile_ReadBuffer(ini, buffer) < 0) @@ -749,13 +749,13 @@ out: proxyConfig* pf_server_config_load_file(const char* path) { - proxyConfig* config = NULL; + proxyConfig* config = nullptr; wIniFile* ini = IniFile_New(); if (!ini) { WLog_ERR(TAG, "IniFile_New() failed!"); - return NULL; + return nullptr; } if (IniFile_ReadFile(ini, path) < 0) @@ -873,7 +873,7 @@ static void znfree(char* str, size_t len) void pf_server_config_free(proxyConfig* config) { - if (config == NULL) + if (config == nullptr) return; free(config->Host); @@ -907,7 +907,7 @@ const char* pf_config_required_plugin(const proxyConfig* config, size_t index) { WINPR_ASSERT(config); if (index >= config->RequiredPluginsCount) - return NULL; + return nullptr; return config->RequiredPlugins[index]; } @@ -935,7 +935,7 @@ const char** pf_config_modules(const proxyConfig* config) WINPR_ATTR_NODISCARD static BOOL pf_config_copy_string(char** dst, const char* src) { - *dst = NULL; + *dst = nullptr; if (src) *dst = _strdup(src); return TRUE; @@ -944,7 +944,7 @@ static BOOL pf_config_copy_string(char** dst, const char* src) WINPR_ATTR_NODISCARD static BOOL pf_config_copy_string_n(char** dst, const char* src, size_t size) { - *dst = NULL; + *dst = nullptr; if (src && (size > 0)) { @@ -965,7 +965,7 @@ static BOOL pf_config_copy_string_list(char*** dst, size_t* size, char** src, si WINPR_ASSERT(size); WINPR_ASSERT(src || (srcSize == 0)); - *dst = NULL; + *dst = nullptr; *size = 0; if (srcSize > INT32_MAX) return FALSE; @@ -1063,7 +1063,7 @@ static BOOL config_plugin_unload(proxyPlugin* plugin) if (plugin) { free(plugin->custom); - plugin->custom = NULL; + plugin->custom = nullptr; } return TRUE; @@ -1074,8 +1074,8 @@ static BOOL config_plugin_keyboard_event(proxyPlugin* plugin, WINPR_ATTR_UNUSED void* param) { BOOL rc = 0; - const struct config_plugin_data* custom = NULL; - const proxyConfig* cfg = NULL; + const struct config_plugin_data* custom = nullptr; + const proxyConfig* cfg = nullptr; const proxyKeyboardEventInfo* event_data = (const proxyKeyboardEventInfo*)(param); WINPR_ASSERT(plugin); @@ -1100,8 +1100,8 @@ static BOOL config_plugin_unicode_event(proxyPlugin* plugin, WINPR_ATTR_UNUSED p void* param) { BOOL rc = 0; - const struct config_plugin_data* custom = NULL; - const proxyConfig* cfg = NULL; + const struct config_plugin_data* custom = nullptr; + const proxyConfig* cfg = nullptr; const proxyUnicodeEventInfo* event_data = (const proxyUnicodeEventInfo*)(param); WINPR_ASSERT(plugin); @@ -1126,8 +1126,8 @@ static BOOL config_plugin_mouse_event(proxyPlugin* plugin, WINPR_ATTR_UNUSED pro void* param) { BOOL rc = 0; - const struct config_plugin_data* custom = NULL; - const proxyConfig* cfg = NULL; + const struct config_plugin_data* custom = nullptr; + const proxyConfig* cfg = nullptr; const proxyMouseEventInfo* event_data = (const proxyMouseEventInfo*)(param); WINPR_ASSERT(plugin); @@ -1151,8 +1151,8 @@ static BOOL config_plugin_mouse_ex_event(proxyPlugin* plugin, WINPR_ATTR_UNUSED void* param) { BOOL rc = 0; - const struct config_plugin_data* custom = NULL; - const proxyConfig* cfg = NULL; + const struct config_plugin_data* custom = nullptr; + const proxyConfig* cfg = nullptr; const proxyMouseExEventInfo* event_data = (const proxyMouseExEventInfo*)(param); WINPR_ASSERT(plugin); @@ -1322,7 +1322,7 @@ static BOOL config_plugin_channel_create(proxyPlugin* plugin, WINPR_ATTR_UNUSED BOOL pf_config_plugin(proxyPluginsManager* plugins_manager, void* userdata) { - struct config_plugin_data* custom = NULL; + struct config_plugin_data* custom = nullptr; proxyPlugin plugin = WINPR_C_ARRAY_INIT; plugin.name = config_plugin_name; diff --git a/server/proxy/pf_context.c b/server/proxy/pf_context.c index 91ee332b1..806d8770e 100644 --- a/server/proxy/pf_context.c +++ b/server/proxy/pf_context.c @@ -88,7 +88,7 @@ pServerStaticChannelContext* StaticChannelContext_new(pServerContext* ps, const if (!ret) { PROXY_LOG_ERR(TAG, ps, "error allocating channel context for '%s'", name); - return NULL; + return nullptr; } ret->front_channel_id = id; @@ -97,7 +97,7 @@ pServerStaticChannelContext* StaticChannelContext_new(pServerContext* ps, const { PROXY_LOG_ERR(TAG, ps, "error allocating name in channel context for '%s'", name); free(ret); - return NULL; + return nullptr; } proxyChannelToInterceptData channel = { .name = name, .channelId = id, .intercept = FALSE }; @@ -136,20 +136,20 @@ static void client_to_proxy_context_free(freerdp_peer* client, rdpContext* ctx); WINPR_ATTR_NODISCARD static BOOL client_to_proxy_context_new(freerdp_peer* client, rdpContext* ctx) { - wObject* obj = NULL; + wObject* obj = nullptr; pServerContext* context = (pServerContext*)ctx; WINPR_ASSERT(client); WINPR_ASSERT(context); - context->dynvcReady = NULL; + context->dynvcReady = nullptr; context->vcm = WTSOpenServerA((LPSTR)client->context); if (!context->vcm || context->vcm == INVALID_HANDLE_VALUE) goto error; - if (!(context->dynvcReady = CreateEvent(NULL, TRUE, FALSE, NULL))) + if (!(context->dynvcReady = CreateEvent(nullptr, TRUE, FALSE, nullptr))) goto error; context->interceptContextMap = HashTable_New(FALSE); @@ -204,7 +204,7 @@ void client_to_proxy_context_free(freerdp_peer* client, rdpContext* ctx) if (context->dynvcReady) { (void)CloseHandle(context->dynvcReady); - context->dynvcReady = NULL; + context->dynvcReady = nullptr; } HashTable_Free(context->interceptContextMap); @@ -213,7 +213,7 @@ void client_to_proxy_context_free(freerdp_peer* client, rdpContext* ctx) if (context->vcm && (context->vcm != INVALID_HANDLE_VALUE)) WTSCloseServer(context->vcm); - context->vcm = NULL; + context->vcm = nullptr; } BOOL pf_context_init_server_context(freerdp_peer* client) @@ -259,7 +259,7 @@ void intercept_context_entry_free(void* obj) BOOL pf_context_copy_settings(rdpSettings* dst, const rdpSettings* src) { BOOL rc = FALSE; - rdpSettings* before_copy = NULL; + rdpSettings* before_copy = nullptr; const FreeRDP_Settings_Keys_String to_revert[] = { FreeRDP_ConfigPath, FreeRDP_CertificateName }; @@ -288,11 +288,11 @@ BOOL pf_context_copy_settings(rdpSettings* dst, const rdpSettings* src) goto out_fail; /* - * RdpServerRsaKey must be set to NULL if `dst` is client's context - * it must be freed before setting it to NULL to avoid a memory leak! + * RdpServerRsaKey must be set to nullptr if `dst` is client's context + * it must be freed before setting it to nullptr to avoid a memory leak! */ - if (!freerdp_settings_set_pointer_len(dst, FreeRDP_RdpServerRsaKey, NULL, 1)) + if (!freerdp_settings_set_pointer_len(dst, FreeRDP_RdpServerRsaKey, nullptr, 1)) goto out_fail; } @@ -314,7 +314,7 @@ pClientContext* pf_context_create_client_context(const rdpSettings* clientSettin rdpContext* context = freerdp_client_context_new(&clientEntryPoints); if (!context) - return NULL; + return nullptr; pClientContext* pc = (pClientContext*)context; @@ -324,23 +324,23 @@ pClientContext* pf_context_create_client_context(const rdpSettings* clientSettin return pc; error: freerdp_client_context_free(context); - return NULL; + return nullptr; } proxyData* proxy_data_new(void) { BYTE temp[16]; - char* hex = NULL; - proxyData* pdata = NULL; + char* hex = nullptr; + proxyData* pdata = nullptr; pdata = calloc(1, sizeof(proxyData)); if (!pdata) - return NULL; + return nullptr; - if (!(pdata->abort_event = CreateEvent(NULL, TRUE, FALSE, NULL))) + if (!(pdata->abort_event = CreateEvent(nullptr, TRUE, FALSE, nullptr))) goto error; - if (!(pdata->gfx_server_ready = CreateEvent(NULL, TRUE, FALSE, NULL))) + if (!(pdata->gfx_server_ready = CreateEvent(nullptr, TRUE, FALSE, nullptr))) goto error; winpr_RAND(&temp, 16); @@ -365,7 +365,7 @@ error: WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC proxy_data_free(pdata); WINPR_PRAGMA_DIAG_POP - return NULL; + return nullptr; } /* updates circular pointers between proxyData and pClientContext instances */ diff --git a/server/proxy/pf_input.c b/server/proxy/pf_input.c index 727337385..7de89aaeb 100644 --- a/server/proxy/pf_input.c +++ b/server/proxy/pf_input.c @@ -48,8 +48,8 @@ static BOOL pf_server_check_and_sync_input_state(pClientContext* pc) WINPR_ATTR_NODISCARD static BOOL pf_server_synchronize_event(rdpInput* input, UINT32 flags) { - pServerContext* ps = NULL; - pClientContext* pc = NULL; + pServerContext* ps = nullptr; + pClientContext* pc = nullptr; WINPR_ASSERT(input); ps = (pServerContext*)input->context; @@ -68,10 +68,10 @@ static BOOL pf_server_synchronize_event(rdpInput* input, UINT32 flags) WINPR_ATTR_NODISCARD static BOOL pf_server_keyboard_event(rdpInput* input, UINT16 flags, UINT8 code) { - const proxyConfig* config = NULL; + const proxyConfig* config = nullptr; proxyKeyboardEventInfo event = WINPR_C_ARRAY_INIT; - pServerContext* ps = NULL; - pClientContext* pc = NULL; + pServerContext* ps = nullptr; + pClientContext* pc = nullptr; WINPR_ASSERT(input); ps = (pServerContext*)input->context; @@ -102,10 +102,10 @@ static BOOL pf_server_keyboard_event(rdpInput* input, UINT16 flags, UINT8 code) WINPR_ATTR_NODISCARD static BOOL pf_server_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code) { - const proxyConfig* config = NULL; + const proxyConfig* config = nullptr; proxyUnicodeEventInfo event = WINPR_C_ARRAY_INIT; - pServerContext* ps = NULL; - pClientContext* pc = NULL; + pServerContext* ps = nullptr; + pClientContext* pc = nullptr; WINPR_ASSERT(input); ps = (pServerContext*)input->context; @@ -135,9 +135,9 @@ WINPR_ATTR_NODISCARD static BOOL pf_server_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y) { proxyMouseEventInfo event = WINPR_C_ARRAY_INIT; - const proxyConfig* config = NULL; - pServerContext* ps = NULL; - pClientContext* pc = NULL; + const proxyConfig* config = nullptr; + pServerContext* ps = nullptr; + pClientContext* pc = nullptr; WINPR_ASSERT(input); ps = (pServerContext*)input->context; @@ -169,10 +169,10 @@ static BOOL pf_server_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT1 WINPR_ATTR_NODISCARD static BOOL pf_server_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y) { - const proxyConfig* config = NULL; + const proxyConfig* config = nullptr; proxyMouseExEventInfo event = WINPR_C_ARRAY_INIT; - pServerContext* ps = NULL; - pClientContext* pc = NULL; + pServerContext* ps = nullptr; + pClientContext* pc = nullptr; WINPR_ASSERT(input); ps = (pServerContext*)input->context; diff --git a/server/proxy/pf_modules.c b/server/proxy/pf_modules.c index 3f245d832..dbfea2251 100644 --- a/server/proxy/pf_modules.c +++ b/server/proxy/pf_modules.c @@ -357,7 +357,7 @@ static BOOL pf_modules_set_plugin_data(WINPR_ATTR_UNUSED proxyPluginsManager* mg WINPR_ASSERT(plugin_name); ccharconv.ccp = plugin_name; - if (data == NULL) /* no need to store anything */ + if (data == nullptr) /* no need to store anything */ return FALSE; if (!HashTable_Insert(pdata->modules_info, ccharconv.cp, data)) @@ -373,7 +373,7 @@ static BOOL pf_modules_set_plugin_data(WINPR_ATTR_UNUSED proxyPluginsManager* mg * returns per-session data needed a plugin. * * @context: current session server's rdpContext instance. - * if there's no data related to `plugin_name` in `context` (current session), a NULL will be + * if there's no data related to `plugin_name` in `context` (current session), a nullptr will be * returned. */ WINPR_ATTR_NODISCARD @@ -504,9 +504,9 @@ static BOOL pf_modules_load_static_module(const char* module_name, proxyModule* { WINPR_ASSERT(module); - HANDLE handle = GetModuleHandleA(NULL); + HANDLE handle = GetModuleHandleA(nullptr); - if (handle == NULL) + if (handle == nullptr) { WLog_DBG(TAG, "failed loading static library: %s", module_name); return FALSE; @@ -550,7 +550,7 @@ static BOOL pf_modules_load_dynamic_module(const char* module_path, proxyModule* HANDLE handle = LoadLibraryX(module_path); - if (handle == NULL) + if (handle == nullptr) { WLog_DBG(TAG, "failed loading external library: %s", module_path); return FALSE; @@ -649,18 +649,18 @@ static void* new_plugin(const void* obj) const proxyPlugin* src = obj; proxyPlugin* proxy = calloc(1, sizeof(proxyPlugin)); if (!proxy) - return NULL; + return nullptr; *proxy = *src; return proxy; } proxyModule* pf_modules_new(const char* root_dir, const char** modules, size_t count) { - wObject* obj = NULL; - char* path = NULL; + wObject* obj = nullptr; + char* path = nullptr; proxyModule* module = calloc(1, sizeof(proxyModule)); if (!module) - return NULL; + return nullptr; module->mgr.RegisterPlugin = pf_modules_register_plugin; module->mgr.SetPluginData = pf_modules_set_plugin_data; @@ -668,7 +668,7 @@ proxyModule* pf_modules_new(const char* root_dir, const char** modules, size_t c module->mgr.AbortConnect = pf_modules_abort_connect; module->plugins = ArrayList_New(FALSE); - if (module->plugins == NULL) + if (module->plugins == nullptr) { WLog_ERR(TAG, "ArrayList_New failed!"); goto error; @@ -680,7 +680,7 @@ proxyModule* pf_modules_new(const char* root_dir, const char** modules, size_t c obj->fnObjectNew = new_plugin; module->handles = ArrayList_New(FALSE); - if (module->handles == NULL) + if (module->handles == nullptr) { WLog_ERR(TAG, "ArrayList_New failed!"); @@ -698,7 +698,7 @@ proxyModule* pf_modules_new(const char* root_dir, const char** modules, size_t c if (!winpr_PathFileExists(path)) { - if (!winpr_PathMakePath(path, NULL)) + if (!winpr_PathMakePath(path, nullptr)) { WLog_ERR(TAG, "error occurred while creating modules directory: %s", root_dir); } @@ -710,7 +710,7 @@ proxyModule* pf_modules_new(const char* root_dir, const char** modules, size_t c for (size_t i = 0; i < count; i++) { const char* module_name = modules[i]; - if (!pf_modules_load_module(path, module_name, module, NULL)) + if (!pf_modules_load_module(path, module_name, module, nullptr)) WLog_WARN(TAG, "Failed to load proxy module '%s'", module_name); else WLog_INFO(TAG, "Successfully loaded proxy module '%s'", module_name); @@ -723,7 +723,7 @@ proxyModule* pf_modules_new(const char* root_dir, const char** modules, size_t c error: free(path); pf_modules_free(module); - return NULL; + return nullptr; } void pf_modules_free(proxyModule* module) diff --git a/server/proxy/pf_server.c b/server/proxy/pf_server.c index 0a77efc0c..4d645d1ec 100644 --- a/server/proxy/pf_server.c +++ b/server/proxy/pf_server.c @@ -70,7 +70,7 @@ static BOOL pf_server_parse_target_from_routing_token(rdpContext* context, rdpSe { #define TARGET_MAX (100) #define ROUTING_TOKEN_PREFIX "Cookie: msts=" - char* colon = NULL; + char* colon = nullptr; size_t len = 0; DWORD routing_token_length = 0; const size_t prefix_len = strnlen(ROUTING_TOKEN_PREFIX, sizeof(ROUTING_TOKEN_PREFIX)); @@ -97,7 +97,7 @@ static BOOL pf_server_parse_target_from_routing_token(rdpContext* context, rdpSe if (colon) { /* port is specified */ - unsigned long p = strtoul(colon + 1, NULL, 10); + unsigned long p = strtoul(colon + 1, nullptr, 10); if (p > USHRT_MAX) return FALSE; @@ -184,8 +184,9 @@ static BOOL pf_server_get_target_info(rdpContext* context, rdpSettings* settings { if (!ev.target_address) { - PROXY_LOG_ERR(TAG, ps, - "router: using CUSTOM_ADDR fetch method, but target_address == NULL"); + PROXY_LOG_ERR( + TAG, ps, + "router: using CUSTOM_ADDR fetch method, but target_address == nullptr"); return FALSE; } @@ -210,7 +211,7 @@ WINPR_ATTR_NODISCARD static BOOL pf_server_setup_channels(freerdp_peer* peer) { BOOL rc = FALSE; - char** accepted_channels = NULL; + char** accepted_channels = nullptr; size_t accepted_channels_count = 0; pServerContext* ps = (pServerContext*)peer->context; @@ -220,7 +221,7 @@ static BOOL pf_server_setup_channels(freerdp_peer* peer) for (size_t i = 0; i < accepted_channels_count; i++) { - pServerStaticChannelContext* channelContext = NULL; + pServerStaticChannelContext* channelContext = nullptr; const char* cname = accepted_channels[i]; UINT16 channelId = WTSChannelGetId(peer, cname); @@ -289,11 +290,11 @@ fail: WINPR_ATTR_NODISCARD static BOOL pf_server_post_connect(freerdp_peer* peer) { - pServerContext* ps = NULL; - pClientContext* pc = NULL; - rdpSettings* client_settings = NULL; - proxyData* pdata = NULL; - rdpSettings* frontSettings = NULL; + pServerContext* ps = nullptr; + pClientContext* pc = nullptr; + rdpSettings* client_settings = nullptr; + proxyData* pdata = nullptr; + rdpSettings* frontSettings = nullptr; WINPR_ASSERT(peer); @@ -315,7 +316,7 @@ static BOOL pf_server_post_connect(freerdp_peer* peer) } pc = pf_context_create_client_context(frontSettings); - if (pc == NULL) + if (pc == nullptr) { PROXY_LOG_ERR(TAG, ps, "failed to create client context!"); return FALSE; @@ -340,7 +341,7 @@ static BOOL pf_server_post_connect(freerdp_peer* peer) return FALSE; /* Start a proxy's client in it's own thread */ - if (!(pdata->client_thread = CreateThread(NULL, 0, pf_client_start, pc, 0, NULL))) + if (!(pdata->client_thread = CreateThread(nullptr, 0, pf_client_start, pc, 0, nullptr))) { PROXY_LOG_ERR(TAG, ps, "failed to create client thread"); return FALSE; @@ -352,9 +353,9 @@ static BOOL pf_server_post_connect(freerdp_peer* peer) WINPR_ATTR_NODISCARD static BOOL pf_server_activate(freerdp_peer* peer) { - pServerContext* ps = NULL; - proxyData* pdata = NULL; - rdpSettings* settings = NULL; + pServerContext* ps = nullptr; + proxyData* pdata = nullptr; + rdpSettings* settings = nullptr; WINPR_ASSERT(peer); @@ -378,8 +379,8 @@ WINPR_ATTR_NODISCARD static BOOL pf_server_logon(freerdp_peer* peer, const SEC_WINNT_AUTH_IDENTITY* identity, BOOL automatic) { - pServerContext* ps = NULL; - proxyData* pdata = NULL; + pServerContext* ps = nullptr; + proxyData* pdata = nullptr; proxyServerPeerLogon info = WINPR_C_ARRAY_INIT; WINPR_ASSERT(peer); @@ -489,7 +490,7 @@ static BOOL pf_server_initialize_peer_connection(freerdp_peer* peer) pdata->module = server->module; const proxyConfig* config = pdata->config = server->config; - rdpPrivateKey* key = freerdp_key_new_from_pem_enc(config->PrivateKeyPEM, NULL); + rdpPrivateKey* key = freerdp_key_new_from_pem_enc(config->PrivateKeyPEM, nullptr); if (!key) return FALSE; @@ -581,8 +582,8 @@ WINPR_ATTR_NODISCARD static DWORD WINAPI pf_server_handle_peer(LPVOID arg) { HANDLE eventHandles[MAXIMUM_WAIT_OBJECTS] = WINPR_C_ARRAY_INIT; - pServerContext* ps = NULL; - proxyData* pdata = NULL; + pServerContext* ps = nullptr; + proxyData* pdata = nullptr; peer_thread_args* args = arg; WINPR_ASSERT(args); @@ -761,8 +762,8 @@ out_free_peer: WINPR_ATTR_NODISCARD static BOOL pf_server_start_peer(freerdp_peer* client) { - HANDLE hThread = NULL; - proxyServer* server = NULL; + HANDLE hThread = nullptr; + proxyServer* server = nullptr; peer_thread_args* args = calloc(1, sizeof(peer_thread_args)); if (!args) return FALSE; @@ -773,7 +774,7 @@ static BOOL pf_server_start_peer(freerdp_peer* client) server = (proxyServer*)client->ContextExtra; WINPR_ASSERT(server); - hThread = CreateThread(NULL, 0, pf_server_handle_peer, args, CREATE_SUSPENDED, NULL); + hThread = CreateThread(nullptr, 0, pf_server_handle_peer, args, CREATE_SUSPENDED, nullptr); if (!hThread) { free(args); @@ -888,7 +889,7 @@ BOOL pf_server_start_with_peer_socket(proxyServer* server, int socket) { struct sockaddr_storage peer_addr; socklen_t len = sizeof(peer_addr); - freerdp_peer* client = NULL; + freerdp_peer* client = nullptr; WINPR_ASSERT(server); @@ -943,14 +944,14 @@ static void peer_free(void* obj) proxyServer* pf_server_new(const proxyConfig* config) { - wObject* obj = NULL; - proxyServer* server = NULL; + wObject* obj = nullptr; + proxyServer* server = nullptr; WINPR_ASSERT(config); server = calloc(1, sizeof(proxyServer)); if (!server) - return NULL; + return nullptr; if (!pf_config_clone(&server->config, config)) goto out; @@ -967,7 +968,7 @@ proxyServer* pf_server_new(const proxyConfig* config) if (!are_all_required_modules_loaded(server->module, server->config)) goto out; - server->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + server->stopEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr); if (!server->stopEvent) goto out; @@ -997,7 +998,7 @@ out: WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC pf_server_free(server); WINPR_PRAGMA_DIAG_POP - return NULL; + return nullptr; } BOOL pf_server_run(proxyServer* server) @@ -1006,7 +1007,7 @@ BOOL pf_server_run(proxyServer* server) HANDLE eventHandles[MAXIMUM_WAIT_OBJECTS] = WINPR_C_ARRAY_INIT; DWORD eventCount = 0; DWORD status = 0; - freerdp_listener* listener = NULL; + freerdp_listener* listener = nullptr; WINPR_ASSERT(server); diff --git a/server/proxy/pf_update.c b/server/proxy/pf_update.c index 0db436b32..cddac0500 100644 --- a/server/proxy/pf_update.c +++ b/server/proxy/pf_update.c @@ -39,7 +39,7 @@ WINPR_ATTR_NODISCARD static BOOL pf_server_refresh_rect(rdpContext* context, BYTE count, const RECTANGLE_16* areas) { pServerContext* ps = (pServerContext*)context; - rdpContext* pc = NULL; + rdpContext* pc = nullptr; WINPR_ASSERT(ps); WINPR_ASSERT(ps->pdata); pc = (rdpContext*)ps->pdata->pc; @@ -53,7 +53,7 @@ WINPR_ATTR_NODISCARD static BOOL pf_server_suppress_output(rdpContext* context, BYTE allow, const RECTANGLE_16* area) { pServerContext* ps = (pServerContext*)context; - rdpContext* pc = NULL; + rdpContext* pc = nullptr; WINPR_ASSERT(ps); WINPR_ASSERT(ps->pdata); pc = (rdpContext*)ps->pdata->pc; @@ -73,8 +73,8 @@ WINPR_ATTR_NODISCARD static BOOL pf_client_begin_paint(rdpContext* context) { pClientContext* pc = (pClientContext*)context; - proxyData* pdata = NULL; - rdpContext* ps = NULL; + proxyData* pdata = nullptr; + rdpContext* ps = nullptr; WINPR_ASSERT(pc); pdata = pc->pdata; WINPR_ASSERT(pdata); @@ -95,8 +95,8 @@ WINPR_ATTR_NODISCARD static BOOL pf_client_end_paint(rdpContext* context) { pClientContext* pc = (pClientContext*)context; - proxyData* pdata = NULL; - rdpContext* ps = NULL; + proxyData* pdata = nullptr; + rdpContext* ps = nullptr; WINPR_ASSERT(pc); pdata = pc->pdata; WINPR_ASSERT(pdata); @@ -121,8 +121,8 @@ WINPR_ATTR_NODISCARD static BOOL pf_client_bitmap_update(rdpContext* context, const BITMAP_UPDATE* bitmap) { pClientContext* pc = (pClientContext*)context; - proxyData* pdata = NULL; - rdpContext* ps = NULL; + proxyData* pdata = nullptr; + rdpContext* ps = nullptr; WINPR_ASSERT(pc); pdata = pc->pdata; WINPR_ASSERT(pdata); @@ -138,8 +138,8 @@ WINPR_ATTR_NODISCARD static BOOL pf_client_desktop_resize(rdpContext* context) { pClientContext* pc = (pClientContext*)context; - proxyData* pdata = NULL; - rdpContext* ps = NULL; + proxyData* pdata = nullptr; + rdpContext* ps = nullptr; WINPR_ASSERT(pc); pdata = pc->pdata; WINPR_ASSERT(pdata); @@ -162,8 +162,8 @@ static BOOL pf_client_remote_monitors(rdpContext* context, UINT32 count, const MONITOR_DEF* monitors) { pClientContext* pc = (pClientContext*)context; - proxyData* pdata = NULL; - rdpContext* ps = NULL; + proxyData* pdata = nullptr; + rdpContext* ps = nullptr; WINPR_ASSERT(pc); pdata = pc->pdata; WINPR_ASSERT(pdata); @@ -178,8 +178,8 @@ static BOOL pf_client_send_pointer_system(rdpContext* context, const POINTER_SYSTEM_UPDATE* pointer_system) { pClientContext* pc = (pClientContext*)context; - proxyData* pdata = NULL; - rdpContext* ps = NULL; + proxyData* pdata = nullptr; + rdpContext* ps = nullptr; WINPR_ASSERT(pc); pdata = pc->pdata; WINPR_ASSERT(pdata); @@ -197,8 +197,8 @@ static BOOL pf_client_send_pointer_position(rdpContext* context, const POINTER_POSITION_UPDATE* pointerPosition) { pClientContext* pc = (pClientContext*)context; - proxyData* pdata = NULL; - rdpContext* ps = NULL; + proxyData* pdata = nullptr; + rdpContext* ps = nullptr; WINPR_ASSERT(pc); pdata = pc->pdata; WINPR_ASSERT(pdata); @@ -216,8 +216,8 @@ static BOOL pf_client_send_pointer_color(rdpContext* context, const POINTER_COLOR_UPDATE* pointer_color) { pClientContext* pc = (pClientContext*)context; - proxyData* pdata = NULL; - rdpContext* ps = NULL; + proxyData* pdata = nullptr; + rdpContext* ps = nullptr; WINPR_ASSERT(pc); pdata = pc->pdata; WINPR_ASSERT(pdata); @@ -235,8 +235,8 @@ static BOOL pf_client_send_pointer_large(rdpContext* context, const POINTER_LARGE_UPDATE* pointer_large) { pClientContext* pc = (pClientContext*)context; - proxyData* pdata = NULL; - rdpContext* ps = NULL; + proxyData* pdata = nullptr; + rdpContext* ps = nullptr; WINPR_ASSERT(pc); pdata = pc->pdata; WINPR_ASSERT(pdata); @@ -253,8 +253,8 @@ WINPR_ATTR_NODISCARD static BOOL pf_client_send_pointer_new(rdpContext* context, const POINTER_NEW_UPDATE* pointer_new) { pClientContext* pc = (pClientContext*)context; - proxyData* pdata = NULL; - rdpContext* ps = NULL; + proxyData* pdata = nullptr; + rdpContext* ps = nullptr; WINPR_ASSERT(pc); pdata = pc->pdata; WINPR_ASSERT(pdata); @@ -272,8 +272,8 @@ static BOOL pf_client_send_pointer_cached(rdpContext* context, const POINTER_CACHED_UPDATE* pointer_cached) { pClientContext* pc = (pClientContext*)context; - proxyData* pdata = NULL; - rdpContext* ps = NULL; + proxyData* pdata = nullptr; + rdpContext* ps = nullptr; WINPR_ASSERT(pc); pdata = pc->pdata; WINPR_ASSERT(pdata); @@ -289,10 +289,10 @@ static BOOL pf_client_send_pointer_cached(rdpContext* context, WINPR_ATTR_NODISCARD static BOOL pf_client_save_session_info(rdpContext* context, UINT32 type, void* data) { - logon_info* logonInfo = NULL; + logon_info* logonInfo = nullptr; pClientContext* pc = (pClientContext*)context; - proxyData* pdata = NULL; - rdpContext* ps = NULL; + proxyData* pdata = nullptr; + rdpContext* ps = nullptr; WINPR_ASSERT(pc); pdata = pc->pdata; WINPR_ASSERT(pdata); @@ -325,8 +325,8 @@ WINPR_ATTR_NODISCARD static BOOL pf_client_server_status_info(rdpContext* context, UINT32 status) { pClientContext* pc = (pClientContext*)context; - proxyData* pdata = NULL; - rdpContext* ps = NULL; + proxyData* pdata = nullptr; + rdpContext* ps = nullptr; WINPR_ASSERT(pc); pdata = pc->pdata; WINPR_ASSERT(pdata); @@ -343,8 +343,8 @@ WINPR_ATTR_NODISCARD static BOOL pf_client_set_keyboard_indicators(rdpContext* context, UINT16 led_flags) { pClientContext* pc = (pClientContext*)context; - proxyData* pdata = NULL; - rdpContext* ps = NULL; + proxyData* pdata = nullptr; + rdpContext* ps = nullptr; WINPR_ASSERT(pc); pdata = pc->pdata; WINPR_ASSERT(pdata); @@ -362,8 +362,8 @@ static BOOL pf_client_set_keyboard_ime_status(rdpContext* context, UINT16 imeId, UINT32 imeConvMode) { pClientContext* pc = (pClientContext*)context; - proxyData* pdata = NULL; - rdpContext* ps = NULL; + proxyData* pdata = nullptr; + rdpContext* ps = nullptr; WINPR_ASSERT(pc); pdata = pc->pdata; WINPR_ASSERT(pdata); @@ -382,8 +382,8 @@ static BOOL pf_client_window_create(rdpContext* context, const WINDOW_ORDER_INFO { BOOL rc = 0; pClientContext* pc = (pClientContext*)context; - proxyData* pdata = NULL; - rdpContext* ps = NULL; + proxyData* pdata = nullptr; + rdpContext* ps = nullptr; WINPR_ASSERT(pc); pdata = pc->pdata; WINPR_ASSERT(pdata); @@ -406,8 +406,8 @@ static BOOL pf_client_window_update(rdpContext* context, const WINDOW_ORDER_INFO { BOOL rc = 0; pClientContext* pc = (pClientContext*)context; - proxyData* pdata = NULL; - rdpContext* ps = NULL; + proxyData* pdata = nullptr; + rdpContext* ps = nullptr; WINPR_ASSERT(pc); pdata = pc->pdata; WINPR_ASSERT(pdata); @@ -430,8 +430,8 @@ static BOOL pf_client_window_icon(rdpContext* context, const WINDOW_ORDER_INFO* { BOOL rc = 0; pClientContext* pc = (pClientContext*)context; - proxyData* pdata = NULL; - rdpContext* ps = NULL; + proxyData* pdata = nullptr; + rdpContext* ps = nullptr; WINPR_ASSERT(pc); pdata = pc->pdata; WINPR_ASSERT(pdata); @@ -454,8 +454,8 @@ static BOOL pf_client_window_cached_icon(rdpContext* context, const WINDOW_ORDER { BOOL rc = 0; pClientContext* pc = (pClientContext*)context; - proxyData* pdata = NULL; - rdpContext* ps = NULL; + proxyData* pdata = nullptr; + rdpContext* ps = nullptr; WINPR_ASSERT(pc); pdata = pc->pdata; WINPR_ASSERT(pdata); @@ -477,8 +477,8 @@ static BOOL pf_client_window_delete(rdpContext* context, const WINDOW_ORDER_INFO { BOOL rc = 0; pClientContext* pc = (pClientContext*)context; - proxyData* pdata = NULL; - rdpContext* ps = NULL; + proxyData* pdata = nullptr; + rdpContext* ps = nullptr; WINPR_ASSERT(pc); pdata = pc->pdata; WINPR_ASSERT(pdata); @@ -501,8 +501,8 @@ static BOOL pf_client_notify_icon_create(rdpContext* context, const WINDOW_ORDER { BOOL rc = 0; pClientContext* pc = (pClientContext*)context; - proxyData* pdata = NULL; - rdpContext* ps = NULL; + proxyData* pdata = nullptr; + rdpContext* ps = nullptr; WINPR_ASSERT(pc); pdata = pc->pdata; WINPR_ASSERT(pdata); @@ -525,8 +525,8 @@ static BOOL pf_client_notify_icon_update(rdpContext* context, const WINDOW_ORDER { BOOL rc = 0; pClientContext* pc = (pClientContext*)context; - proxyData* pdata = NULL; - rdpContext* ps = NULL; + proxyData* pdata = nullptr; + rdpContext* ps = nullptr; WINPR_ASSERT(pc); pdata = pc->pdata; WINPR_ASSERT(pdata); @@ -549,8 +549,8 @@ static BOOL pf_client_notify_icon_delete(rdpContext* context, const WINDOW_ORDER BOOL rc = 0; pClientContext* pc = (pClientContext*)context; - proxyData* pdata = NULL; - rdpContext* ps = NULL; + proxyData* pdata = nullptr; + rdpContext* ps = nullptr; WINPR_ASSERT(pc); pdata = pc->pdata; WINPR_ASSERT(pdata); @@ -573,8 +573,8 @@ static BOOL pf_client_monitored_desktop(rdpContext* context, const WINDOW_ORDER_ { BOOL rc = 0; pClientContext* pc = (pClientContext*)context; - proxyData* pdata = NULL; - rdpContext* ps = NULL; + proxyData* pdata = nullptr; + rdpContext* ps = nullptr; WINPR_ASSERT(pc); pdata = pc->pdata; WINPR_ASSERT(pdata); @@ -596,8 +596,8 @@ static BOOL pf_client_non_monitored_desktop(rdpContext* context, const WINDOW_OR { BOOL rc = 0; pClientContext* pc = (pClientContext*)context; - proxyData* pdata = NULL; - rdpContext* ps = NULL; + proxyData* pdata = nullptr; + rdpContext* ps = nullptr; WINPR_ASSERT(pc); pdata = pc->pdata; WINPR_ASSERT(pdata); diff --git a/server/proxy/pf_utils.h b/server/proxy/pf_utils.h index f1592c1e0..9b23698fd 100644 --- a/server/proxy/pf_utils.h +++ b/server/proxy/pf_utils.h @@ -28,8 +28,8 @@ * @brief pf_utils_channel_is_passthrough Checks of a channel identified by 'name' * should be handled as passthrough. * - * @param config The proxy configuration to check against. Must NOT be NULL. - * @param name The name of the channel. Must NOT be NULL. + * @param config The proxy configuration to check against. Must NOT be nullptr. + * @param name The name of the channel. Must NOT be nullptr. * @return -1 if the channel is not handled, 0 if the channel should be ignored, * 1 if the channel should be passed, 2 the channel will be intercepted * e.g. proxy client and server are termination points and data passed diff --git a/server/proxy/proxy_modules.h b/server/proxy/proxy_modules.h index db41cfd04..0979501af 100644 --- a/server/proxy/proxy_modules.h +++ b/server/proxy/proxy_modules.h @@ -82,7 +82,7 @@ extern "C" /** * @brief pf_modules_add Registers a new plugin - * @param ep A module entry point function, must NOT be NULL + * @param ep A module entry point function, must NOT be nullptr * @return TRUE for success, FALSE otherwise */ WINPR_ATTR_NODISCARD BOOL pf_modules_add(proxyModule* module, proxyModuleEntryPoint ep, diff --git a/server/shadow/Mac/mac_shadow.c b/server/shadow/Mac/mac_shadow.c index 54384d022..365fbf657 100644 --- a/server/shadow/Mac/mac_shadow.c +++ b/server/shadow/Mac/mac_shadow.c @@ -30,7 +30,7 @@ #define TAG SERVER_TAG("shadow.mac") -static macShadowSubsystem* g_Subsystem = NULL; +static macShadowSubsystem* g_Subsystem = nullptr; static BOOL mac_shadow_input_synchronize_event(rdpShadowSubsystem* subsystem, rdpShadowClient* client, UINT32 flags) @@ -394,7 +394,7 @@ static void (^mac_capture_stream_handler)( y = extents->top; width = extents->right - extents->left; height = extents->bottom - extents->top; - IOSurfaceLock(frameSurface, kIOSurfaceLockReadOnly, NULL); + IOSurfaceLock(frameSurface, kIOSurfaceLockReadOnly, nullptr); pSrcData = (BYTE*)IOSurfaceGetBaseAddress(frameSurface); nSrcStep = (int)IOSurfaceGetBytesPerRow(frameSurface); @@ -407,11 +407,11 @@ static void (^mac_capture_stream_handler)( { freerdp_image_copy_no_overlap(surface->data, surface->format, surface->scanline, x, y, width, height, pSrcData, PIXEL_FORMAT_BGRX32, nSrcStep, x, - y, NULL, FREERDP_FLIP_NONE); + y, nullptr, FREERDP_FLIP_NONE); } LeaveCriticalSection(&(surface->lock)); - IOSurfaceUnlock(frameSurface, kIOSurfaceLockReadOnly, NULL); + IOSurfaceUnlock(frameSurface, kIOSurfaceLockReadOnly, nullptr); ArrayList_Lock(server->clients); count = ArrayList_Count(server->clients); shadow_subsystem_frame_update(&subsystem->common); @@ -470,11 +470,11 @@ static int mac_shadow_capture_init(macShadowSubsystem* subsystem) CFDictionaryRef opts; CGDirectDisplayID displayId; displayId = CGMainDisplayID(); - subsystem->captureQueue = dispatch_queue_create("mac.shadow.capture", NULL); + subsystem->captureQueue = dispatch_queue_create("mac.shadow.capture", nullptr); keys[0] = (void*)kCGDisplayStreamShowCursor; values[0] = (void*)kCFBooleanFalse; opts = CFDictionaryCreate(kCFAllocatorDefault, (const void**)keys, (const void**)values, 1, - NULL, NULL); + nullptr, nullptr); subsystem->stream = CGDisplayStreamCreateWithDispatchQueue( displayId, subsystem->pixelWidth, subsystem->pixelHeight, 'BGRA', opts, subsystem->captureQueue, mac_capture_stream_handler); @@ -601,7 +601,7 @@ static int mac_shadow_subsystem_uninit(rdpShadowSubsystem* rdpsubsystem) if (subsystem->lastUpdate) { CFRelease(subsystem->lastUpdate); - subsystem->lastUpdate = NULL; + subsystem->lastUpdate = nullptr; } return 1; @@ -617,7 +617,8 @@ static int mac_shadow_subsystem_start(rdpShadowSubsystem* rdpsubsystem) mac_shadow_capture_start(subsystem); - if (!(thread = CreateThread(NULL, 0, mac_shadow_subsystem_thread, (void*)subsystem, 0, NULL))) + if (!(thread = + CreateThread(nullptr, 0, mac_shadow_subsystem_thread, (void*)subsystem, 0, nullptr))) { WLog_ERR(TAG, "Failed to create thread"); return -1; @@ -648,7 +649,7 @@ static rdpShadowSubsystem* mac_shadow_subsystem_new(void) macShadowSubsystem* subsystem = calloc(1, sizeof(macShadowSubsystem)); if (!subsystem) - return NULL; + return nullptr; subsystem->common.SynchronizeEvent = mac_shadow_input_synchronize_event; subsystem->common.KeyboardEvent = mac_shadow_input_keyboard_event; diff --git a/server/shadow/Sample/sample_shadow.c b/server/shadow/Sample/sample_shadow.c index a9b9416ad..4efa6f12a 100644 --- a/server/shadow/Sample/sample_shadow.c +++ b/server/shadow/Sample/sample_shadow.c @@ -161,7 +161,7 @@ static rdpShadowSubsystem* sample_shadow_subsystem_new(void) (sampleShadowSubsystem*)calloc(1, sizeof(sampleShadowSubsystem)); if (!subsystem) - return NULL; + return nullptr; subsystem->base.SynchronizeEvent = sample_shadow_input_synchronize_event; subsystem->base.KeyboardEvent = sample_shadow_input_keyboard_event; diff --git a/server/shadow/Win/win_dxgi.c b/server/shadow/Win/win_dxgi.c index c96790071..2f9d66dfa 100644 --- a/server/shadow/Win/win_dxgi.c +++ b/server/shadow/Win/win_dxgi.c @@ -42,7 +42,7 @@ static D3D_FEATURE_LEVEL FeatureLevels[] = { D3D_FEATURE_LEVEL_11_0, D3D_FEATURE static UINT NumFeatureLevels = ARRAYSIZE(FeatureLevels); -static HMODULE d3d11_module = NULL; +static HMODULE d3d11_module = nullptr; typedef HRESULT(WINAPI* fnD3D11CreateDevice)(IDXGIAdapter* pAdapter, D3D_DRIVER_TYPE DriverType, HMODULE Software, UINT Flags, @@ -52,7 +52,7 @@ typedef HRESULT(WINAPI* fnD3D11CreateDevice)(IDXGIAdapter* pAdapter, D3D_DRIVER_ D3D_FEATURE_LEVEL* pFeatureLevel, ID3D11DeviceContext** ppImmediateContext); -static fnD3D11CreateDevice pfnD3D11CreateDevice = NULL; +static fnD3D11CreateDevice pfnD3D11CreateDevice = nullptr; #undef DEFINE_GUID #define INITGUID @@ -300,10 +300,10 @@ int win_shadow_dxgi_init_duplication(winShadowSubsystem* subsystem) DXGI_OUTPUT_DESC outputDesc = WINPR_C_ARRAY_INIT; DXGI_OUTPUT_DESC* pOutputDesc; D3D11_TEXTURE2D_DESC textureDesc; - IDXGIDevice* dxgiDevice = NULL; - IDXGIAdapter* dxgiAdapter = NULL; - IDXGIOutput* dxgiOutput = NULL; - IDXGIOutput1* dxgiOutput1 = NULL; + IDXGIDevice* dxgiDevice = nullptr; + IDXGIAdapter* dxgiAdapter = nullptr; + IDXGIOutput* dxgiOutput = nullptr; + IDXGIOutput1* dxgiOutput1 = nullptr; hr = subsystem->dxgiDevice->lpVtbl->QueryInterface(subsystem->dxgiDevice, &IID_IDXGIDevice, (void**)&dxgiDevice); @@ -320,7 +320,7 @@ int win_shadow_dxgi_init_duplication(winShadowSubsystem* subsystem) if (dxgiDevice) { dxgiDevice->lpVtbl->Release(dxgiDevice); - dxgiDevice = NULL; + dxgiDevice = nullptr; } if (FAILED(hr)) @@ -330,7 +330,7 @@ int win_shadow_dxgi_init_duplication(winShadowSubsystem* subsystem) return -1; } - pOutput = NULL; + pOutput = nullptr; while (dxgiAdapter->lpVtbl->EnumOutputs(dxgiAdapter, i, &pOutput) != DXGI_ERROR_NOT_FOUND) { @@ -358,7 +358,7 @@ int win_shadow_dxgi_init_duplication(winShadowSubsystem* subsystem) if (dxgiAdapter) { dxgiAdapter->lpVtbl->Release(dxgiAdapter); - dxgiAdapter = NULL; + dxgiAdapter = nullptr; } if (FAILED(hr)) @@ -373,7 +373,7 @@ int win_shadow_dxgi_init_duplication(winShadowSubsystem* subsystem) if (dxgiOutput) { dxgiOutput->lpVtbl->Release(dxgiOutput); - dxgiOutput = NULL; + dxgiOutput = nullptr; } if (FAILED(hr)) @@ -389,7 +389,7 @@ int win_shadow_dxgi_init_duplication(winShadowSubsystem* subsystem) if (dxgiOutput1) { dxgiOutput1->lpVtbl->Release(dxgiOutput1); - dxgiOutput1 = NULL; + dxgiOutput1 = nullptr; } if (FAILED(hr)) @@ -411,8 +411,8 @@ int win_shadow_dxgi_init_duplication(winShadowSubsystem* subsystem) textureDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ; textureDesc.MiscFlags = 0; - hr = subsystem->dxgiDevice->lpVtbl->CreateTexture2D(subsystem->dxgiDevice, &textureDesc, NULL, - &(subsystem->dxgiStage)); + hr = subsystem->dxgiDevice->lpVtbl->CreateTexture2D(subsystem->dxgiDevice, &textureDesc, + nullptr, &(subsystem->dxgiStage)); if (FAILED(hr)) { @@ -430,10 +430,10 @@ int win_shadow_dxgi_init(winShadowSubsystem* subsystem) HRESULT hr; int status; UINT DriverTypeIndex; - IDXGIDevice* DxgiDevice = NULL; - IDXGIAdapter* DxgiAdapter = NULL; - IDXGIOutput* DxgiOutput = NULL; - IDXGIOutput1* DxgiOutput1 = NULL; + IDXGIDevice* DxgiDevice = nullptr; + IDXGIAdapter* DxgiAdapter = nullptr; + IDXGIOutput* DxgiOutput = nullptr; + IDXGIOutput1* DxgiOutput1 = nullptr; win_shadow_d3d11_module_init(); @@ -442,7 +442,7 @@ int win_shadow_dxgi_init(winShadowSubsystem* subsystem) for (DriverTypeIndex = 0; DriverTypeIndex < NumDriverTypes; ++DriverTypeIndex) { - hr = pfnD3D11CreateDevice(NULL, DriverTypes[DriverTypeIndex], NULL, 0, FeatureLevels, + hr = pfnD3D11CreateDevice(nullptr, DriverTypes[DriverTypeIndex], nullptr, 0, FeatureLevels, NumFeatureLevels, D3D11_SDK_VERSION, &(subsystem->dxgiDevice), &(subsystem->featureLevel), &(subsystem->dxgiDeviceContext)); @@ -466,31 +466,31 @@ int win_shadow_dxgi_uninit(winShadowSubsystem* subsystem) if (subsystem->dxgiStage) { subsystem->dxgiStage->lpVtbl->Release(subsystem->dxgiStage); - subsystem->dxgiStage = NULL; + subsystem->dxgiStage = nullptr; } if (subsystem->dxgiDesktopImage) { subsystem->dxgiDesktopImage->lpVtbl->Release(subsystem->dxgiDesktopImage); - subsystem->dxgiDesktopImage = NULL; + subsystem->dxgiDesktopImage = nullptr; } if (subsystem->dxgiOutputDuplication) { subsystem->dxgiOutputDuplication->lpVtbl->Release(subsystem->dxgiOutputDuplication); - subsystem->dxgiOutputDuplication = NULL; + subsystem->dxgiOutputDuplication = nullptr; } if (subsystem->dxgiDeviceContext) { subsystem->dxgiDeviceContext->lpVtbl->Release(subsystem->dxgiDeviceContext); - subsystem->dxgiDeviceContext = NULL; + subsystem->dxgiDeviceContext = nullptr; } if (subsystem->dxgiDevice) { subsystem->dxgiDevice->lpVtbl->Release(subsystem->dxgiDevice); - subsystem->dxgiDevice = NULL; + subsystem->dxgiDevice = nullptr; } return 1; @@ -568,7 +568,7 @@ int win_shadow_dxgi_release_frame_data(winShadowSubsystem* subsystem) } subsystem->dxgiSurface->lpVtbl->Release(subsystem->dxgiSurface); - subsystem->dxgiSurface = NULL; + subsystem->dxgiSurface = nullptr; } if (subsystem->dxgiOutputDuplication) @@ -593,7 +593,7 @@ int win_shadow_dxgi_get_next_frame(winShadowSubsystem* subsystem) HRESULT hr = 0; UINT timeout = 15; UINT DataBufferSize = 0; - BYTE* DataBuffer = NULL; + BYTE* DataBuffer = nullptr; if (subsystem->dxgiFrameAcquired) { @@ -603,7 +603,7 @@ int win_shadow_dxgi_get_next_frame(winShadowSubsystem* subsystem) if (subsystem->dxgiDesktopImage) { subsystem->dxgiDesktopImage->lpVtbl->Release(subsystem->dxgiDesktopImage); - subsystem->dxgiDesktopImage = NULL; + subsystem->dxgiDesktopImage = nullptr; } hr = subsystem->dxgiOutputDuplication->lpVtbl->AcquireNextFrame( @@ -631,13 +631,13 @@ int win_shadow_dxgi_get_next_frame(winShadowSubsystem* subsystem) if (subsystem->dxgiDesktopImage) { subsystem->dxgiDesktopImage->lpVtbl->Release(subsystem->dxgiDesktopImage); - subsystem->dxgiDesktopImage = NULL; + subsystem->dxgiDesktopImage = nullptr; } if (subsystem->dxgiOutputDuplication) { subsystem->dxgiOutputDuplication->lpVtbl->Release(subsystem->dxgiOutputDuplication); - subsystem->dxgiOutputDuplication = NULL; + subsystem->dxgiOutputDuplication = nullptr; } status = win_shadow_dxgi_init_duplication(subsystem); @@ -668,7 +668,7 @@ int win_shadow_dxgi_get_next_frame(winShadowSubsystem* subsystem) if (subsystem->dxgiResource) { subsystem->dxgiResource->lpVtbl->Release(subsystem->dxgiResource); - subsystem->dxgiResource = NULL; + subsystem->dxgiResource = nullptr; } if (FAILED(hr)) diff --git a/server/shadow/Win/win_rdp.c b/server/shadow/Win/win_rdp.c index a83dd0942..0d92b2a18 100644 --- a/server/shadow/Win/win_rdp.c +++ b/server/shadow/Win/win_rdp.c @@ -249,7 +249,7 @@ static int shw_freerdp_client_start(rdpContext* context) freerdp* instance = context->instance; shw = (shwContext*)context; - if (!(shw->common.thread = CreateThread(NULL, 0, shw_client_thread, instance, 0, NULL))) + if (!(shw->common.thread = CreateThread(nullptr, 0, shw_client_thread, instance, 0, nullptr))) { WLog_ERR(TAG, "Failed to create thread"); return -1; @@ -276,7 +276,7 @@ static BOOL shw_freerdp_client_new(freerdp* instance, rdpContext* context) shw = (shwContext*)instance->context; WINPR_ASSERT(shw); - if (!(shw->StopEvent = CreateEvent(NULL, TRUE, FALSE, NULL))) + if (!(shw->StopEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr))) return FALSE; instance->LoadChannels = freerdp_client_load_channels; @@ -374,7 +374,7 @@ int shw_RdpClientEntry(RDP_CLIENT_ENTRY_POINTS* pEntryPoints) { pEntryPoints->Version = 1; pEntryPoints->Size = sizeof(RDP_CLIENT_ENTRY_POINTS_V1); - pEntryPoints->settings = NULL; + pEntryPoints->settings = nullptr; pEntryPoints->ContextSize = sizeof(shwContext); pEntryPoints->GlobalInit = shw_freerdp_client_global_init; pEntryPoints->GlobalUninit = shw_freerdp_client_global_uninit; @@ -394,10 +394,10 @@ int win_shadow_rdp_init(winShadowSubsystem* subsystem) clientEntryPoints.Version = RDP_CLIENT_INTERFACE_VERSION; shw_RdpClientEntry(&clientEntryPoints); - if (!(subsystem->RdpUpdateEnterEvent = CreateEvent(NULL, TRUE, FALSE, NULL))) + if (!(subsystem->RdpUpdateEnterEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr))) goto fail_enter_event; - if (!(subsystem->RdpUpdateLeaveEvent = CreateEvent(NULL, TRUE, FALSE, NULL))) + if (!(subsystem->RdpUpdateLeaveEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr))) goto fail_leave_event; if (!(context = freerdp_client_context_new(&clientEntryPoints))) diff --git a/server/shadow/Win/win_shadow.c b/server/shadow/Win/win_shadow.c index 533bd19ec..8dd64d194 100644 --- a/server/shadow/Win/win_shadow.c +++ b/server/shadow/Win/win_shadow.c @@ -247,7 +247,7 @@ static int win_shadow_surface_copy(winShadowSubsystem* subsystem) int status = 1; int nDstStep = 0; DWORD DstFormat; - BYTE* pDstData = NULL; + BYTE* pDstData = nullptr; rdpShadowServer* server; rdpShadowSurface* surface; RECTANGLE_16 surfaceRect; @@ -315,7 +315,7 @@ static int win_shadow_surface_copy(winShadowSubsystem* subsystem) return status; if (!freerdp_image_copy_no_overlap(surface->data, surface->format, surface->scanline, x, y, - width, height, pDstData, DstFormat, nDstStep, x, y, NULL, + width, height, pDstData, DstFormat, nDstStep, x, y, nullptr, FREERDP_FLIP_NONE)) return ERROR_INTERNAL_ERROR; @@ -430,9 +430,9 @@ static UINT32 win_shadow_enum_monitors(MONITOR_DEF* monitors, UINT32 maxMonitors displayDevice.cb = sizeof(DISPLAY_DEVICE); - if (EnumDisplayDevices(NULL, iDevNum, &displayDevice, 0)) + if (EnumDisplayDevices(nullptr, iDevNum, &displayDevice, 0)) { - hdc = CreateDC(displayDevice.DeviceName, NULL, NULL, NULL); + hdc = CreateDC(displayDevice.DeviceName, nullptr, nullptr, nullptr); desktopWidth = GetDeviceCaps(hdc, HORZRES); desktopHeight = GetDeviceCaps(hdc, VERTRES); index = 0; @@ -493,7 +493,8 @@ static int win_shadow_subsystem_start(rdpShadowSubsystem* arg) if (!subsystem) return -1; - if (!(thread = CreateThread(NULL, 0, win_shadow_subsystem_thread, (void*)subsystem, 0, NULL))) + if (!(thread = + CreateThread(nullptr, 0, win_shadow_subsystem_thread, (void*)subsystem, 0, nullptr))) { WLog_ERR(TAG, "Failed to create thread"); return -1; @@ -529,7 +530,7 @@ static rdpShadowSubsystem* win_shadow_subsystem_new(void) subsystem = (winShadowSubsystem*)calloc(1, sizeof(winShadowSubsystem)); if (!subsystem) - return NULL; + return nullptr; subsystem->base.SynchronizeEvent = win_shadow_input_synchronize_event; subsystem->base.KeyboardEvent = win_shadow_input_keyboard_event; diff --git a/server/shadow/Win/win_wds.c b/server/shadow/Win/win_wds.c index de9edaea9..11d0a7df0 100644 --- a/server/shadow/Win/win_wds.c +++ b/server/shadow/Win/win_wds.c @@ -186,7 +186,7 @@ Shadow_IRDPSessionEvents_QueryInterface(__RPC__in _IRDPSessionEvents* This, /* [annotation][iid_is][out] */ _COM_Outptr_ void** ppvObject) { - *ppvObject = NULL; + *ppvObject = nullptr; if (IsEqualIID(riid, &DIID__IRDPSessionEvents) || IsEqualIID(riid, &IID_IDispatch) || IsEqualIID(riid, &IID_IUnknown)) @@ -278,7 +278,7 @@ static HRESULT STDMETHODCALLTYPE Shadow_IRDPSessionEvents_Invoke(_IRDPSessionEve IDispatch* pDispatch; IRDPSRAPIAttendee* pAttendee; vr.vt = VT_DISPATCH; - vr.pdispVal = NULL; + vr.pdispVal = nullptr; hr = DispGetParam(pDispParams, 0, VT_DISPATCH, &vr, &uArgErr); if (FAILED(hr)) @@ -341,7 +341,7 @@ static HRESULT STDMETHODCALLTYPE Shadow_IRDPSessionEvents_Invoke(_IRDPSessionEve IDispatch* pDispatch; IRDPSRAPIAttendee* pAttendee; vr.vt = VT_INT; - vr.pdispVal = NULL; + vr.pdispVal = nullptr; hr = DispGetParam(pDispParams, 1, VT_INT, &vr, &uArgErr); if (FAILED(hr)) @@ -353,7 +353,7 @@ static HRESULT STDMETHODCALLTYPE Shadow_IRDPSessionEvents_Invoke(_IRDPSessionEve level = vr.intVal; vr.vt = VT_DISPATCH; - vr.pdispVal = NULL; + vr.pdispVal = nullptr; hr = DispGetParam(pDispParams, 0, VT_DISPATCH, &vr, &uArgErr); if (FAILED(hr)) @@ -479,7 +479,7 @@ int win_shadow_wds_wnd_init(winShadowSubsystem* subsystem) HMODULE hModule; HINSTANCE hInstance; WNDCLASSEX wndClassEx = WINPR_C_ARRAY_INIT; - hModule = GetModuleHandle(NULL); + hModule = GetModuleHandle(nullptr); wndClassEx.cbSize = sizeof(WNDCLASSEX); wndClassEx.style = 0; @@ -487,12 +487,12 @@ int win_shadow_wds_wnd_init(winShadowSubsystem* subsystem) wndClassEx.cbClsExtra = 0; wndClassEx.cbWndExtra = 0; wndClassEx.hInstance = hModule; - wndClassEx.hIcon = NULL; - wndClassEx.hCursor = NULL; - wndClassEx.hbrBackground = NULL; + wndClassEx.hIcon = nullptr; + wndClassEx.hCursor = nullptr; + wndClassEx.hbrBackground = nullptr; wndClassEx.lpszMenuName = _T("ShadowWndMenu"); wndClassEx.lpszClassName = _T("ShadowWndClass"); - wndClassEx.hIconSm = NULL; + wndClassEx.hIconSm = nullptr; if (!RegisterClassEx(&wndClassEx)) { @@ -502,7 +502,7 @@ int win_shadow_wds_wnd_init(winShadowSubsystem* subsystem) hInstance = wndClassEx.hInstance; subsystem->hWnd = CreateWindowEx(0, wndClassEx.lpszClassName, 0, 0, 0, 0, 0, 0, HWND_MESSAGE, 0, - hInstance, NULL); + hInstance, nullptr); if (!subsystem->hWnd) { @@ -521,17 +521,17 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) long top = 0; long right = 0; long bottom = 0; - BSTR bstrAuthString = NULL; - BSTR bstrGroupName = NULL; - BSTR bstrPassword = NULL; - BSTR bstrPropertyName = NULL; + BSTR bstrAuthString = nullptr; + BSTR bstrGroupName = nullptr; + BSTR bstrPassword = nullptr; + BSTR bstrPropertyName = nullptr; VARIANT varPropertyValue; - rdpAssistanceFile* file = NULL; - IConnectionPoint* pCP = NULL; - IConnectionPointContainer* pCPC = NULL; + rdpAssistanceFile* file = nullptr; + IConnectionPoint* pCP = nullptr; + IConnectionPointContainer* pCPC = nullptr; win_shadow_wds_wnd_init(subsystem); - HRESULT hr = OleInitialize(NULL); + HRESULT hr = OleInitialize(nullptr); if (FAILED(hr)) { @@ -539,7 +539,7 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) return -1; } - hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); + hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); if (FAILED(hr)) { @@ -547,7 +547,7 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) return -1; } - hr = CoCreateInstance(&CLSID_RDPSession, NULL, CLSCTX_ALL, &IID_IRDPSRAPISharingSession, + hr = CoCreateInstance(&CLSID_RDPSession, nullptr, CLSCTX_ALL, &IID_IRDPSRAPISharingSession, (void**)&(subsystem->pSharingSession)); if (FAILED(hr)) @@ -743,7 +743,7 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) return -1; } - ConnectionString2 = ConvertWCharToUtf8Alloc(bstrConnectionString, NULL); + ConnectionString2 = ConvertWCharToUtf8Alloc(bstrConnectionString, nullptr); SysFreeString(bstrConnectionString); status2 = freerdp_assistance_set_connection_string2(file, ConnectionString2, "Shadow123!"); free(ConnectionString2); @@ -794,61 +794,61 @@ int win_shadow_wds_uninit(winShadowSubsystem* subsystem) { subsystem->pSharingSession->lpVtbl->Close(subsystem->pSharingSession); subsystem->pSharingSession->lpVtbl->Release(subsystem->pSharingSession); - subsystem->pSharingSession = NULL; + subsystem->pSharingSession = nullptr; } if (subsystem->pVirtualChannelMgr) { subsystem->pVirtualChannelMgr->lpVtbl->Release(subsystem->pVirtualChannelMgr); - subsystem->pVirtualChannelMgr = NULL; + subsystem->pVirtualChannelMgr = nullptr; } if (subsystem->pApplicationFilter) { subsystem->pApplicationFilter->lpVtbl->Release(subsystem->pApplicationFilter); - subsystem->pApplicationFilter = NULL; + subsystem->pApplicationFilter = nullptr; } if (subsystem->pAttendeeMgr) { subsystem->pAttendeeMgr->lpVtbl->Release(subsystem->pAttendeeMgr); - subsystem->pAttendeeMgr = NULL; + subsystem->pAttendeeMgr = nullptr; } if (subsystem->pSessionProperties) { subsystem->pSessionProperties->lpVtbl->Release(subsystem->pSessionProperties); - subsystem->pSessionProperties = NULL; + subsystem->pSessionProperties = nullptr; } if (subsystem->pInvitationMgr) { subsystem->pInvitationMgr->lpVtbl->Release(subsystem->pInvitationMgr); - subsystem->pInvitationMgr = NULL; + subsystem->pInvitationMgr = nullptr; } if (subsystem->pInvitation) { subsystem->pInvitation->lpVtbl->Release(subsystem->pInvitation); - subsystem->pInvitation = NULL; + subsystem->pInvitation = nullptr; } if (subsystem->pAssistanceFile) { freerdp_assistance_file_free(subsystem->pAssistanceFile); - subsystem->pAssistanceFile = NULL; + subsystem->pAssistanceFile = nullptr; } if (subsystem->hWnd) { DestroyWindow(subsystem->hWnd); - subsystem->hWnd = NULL; + subsystem->hWnd = nullptr; } if (subsystem->shw) { win_shadow_rdp_uninit(subsystem); - subsystem->shw = NULL; + subsystem->shw = nullptr; } return 1; diff --git a/server/shadow/X11/x11_shadow.c b/server/shadow/X11/x11_shadow.c index f30bf7aa2..7f3d5bd63 100644 --- a/server/shadow/X11/x11_shadow.c +++ b/server/shadow/X11/x11_shadow.c @@ -76,8 +76,8 @@ static int x11_shadow_pam_conv(int num_msg, const struct pam_message** msg, struct pam_response** resp, void* appdata_ptr) { int pam_status = PAM_CONV_ERR; - SHADOW_PAM_AUTH_DATA* appdata = NULL; - struct pam_response* response = NULL; + SHADOW_PAM_AUTH_DATA* appdata = nullptr; + struct pam_response* response = nullptr; WINPR_ASSERT(num_msg >= 0); appdata = (SHADOW_PAM_AUTH_DATA*)appdata_ptr; WINPR_ASSERT(appdata); @@ -128,7 +128,7 @@ out_fail: memset(response, 0, sizeof(struct pam_response) * (size_t)num_msg); free(response); - *resp = NULL; + *resp = nullptr; return pam_status; } @@ -148,7 +148,7 @@ static BOOL x11_shadow_pam_get_service_name(SHADOW_PAM_AUTH_INFO* info) { info->service_name = _strdup(hint); - return info->service_name != NULL; + return info->service_name != nullptr; } } WLog_WARN(TAG, "Could not determine PAM service name"); @@ -172,7 +172,7 @@ static int x11_shadow_pam_authenticate(rdpShadowSubsystem* subsystem, rdpShadowC info.appdata.password = password; info.pamc.conv = &x11_shadow_pam_conv; info.pamc.appdata_ptr = &info.appdata; - pam_status = pam_start(info.service_name, 0, &info.pamc, &info.handle); + pam_status = pam_start(info.service_name, nullptr, &info.pamc, &info.handle); if (pam_status != PAM_SUCCESS) { @@ -278,8 +278,8 @@ static BOOL x11_shadow_input_mouse_event(rdpShadowSubsystem* subsystem, rdpShado x11ShadowSubsystem* x11 = (x11ShadowSubsystem*)subsystem; unsigned int button = 0; BOOL down = FALSE; - rdpShadowServer* server = NULL; - rdpShadowSurface* surface = NULL; + rdpShadowServer* server = nullptr; + rdpShadowSurface* surface = nullptr; if (!subsystem || !client) return FALSE; @@ -417,8 +417,8 @@ static BOOL x11_shadow_input_extended_mouse_event(rdpShadowSubsystem* subsystem, x11ShadowSubsystem* x11 = (x11ShadowSubsystem*)subsystem; UINT button = 0; BOOL down = FALSE; - rdpShadowServer* server = NULL; - rdpShadowSurface* surface = NULL; + rdpShadowServer* server = nullptr; + rdpShadowSurface* surface = nullptr; if (!subsystem || !client) return FALSE; @@ -485,7 +485,7 @@ WINPR_ATTR_NODISCARD static int x11_shadow_pointer_position_update(x11ShadowSubsystem* subsystem) { UINT32 msgId = SHADOW_MSG_OUT_POINTER_POSITION_UPDATE_ID; - rdpShadowServer* server = NULL; + rdpShadowServer* server = nullptr; SHADOW_MSG_OUT_POINTER_POSITION_UPDATE templateMsg = WINPR_C_ARRAY_INIT; int count = 0; @@ -500,7 +500,7 @@ static int x11_shadow_pointer_position_update(x11ShadowSubsystem* subsystem) for (size_t index = 0; index < ArrayList_Count(server->clients); index++) { - SHADOW_MSG_OUT_POINTER_POSITION_UPDATE* msg = NULL; + SHADOW_MSG_OUT_POINTER_POSITION_UPDATE* msg = nullptr; rdpShadowClient* client = (rdpShadowClient*)ArrayList_GetItem(server->clients, index); /* Skip the client which send us the latest mouse event */ @@ -517,7 +517,7 @@ static int x11_shadow_pointer_position_update(x11ShadowSubsystem* subsystem) memcpy(msg, &templateMsg, sizeof(templateMsg)); - if (shadow_client_post_msg(client, NULL, msgId, (SHADOW_MSG_OUT*)msg, NULL)) + if (shadow_client_post_msg(client, nullptr, msgId, (SHADOW_MSG_OUT*)msg, nullptr)) count++; } @@ -548,8 +548,8 @@ static int x11_shadow_pointer_alpha_update(x11ShadowSubsystem* subsystem) } msg->common.Free = x11_shadow_message_free; - const int count = shadow_client_boardcast_msg(subsystem->common.server, NULL, msgId, - (SHADOW_MSG_OUT*)msg, NULL); + const int count = shadow_client_boardcast_msg(subsystem->common.server, nullptr, msgId, + (SHADOW_MSG_OUT*)msg, nullptr); if (count < 0) return -1; return 1; @@ -561,16 +561,16 @@ static int x11_shadow_query_cursor(x11ShadowSubsystem* subsystem, BOOL getImage) int x = 0; int y = 0; int n = 0; - rdpShadowServer* server = NULL; - rdpShadowSurface* surface = NULL; + rdpShadowServer* server = nullptr; + rdpShadowSurface* surface = nullptr; server = subsystem->common.server; surface = server->surface; if (getImage) { #ifdef WITH_XFIXES - UINT32* pDstPixel = NULL; - XFixesCursorImage* ci = NULL; + UINT32* pDstPixel = nullptr; + XFixesCursorImage* ci = nullptr; XLockDisplay(subsystem->display); ci = XFixesGetCursorImage(subsystem->display); XUnlockDisplay(subsystem->display); @@ -904,7 +904,7 @@ static BOOL x11_shadow_surface_update_contents(rdpShadowSurface* surface, UINT32 WINPR_ASSERTING_INT_CAST(uint32_t, y), WINPR_ASSERTING_INT_CAST(uint32_t, width), WINPR_ASSERTING_INT_CAST(uint32_t, height), (BYTE*)image->data, format, WINPR_ASSERTING_INT_CAST(uint32_t, image->bytes_per_line), - WINPR_ASSERTING_INT_CAST(UINT32, x), WINPR_ASSERTING_INT_CAST(UINT32, y), NULL, + WINPR_ASSERTING_INT_CAST(UINT32, x), WINPR_ASSERTING_INT_CAST(UINT32, y), nullptr, FREERDP_FLIP_NONE); LeaveCriticalSection(&surface->lock); return success; @@ -936,7 +936,7 @@ static int x11_shadow_screen_grab(x11ShadowSubsystem* subsystem) LeaveCriticalSection(&surface->lock); } - XImage* image = NULL; + XImage* image = nullptr; RECTANGLE_16 invalidRect = WINPR_C_ARRAY_INIT; int status = -1; { @@ -952,7 +952,7 @@ static int x11_shadow_screen_grab(x11ShadowSubsystem* subsystem) goto fail_capture; /* Restore the default error handler */ - XSetErrorHandler(NULL); + XSetErrorHandler(nullptr); XSync(subsystem->display, False); XUnlockDisplay(subsystem->display); } @@ -977,7 +977,7 @@ static int x11_shadow_screen_grab(x11ShadowSubsystem* subsystem) if (count == 1) { - rdpShadowClient* client = NULL; + rdpShadowClient* client = nullptr; client = (rdpShadowClient*)ArrayList_GetItem(server->clients, 0); if (client) @@ -1032,7 +1032,7 @@ static DWORD WINAPI x11_shadow_subsystem_thread(LPVOID arg) UINT64 frameTime = 0; HANDLE events[32]; wMessage message; - wMessagePipe* MsgPipe = NULL; + wMessagePipe* MsgPipe = nullptr; MsgPipe = subsystem->common.MsgPipe; nCount = 0; events[nCount++] = subsystem->common.event; @@ -1113,11 +1113,11 @@ static int x11_shadow_subsystem_base_init(x11ShadowSubsystem* subsystem) if (!XInitThreads()) return -1; - subsystem->display = XOpenDisplay(NULL); + subsystem->display = XOpenDisplay(nullptr); if (!subsystem->display) { - WLog_ERR(TAG, "failed to open display: %s", XDisplayName(NULL)); + WLog_ERR(TAG, "failed to open display: %s", XDisplayName(nullptr)); return -1; } @@ -1214,7 +1214,7 @@ static int x11_shadow_xdamage_init(x11ShadowSubsystem* subsystem) return -1; #ifdef WITH_XFIXES - subsystem->xdamage_region = XFixesCreateRegion(subsystem->display, NULL, 0); + subsystem->xdamage_region = XFixesCreateRegion(subsystem->display, nullptr, 0); if (!subsystem->xdamage_region) return -1; @@ -1247,7 +1247,7 @@ static int x11_shadow_xshm_init(x11ShadowSubsystem* subsystem) subsystem->fb_shm_info.shmaddr = (char*)-1; subsystem->fb_shm_info.readOnly = False; subsystem->fb_image = - XShmCreateImage(subsystem->display, subsystem->visual, subsystem->depth, ZPixmap, NULL, + XShmCreateImage(subsystem->display, subsystem->visual, subsystem->depth, ZPixmap, nullptr, &(subsystem->fb_shm_info), subsystem->width, subsystem->height); if (!subsystem->fb_image) @@ -1268,7 +1268,7 @@ static int x11_shadow_xshm_init(x11ShadowSubsystem* subsystem) return -1; } - subsystem->fb_shm_info.shmaddr = shmat(subsystem->fb_shm_info.shmid, 0, 0); + subsystem->fb_shm_info.shmaddr = shmat(subsystem->fb_shm_info.shmid, nullptr, 0); subsystem->fb_image->data = subsystem->fb_shm_info.shmaddr; if (subsystem->fb_shm_info.shmaddr == ((char*)-1)) @@ -1281,7 +1281,7 @@ static int x11_shadow_xshm_init(x11ShadowSubsystem* subsystem) return -1; XSync(subsystem->display, False); - shmctl(subsystem->fb_shm_info.shmid, IPC_RMID, 0); + shmctl(subsystem->fb_shm_info.shmid, IPC_RMID, nullptr); subsystem->fb_pixmap = XShmCreatePixmap( subsystem->display, subsystem->root_window, subsystem->fb_image->data, &(subsystem->fb_shm_info), WINPR_ASSERTING_INT_CAST(uint32_t, subsystem->fb_image->width), @@ -1305,7 +1305,7 @@ static int x11_shadow_xshm_init(x11ShadowSubsystem* subsystem) UINT32 x11_shadow_enum_monitors(MONITOR_DEF* monitors, UINT32 maxMonitors) { - Display* display = NULL; + Display* display = nullptr; int displayWidth = 0; int displayHeight = 0; int numMonitors = 0; @@ -1317,11 +1317,11 @@ UINT32 x11_shadow_enum_monitors(MONITOR_DEF* monitors, UINT32 maxMonitors) setenv("DISPLAY", ":0", 1); } - display = XOpenDisplay(NULL); + display = XOpenDisplay(nullptr); if (!display) { - WLog_ERR(TAG, "failed to open display: %s", XDisplayName(NULL)); + WLog_ERR(TAG, "failed to open display: %s", XDisplayName(nullptr)); return 0; } @@ -1335,7 +1335,7 @@ UINT32 x11_shadow_enum_monitors(MONITOR_DEF* monitors, UINT32 maxMonitors) #endif int xinerama_event = 0; int xinerama_error = 0; - XineramaScreenInfo* screens = NULL; + XineramaScreenInfo* screens = nullptr; const Bool xinerama = XineramaQueryExtension(display, &xinerama_event, &xinerama_error); const Bool damage = @@ -1396,7 +1396,7 @@ static int x11_shadow_subsystem_init(rdpShadowSubsystem* sub) int vi_count = 0; int nextensions = 0; XVisualInfo xtemplate = WINPR_C_ARRAY_INIT; - XPixmapFormatValues* pf = NULL; + XPixmapFormatValues* pf = nullptr; x11ShadowSubsystem* subsystem = (x11ShadowSubsystem*)sub; @@ -1524,7 +1524,7 @@ static int x11_shadow_subsystem_init(rdpShadowSubsystem* sub) } if (!(subsystem->common.event = - CreateFileDescriptorEvent(NULL, FALSE, FALSE, subsystem->xfds, WINPR_FD_READ))) + CreateFileDescriptorEvent(nullptr, FALSE, FALSE, subsystem->xfds, WINPR_FD_READ))) return -1; { @@ -1556,19 +1556,19 @@ static int x11_shadow_subsystem_uninit(rdpShadowSubsystem* sub) if (subsystem->display) { XCloseDisplay(subsystem->display); - subsystem->display = NULL; + subsystem->display = nullptr; } if (subsystem->common.event) { (void)CloseHandle(subsystem->common.event); - subsystem->common.event = NULL; + subsystem->common.event = nullptr; } if (subsystem->cursorPixels) { winpr_aligned_free(subsystem->cursorPixels); - subsystem->cursorPixels = NULL; + subsystem->cursorPixels = nullptr; } return 1; @@ -1583,7 +1583,7 @@ static int x11_shadow_subsystem_start(rdpShadowSubsystem* sub) return -1; if (!(subsystem->thread = - CreateThread(NULL, 0, x11_shadow_subsystem_thread, (void*)subsystem, 0, NULL))) + CreateThread(nullptr, 0, x11_shadow_subsystem_thread, (void*)subsystem, 0, nullptr))) { WLog_ERR(TAG, "Failed to create thread"); return -1; @@ -1606,7 +1606,7 @@ static int x11_shadow_subsystem_stop(rdpShadowSubsystem* sub) (void)WaitForSingleObject(subsystem->thread, INFINITE); (void)CloseHandle(subsystem->thread); - subsystem->thread = NULL; + subsystem->thread = nullptr; } return 1; @@ -1618,7 +1618,7 @@ static rdpShadowSubsystem* x11_shadow_subsystem_new(void) x11ShadowSubsystem* subsystem = (x11ShadowSubsystem*)calloc(1, sizeof(x11ShadowSubsystem)); if (!subsystem) - return NULL; + return nullptr; #ifdef WITH_PAM subsystem->common.Authenticate = x11_shadow_pam_authenticate; diff --git a/server/shadow/cli/shadow.c b/server/shadow/cli/shadow.c index 8e2297c74..934613d2a 100644 --- a/server/shadow/cli/shadow.c +++ b/server/shadow/cli/shadow.c @@ -37,84 +37,86 @@ int main(int argc, char** argv) int status = 0; DWORD dwExitCode = 0; COMMAND_LINE_ARGUMENT_A shadow_args[] = { - { "log-filters", COMMAND_LINE_VALUE_REQUIRED, ":[,:[,...]]", NULL, - NULL, -1, NULL, "Set logger filters, see wLog(7) for details" }, - { "log-level", COMMAND_LINE_VALUE_REQUIRED, "[OFF|FATAL|ERROR|WARN|INFO|DEBUG|TRACE]", NULL, - NULL, -1, NULL, "Set the default log level, see wLog(7) for details" }, - { "port", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, "Server port" }, - { "ipc-socket", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, + { "log-filters", COMMAND_LINE_VALUE_REQUIRED, ":[,:[,...]]", + nullptr, nullptr, -1, nullptr, "Set logger filters, see wLog(7) for details" }, + { "log-level", COMMAND_LINE_VALUE_REQUIRED, "[OFF|FATAL|ERROR|WARN|INFO|DEBUG|TRACE]", + nullptr, nullptr, -1, nullptr, "Set the default log level, see wLog(7) for details" }, + { "port", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr, + "Server port" }, + { "ipc-socket", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr, "Server IPC socket" }, { "bind-address", COMMAND_LINE_VALUE_REQUIRED, "[,, ...]", - NULL, NULL, -1, NULL, + nullptr, nullptr, -1, nullptr, "An address to bind to. Use '[]' for IPv6 addresses, e.g. '[::1]' for " "localhost" }, - { "server-side-cursor", COMMAND_LINE_VALUE_BOOL, NULL, NULL, NULL, -1, NULL, + { "server-side-cursor", COMMAND_LINE_VALUE_BOOL, nullptr, nullptr, nullptr, -1, nullptr, "hide mouse cursor in RDP client." }, - { "monitors", COMMAND_LINE_VALUE_OPTIONAL, "<0,1,2...>", NULL, NULL, -1, NULL, + { "monitors", COMMAND_LINE_VALUE_OPTIONAL, "<0,1,2...>", nullptr, nullptr, -1, nullptr, "Select or list monitors" }, - { "max-connections", COMMAND_LINE_VALUE_REQUIRED, "", 0, NULL, -1, NULL, + { "max-connections", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr, "maximum connections allowed to server, 0 to deactivate" }, - { "mouse-relative", COMMAND_LINE_VALUE_BOOL, NULL, NULL, NULL, -1, NULL, + { "mouse-relative", COMMAND_LINE_VALUE_BOOL, nullptr, nullptr, nullptr, -1, nullptr, "enable support for relative mouse events" }, - { "rect", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, + { "rect", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr, "Select rectangle within monitor to share" }, - { "auth", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, + { "auth", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr, "Clients must authenticate" }, - { "remote-guard", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, + { "remote-guard", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueFalse, nullptr, -1, nullptr, "Remote credential guard" }, - { "restricted-admin", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, + { "restricted-admin", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr, "Restricted Admin" }, - { "vmconnect", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, - NULL, -1, NULL, "Hyper-V console server (bind on vsock://1)" }, - { "may-view", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, + { "vmconnect", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueFalse, + nullptr, -1, nullptr, "Hyper-V console server (bind on vsock://1)" }, + { "may-view", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr, "Clients may view without prompt" }, - { "may-interact", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, + { "may-interact", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr, "Clients may interact without prompt" }, - { "sec", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, + { "sec", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr, "force specific protocol security" }, - { "sec-rdp", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, + { "sec-rdp", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr, "rdp protocol security" }, - { "sec-tls", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, + { "sec-tls", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr, "tls protocol security" }, - { "sec-nla", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, + { "sec-nla", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr, "nla protocol security" }, - { "sec-ext", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, + { "sec-ext", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueFalse, nullptr, -1, nullptr, "nla extended protocol security" }, - { "sam-file", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, + { "sam-file", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr, "NTLM SAM file for NLA authentication" }, - { "keytab", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, + { "keytab", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr, "Kerberos keytab file for NLA authentication" }, - { "ccache", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, + { "ccache", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr, "Kerberos host ccache file for NLA authentication" }, - { "tls-secrets-file", COMMAND_LINE_VALUE_REQUIRED, "", NULL, NULL, -1, NULL, + { "tls-secrets-file", COMMAND_LINE_VALUE_REQUIRED, "", nullptr, nullptr, -1, nullptr, "file where tls secrets shall be stored" }, - { "nsc", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "Allow NSC codec" }, - { "rfx", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, + { "nsc", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr, + "Allow NSC codec" }, + { "rfx", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr, "Allow RFX surface bits" }, - { "gfx", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, + { "gfx", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr, "Allow GFX pipeline" }, - { "gfx-progressive", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, + { "gfx-progressive", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr, "Allow GFX progressive codec" }, - { "gfx-rfx", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, + { "gfx-rfx", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr, "Allow GFX RFX codec" }, - { "gfx-planar", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, + { "gfx-planar", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr, "Allow GFX planar codec" }, - { "gfx-avc420", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, + { "gfx-avc420", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr, "Allow GFX AVC420 codec" }, - { "gfx-avc444", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, + { "gfx-avc444", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueTrue, nullptr, -1, nullptr, "Allow GFX AVC444 codec" }, - { "bitmap-compat", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, + { "bitmap-compat", COMMAND_LINE_VALUE_BOOL, nullptr, BoolValueFalse, nullptr, -1, nullptr, "Limit BitmapUpdate to 1 rectangle (fixes broken windows 11 24H2 clients)" }, - { "version", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_VERSION, NULL, NULL, NULL, -1, - NULL, "Print version" }, - { "buildconfig", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_BUILDCONFIG, NULL, NULL, NULL, - -1, NULL, "Print the build configuration" }, - { "help", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_HELP, NULL, NULL, NULL, -1, "?", - "Print help" }, - { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL } + { "version", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_VERSION, nullptr, nullptr, + nullptr, -1, nullptr, "Print version" }, + { "buildconfig", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_BUILDCONFIG, nullptr, nullptr, + nullptr, -1, nullptr, "Print the build configuration" }, + { "help", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_HELP, nullptr, nullptr, nullptr, -1, + "?", "Print help" }, + { nullptr, 0, nullptr, nullptr, nullptr, -1, nullptr, nullptr } }; - shadow_subsystem_set_entry_builtin(NULL); + shadow_subsystem_set_entry_builtin(nullptr); rdpShadowServer* server = shadow_server_new(); diff --git a/server/shadow/shadow_audin.c b/server/shadow/shadow_audin.c index 2d11d2d73..bfe95fd4e 100644 --- a/server/shadow/shadow_audin.c +++ b/server/shadow/shadow_audin.c @@ -34,8 +34,8 @@ WINPR_ATTR_NODISCARD static UINT AudinServerData(audin_server_context* audin, const SNDIN_DATA* data) { - rdpShadowClient* client = NULL; - rdpShadowSubsystem* subsystem = NULL; + rdpShadowClient* client = nullptr; + rdpShadowSubsystem* subsystem = nullptr; WINPR_ASSERT(audin); WINPR_ASSERT(data); @@ -83,14 +83,14 @@ BOOL shadow_client_audin_init(rdpShadowClient* client) } else { - if (!audin_server_set_formats(client->audin, -1, NULL)) + if (!audin_server_set_formats(client->audin, -1, nullptr)) goto fail; } return TRUE; fail: audin_server_context_free(audin); - client->audin = NULL; + client->audin = nullptr; #endif return FALSE; } @@ -101,6 +101,6 @@ void shadow_client_audin_uninit(rdpShadowClient* client) #if defined(CHANNEL_AUDIN_SERVER) audin_server_context_free(client->audin); - client->audin = NULL; + client->audin = nullptr; #endif } diff --git a/server/shadow/shadow_capture.c b/server/shadow/shadow_capture.c index 41c6b02ce..0ca4b37df 100644 --- a/server/shadow/shadow_capture.c +++ b/server/shadow/shadow_capture.c @@ -97,8 +97,8 @@ static BOOL color_equal(UINT32 colorA, UINT32 formatA, UINT32 colorB, UINT32 for BYTE bg = 0; BYTE bb = 0; BYTE ba = 0; - FreeRDPSplitColor(colorA, formatA, &ar, &ag, &ab, &aa, NULL); - FreeRDPSplitColor(colorB, formatB, &br, &bg, &bb, &ba, NULL); + FreeRDPSplitColor(colorA, formatA, &ar, &ag, &ab, &aa, nullptr); + FreeRDPSplitColor(colorB, formatB, &br, &bg, &bb, &ba, nullptr); if (ar != br) return FALSE; @@ -138,8 +138,8 @@ static BOOL color_equal_no_alpha(UINT32 colorA, UINT32 formatA, UINT32 colorB, U BYTE br = 0; BYTE bg = 0; BYTE bb = 0; - FreeRDPSplitColor(colorA, formatA, &ar, &ag, &ab, NULL, NULL); - FreeRDPSplitColor(colorB, formatB, &br, &bg, &bb, NULL, NULL); + FreeRDPSplitColor(colorA, formatA, &ar, &ag, &ab, nullptr, nullptr); + FreeRDPSplitColor(colorB, formatB, &br, &bg, &bb, nullptr, nullptr); if (ar != br) return FALSE; @@ -323,7 +323,7 @@ rdpShadowCapture* shadow_capture_new(rdpShadowServer* server) rdpShadowCapture* capture = (rdpShadowCapture*)calloc(1, sizeof(rdpShadowCapture)); if (!capture) - return NULL; + return nullptr; capture->server = server; @@ -333,7 +333,7 @@ rdpShadowCapture* shadow_capture_new(rdpShadowServer* server) WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC shadow_capture_free(capture); WINPR_PRAGMA_DIAG_POP - return NULL; + return nullptr; } return capture; diff --git a/server/shadow/shadow_client.c b/server/shadow/shadow_client.c index 93c8a7330..268e164f8 100644 --- a/server/shadow/shadow_client.c +++ b/server/shadow/shadow_client.c @@ -115,8 +115,8 @@ static inline BOOL shadow_client_rdpgfx_new_surface(rdpShadowClient* client) UINT error = CHANNEL_RC_OK; RDPGFX_CREATE_SURFACE_PDU createSurface; RDPGFX_MAP_SURFACE_TO_OUTPUT_PDU surfaceToOutput; - RdpgfxServerContext* context = NULL; - rdpSettings* settings = NULL; + RdpgfxServerContext* context = nullptr; + rdpSettings* settings = nullptr; WINPR_ASSERT(client); context = client->rdpgfx; @@ -158,7 +158,7 @@ static inline BOOL shadow_client_rdpgfx_release_surface(rdpShadowClient* client) { UINT error = CHANNEL_RC_OK; RDPGFX_DELETE_SURFACE_PDU pdu; - RdpgfxServerContext* context = NULL; + RdpgfxServerContext* context = nullptr; WINPR_ASSERT(client); @@ -182,8 +182,8 @@ static inline BOOL shadow_client_rdpgfx_reset_graphic(rdpShadowClient* client) { UINT error = CHANNEL_RC_OK; RDPGFX_RESET_GRAPHICS_PDU pdu = WINPR_C_ARRAY_INIT; - RdpgfxServerContext* context = NULL; - rdpSettings* settings = NULL; + RdpgfxServerContext* context = nullptr; + rdpSettings* settings = nullptr; WINPR_ASSERT(client); WINPR_ASSERT(client->rdpgfx); @@ -218,14 +218,14 @@ static inline void shadow_client_free_queued_message(void* obj) if (message->Free) { message->Free(message); - message->Free = NULL; + message->Free = nullptr; } } static void shadow_client_context_free(freerdp_peer* peer, rdpContext* context) { rdpShadowClient* client = (rdpShadowClient*)context; - rdpShadowServer* server = NULL; + rdpShadowServer* server = nullptr; WINPR_UNUSED(peer); if (!client) @@ -243,9 +243,9 @@ static void shadow_client_context_free(freerdp_peer* peer, rdpContext* context) region16_uninit(&(client->invalidRegion)); DeleteCriticalSection(&(client->lock)); - client->MsgQueue = NULL; - client->encoder = NULL; - client->vcm = NULL; + client->MsgQueue = nullptr; + client->encoder = nullptr; + client->vcm = nullptr; } WINPR_ATTR_NODISCARD @@ -254,10 +254,10 @@ static BOOL shadow_client_context_new(freerdp_peer* peer, rdpContext* context) BOOL NSCodec = 0; const char bind_address[] = "bind-address,"; rdpShadowClient* client = (rdpShadowClient*)context; - rdpSettings* settings = NULL; - const rdpSettings* srvSettings = NULL; - rdpShadowServer* server = NULL; - const wObject cb = { NULL, NULL, NULL, shadow_client_free_queued_message, NULL }; + rdpSettings* settings = nullptr; + const rdpSettings* srvSettings = nullptr; + rdpShadowServer* server = nullptr; + const wObject cb = { nullptr, nullptr, nullptr, shadow_client_free_queued_message, nullptr }; WINPR_ASSERT(client); WINPR_ASSERT(peer); @@ -396,8 +396,8 @@ static inline BOOL shadow_client_recalc_desktop_size(rdpShadowClient* client) { INT32 width = 0; INT32 height = 0; - rdpShadowServer* server = NULL; - rdpSettings* settings = NULL; + rdpShadowServer* server = nullptr; + rdpSettings* settings = nullptr; RECTANGLE_16 viewport = WINPR_C_ARRAY_INIT; WINPR_ASSERT(client); @@ -433,8 +433,8 @@ static inline BOOL shadow_client_recalc_desktop_size(rdpShadowClient* client) WINPR_ATTR_NODISCARD static BOOL shadow_client_capabilities(freerdp_peer* peer) { - rdpShadowSubsystem* subsystem = NULL; - rdpShadowClient* client = NULL; + rdpShadowSubsystem* subsystem = nullptr; + rdpShadowClient* client = nullptr; BOOL ret = TRUE; WINPR_ASSERT(peer); @@ -464,9 +464,9 @@ WINPR_ATTR_NODISCARD static BOOL shadow_send_desktop_resize(rdpShadowClient* client) { BOOL rc = 0; - rdpUpdate* update = NULL; - rdpSettings* settings = NULL; - const freerdp_peer* peer = NULL; + rdpUpdate* update = nullptr; + rdpSettings* settings = nullptr; + const freerdp_peer* peer = nullptr; WINPR_ASSERT(client); @@ -518,10 +518,10 @@ WINPR_ATTR_NODISCARD static BOOL shadow_client_post_connect(freerdp_peer* peer) { int authStatus = 0; - rdpSettings* settings = NULL; - rdpShadowClient* client = NULL; - rdpShadowServer* server = NULL; - rdpShadowSubsystem* subsystem = NULL; + rdpSettings* settings = nullptr; + rdpShadowClient* client = nullptr; + rdpShadowServer* server = nullptr; + rdpShadowSubsystem* subsystem = nullptr; WINPR_ASSERT(peer); @@ -562,7 +562,7 @@ static BOOL shadow_client_post_connect(freerdp_peer* peer) if (shadow_client_channels_post_connect(client) != CHANNEL_RC_OK) return FALSE; - shadow_client_mark_invalid(client, 0, NULL); + shadow_client_mark_invalid(client, 0, nullptr); authStatus = -1; const char* Username = freerdp_settings_get_string(settings, FreeRDP_Username); @@ -635,7 +635,7 @@ WINPR_ATTR_NODISCARD static BOOL shadow_client_refresh_request(rdpShadowClient* client) { wMessage message = WINPR_C_ARRAY_INIT; - wMessagePipe* MsgPipe = NULL; + wMessagePipe* MsgPipe = nullptr; WINPR_ASSERT(client); WINPR_ASSERT(client->subsystem); @@ -644,10 +644,10 @@ static BOOL shadow_client_refresh_request(rdpShadowClient* client) WINPR_ASSERT(MsgPipe); message.id = SHADOW_MSG_IN_REFRESH_REQUEST_ID; - message.wParam = NULL; - message.lParam = NULL; + message.wParam = nullptr; + message.lParam = nullptr; message.context = (void*)client; - message.Free = NULL; + message.Free = nullptr; return MessageQueue_Dispatch(MsgPipe->In, &message); } @@ -655,7 +655,7 @@ WINPR_ATTR_NODISCARD static BOOL shadow_client_refresh_rect(rdpContext* context, BYTE count, const RECTANGLE_16* areas) { rdpShadowClient* client = (rdpShadowClient*)context; - RECTANGLE_16* rects = NULL; + RECTANGLE_16* rects = nullptr; /* It is invalid if we have area count but no actual area */ if (count && !areas) @@ -676,7 +676,7 @@ static BOOL shadow_client_refresh_rect(rdpContext* context, BYTE count, const RE } else { - shadow_client_mark_invalid(client, 0, NULL); + shadow_client_mark_invalid(client, 0, nullptr); } return shadow_client_refresh_request(client); @@ -701,7 +701,7 @@ static BOOL shadow_client_suppress_output(rdpContext* context, BYTE allow, const } else { - shadow_client_mark_invalid(client, 0, NULL); + shadow_client_mark_invalid(client, 0, nullptr); } } @@ -731,7 +731,7 @@ static BOOL shadow_client_activate(freerdp_peer* peer) } /* Update full screen in next update */ - return shadow_client_refresh_rect(&client->context, 0, NULL); + return shadow_client_refresh_rect(&client->context, 0, nullptr); } WINPR_ATTR_NODISCARD @@ -739,10 +739,10 @@ static BOOL shadow_client_logon(freerdp_peer* peer, const SEC_WINNT_AUTH_IDENTIT BOOL automatic) { BOOL rc = FALSE; - char* user = NULL; - char* domain = NULL; - char* password = NULL; - rdpSettings* settings = NULL; + char* user = nullptr; + char* domain = nullptr; + char* password = nullptr; + rdpSettings* settings = nullptr; WINPR_UNUSED(automatic); @@ -757,13 +757,14 @@ static BOOL shadow_client_logon(freerdp_peer* peer, const SEC_WINNT_AUTH_IDENTIT if (identity->Flags & SEC_WINNT_AUTH_IDENTITY_UNICODE) { if (identity->User) - user = ConvertWCharNToUtf8Alloc(identity->User, identity->UserLength, NULL); + user = ConvertWCharNToUtf8Alloc(identity->User, identity->UserLength, nullptr); if (identity->Domain) - domain = ConvertWCharNToUtf8Alloc(identity->Domain, identity->DomainLength, NULL); + domain = ConvertWCharNToUtf8Alloc(identity->Domain, identity->DomainLength, nullptr); if (identity->Password) - password = ConvertWCharNToUtf8Alloc(identity->Password, identity->PasswordLength, NULL); + password = + ConvertWCharNToUtf8Alloc(identity->Password, identity->PasswordLength, nullptr); } else { @@ -839,7 +840,7 @@ static UINT shadow_client_rdpgfx_frame_acknowledge(RdpgfxServerContext* context, const RDPGFX_FRAME_ACKNOWLEDGE_PDU* frameAcknowledge) { - rdpShadowClient* client = NULL; + rdpShadowClient* client = nullptr; WINPR_ASSERT(context); WINPR_ASSERT(frameAcknowledge); @@ -894,8 +895,8 @@ static BOOL shadow_client_caps_test_version(RdpgfxServerContext* context, rdpSha BOOL h264, const RDPGFX_CAPSET* capsSets, UINT32 capsSetCount, UINT32 capsVersion, UINT* rc) { - const rdpSettings* srvSettings = NULL; - rdpSettings* clientSettings = NULL; + const rdpSettings* srvSettings = nullptr; + rdpSettings* clientSettings = nullptr; WINPR_ASSERT(context); WINPR_ASSERT(client); @@ -985,8 +986,8 @@ static UINT shadow_client_rdpgfx_caps_advertise(RdpgfxServerContext* context, const RDPGFX_CAPS_ADVERTISE_PDU* capsAdvertise) { UINT rc = ERROR_INTERNAL_ERROR; - const rdpSettings* srvSettings = NULL; - rdpSettings* clientSettings = NULL; + const rdpSettings* srvSettings = nullptr; + rdpSettings* clientSettings = nullptr; BOOL h264 = FALSE; UINT32 flags = 0; @@ -1017,7 +1018,7 @@ static UINT shadow_client_rdpgfx_caps_advertise(RdpgfxServerContext* context, #endif /* Request full screen update for new gfx channel */ - if (!shadow_client_refresh_rect(&client->context, 0, NULL)) + if (!shadow_client_refresh_rect(&client->context, 0, nullptr)) return rc; if (shadow_client_caps_test_version(context, client, h264, capsAdvertise->capsSets, @@ -1166,8 +1167,8 @@ static BOOL shadow_client_send_surface_gfx(rdpShadowClient* client, const BYTE* UINT32 id = 0; UINT error = CHANNEL_RC_OK; const rdpContext* context = (const rdpContext*)client; - const rdpSettings* settings = NULL; - rdpShadowEncoder* encoder = NULL; + const rdpSettings* settings = nullptr; + rdpShadowEncoder* encoder = nullptr; RDPGFX_SURFACE_COMMAND cmd = WINPR_C_ARRAY_INIT; RDPGFX_START_FRAME_PDU cmdstart = WINPR_C_ARRAY_INIT; RDPGFX_END_FRAME_PDU cmdend = WINPR_C_ARRAY_INIT; @@ -1311,7 +1312,7 @@ static BOOL shadow_client_send_surface_gfx(rdpShadowClient* client, const BYTE* if (freerdp_settings_get_bool(settings, FreeRDP_RemoteFxCodec) && (id != 0)) { BOOL rc = 0; - wStream* s = NULL; + wStream* s = nullptr; RFX_RECT rect; if (shadow_encoder_prepare(encoder, FREERDP_CODEC_REMOTEFX) < 0) @@ -1320,7 +1321,7 @@ static BOOL shadow_client_send_surface_gfx(rdpShadowClient* client, const BYTE* return FALSE; } - s = Stream_New(NULL, 1024); + s = Stream_New(nullptr, 1024); WINPR_ASSERT(s); WINPR_ASSERT(cmd.left <= UINT16_MAX); @@ -1431,7 +1432,7 @@ static BOOL shadow_client_send_surface_gfx(rdpShadowClient* client, const BYTE* freerdp_planar_topdown_image(encoder->planar, TRUE); cmd.data = freerdp_bitmap_compress_planar(encoder->planar, src, SrcFormat, w, h, nSrcStep, - NULL, &cmd.length); + nullptr, &cmd.length); WINPR_ASSERT(cmd.data || (cmd.length == 0)); cmd.codecId = RDPGFX_CODECID_PLANAR; @@ -1456,7 +1457,7 @@ static BOOL shadow_client_send_surface_gfx(rdpShadowClient* client, const BYTE* return FALSE; BOOL rc = freerdp_image_copy_no_overlap(data, PIXEL_FORMAT_BGRA32, 0, 0, 0, w, h, pSrcData, - SrcFormat, nSrcStep, cmd.left, cmd.top, NULL, 0); + SrcFormat, nSrcStep, cmd.left, cmd.top, nullptr, 0); if (!rc) { free(data); @@ -1528,13 +1529,13 @@ static BOOL shadow_client_send_surface_bits(rdpShadowClient* client, BYTE* pSrcD BOOL ret = TRUE; BOOL first = 0; BOOL last = 0; - wStream* s = NULL; + wStream* s = nullptr; size_t numMessages = 0; UINT32 frameId = 0; - rdpUpdate* update = NULL; + rdpUpdate* update = nullptr; rdpContext* context = (rdpContext*)client; - rdpSettings* settings = NULL; - rdpShadowEncoder* encoder = NULL; + rdpSettings* settings = nullptr; + rdpShadowEncoder* encoder = nullptr; SURFACE_BITS_COMMAND cmd = WINPR_C_ARRAY_INIT; if (!context || !pSrcData) @@ -1687,8 +1688,8 @@ static BOOL shadow_client_send_bitmap_update(rdpShadowClient* client, BYTE* pSrc UINT16 nWidth, UINT16 nHeight) { BOOL ret = TRUE; - BYTE* data = NULL; - BYTE* buffer = NULL; + BYTE* data = nullptr; + BYTE* buffer = nullptr; UINT32 k = 0; UINT32 yIdx = 0; UINT32 xIdx = 0; @@ -1696,11 +1697,11 @@ static BOOL shadow_client_send_bitmap_update(rdpShadowClient* client, BYTE* pSrc UINT32 cols = 0; UINT32 DstSize = 0; UINT32 SrcFormat = 0; - BITMAP_DATA* bitmap = NULL; + BITMAP_DATA* bitmap = nullptr; rdpContext* context = (rdpContext*)client; UINT32 totalBitmapSize = 0; UINT32 updateSizeEstimate = 0; - BITMAP_DATA* bitmapData = NULL; + BITMAP_DATA* bitmapData = nullptr; BITMAP_UPDATE bitmapUpdate = WINPR_C_ARRAY_INIT; if (!context || !pSrcData) @@ -1797,9 +1798,9 @@ static BOOL shadow_client_send_bitmap_update(rdpShadowClient* client, BYTE* pSrc DstSize = 64 * 64 * 4; buffer = encoder->grid[k]; - ret = interleaved_compress(encoder->interleaved, buffer, &DstSize, bitmap->width, - bitmap->height, pSrcData, SrcFormat, nSrcStep, - bitmap->destLeft, bitmap->destTop, NULL, bitsPerPixel); + ret = interleaved_compress( + encoder->interleaved, buffer, &DstSize, bitmap->width, bitmap->height, pSrcData, + SrcFormat, nSrcStep, bitmap->destLeft, bitmap->destTop, nullptr, bitsPerPixel); if (!ret) goto out; bitmap->bitmapDataStream = buffer; @@ -1840,7 +1841,7 @@ static BOOL shadow_client_send_bitmap_update(rdpShadowClient* client, BYTE* pSrc UINT32 j = 0; UINT32 updateSize = 0; UINT32 newUpdateSize = 0; - BITMAP_DATA* fragBitmapData = NULL; + BITMAP_DATA* fragBitmapData = nullptr; if (k > 0) fragBitmapData = (BITMAP_DATA*)calloc(k, sizeof(BITMAP_DATA)); @@ -1905,17 +1906,17 @@ static BOOL shadow_client_send_surface_update(rdpShadowClient* client, SHADOW_GF INT64 nWidth = 0; INT64 nHeight = 0; rdpContext* context = (rdpContext*)client; - rdpSettings* settings = NULL; - rdpShadowServer* server = NULL; - rdpShadowSurface* surface = NULL; + rdpSettings* settings = nullptr; + rdpShadowServer* server = nullptr; + rdpShadowSurface* surface = nullptr; REGION16 invalidRegion; RECTANGLE_16 surfaceRect; - const RECTANGLE_16* extents = NULL; - BYTE* pSrcData = NULL; + const RECTANGLE_16* extents = nullptr; + BYTE* pSrcData = nullptr; UINT32 nSrcStep = 0; UINT32 SrcFormat = 0; UINT32 numRects = 0; - const RECTANGLE_16* rects = NULL; + const RECTANGLE_16* rects = nullptr; if (!context || !pStatus) return FALSE; @@ -2078,8 +2079,8 @@ WINPR_ATTR_NODISCARD static BOOL shadow_client_send_resize(rdpShadowClient* client, SHADOW_GFX_STATUS* pStatus) { rdpContext* context = (rdpContext*)client; - rdpSettings* settings = NULL; - freerdp_peer* peer = NULL; + rdpSettings* settings = nullptr; + freerdp_peer* peer = nullptr; if (!context || !pStatus) return FALSE; @@ -2128,7 +2129,7 @@ WINPR_ATTR_NODISCARD static BOOL shadow_client_surface_update(rdpShadowClient* client, REGION16* region) { UINT32 numRects = 0; - const RECTANGLE_16* rects = NULL; + const RECTANGLE_16* rects = nullptr; rects = region16_rects(region, &numRects); shadow_client_mark_invalid(client, numRects, rects); return TRUE; @@ -2144,8 +2145,8 @@ WINPR_ATTR_NODISCARD static inline BOOL shadow_client_no_surface_update(rdpShadowClient* client, SHADOW_GFX_STATUS* pStatus) { - rdpShadowServer* server = NULL; - rdpShadowSurface* surface = NULL; + rdpShadowServer* server = nullptr; + rdpShadowSurface* surface = nullptr; WINPR_UNUSED(pStatus); WINPR_ASSERT(client); server = client->server; @@ -2304,18 +2305,18 @@ static DWORD WINAPI shadow_client_thread(LPVOID arg) wMessage pointerPositionMsg = WINPR_C_ARRAY_INIT; wMessage pointerAlphaMsg = WINPR_C_ARRAY_INIT; wMessage audioVolumeMsg = WINPR_C_ARRAY_INIT; - HANDLE ChannelEvent = 0; - void* UpdateSubscriber = NULL; - HANDLE UpdateEvent = 0; - freerdp_peer* peer = NULL; - rdpContext* context = NULL; - rdpSettings* settings = NULL; - rdpShadowServer* server = NULL; - rdpShadowSubsystem* subsystem = NULL; - wMessageQueue* MsgQueue = NULL; + HANDLE ChannelEvent = nullptr; + void* UpdateSubscriber = nullptr; + HANDLE UpdateEvent = nullptr; + freerdp_peer* peer = nullptr; + rdpContext* context = nullptr; + rdpSettings* settings = nullptr; + rdpShadowServer* server = nullptr; + rdpShadowSubsystem* subsystem = nullptr; + wMessageQueue* MsgQueue = nullptr; /* This should only be visited in client thread */ SHADOW_GFX_STATUS gfxstatus = WINPR_C_ARRAY_INIT; - rdpUpdate* update = NULL; + rdpUpdate* update = nullptr; WINPR_ASSERT(client); @@ -2542,11 +2543,11 @@ static DWORD WINAPI shadow_client_thread(LPVOID arg) { /* Drain messages. Pointer update could be accumulated. */ pointerPositionMsg.id = 0; - pointerPositionMsg.Free = NULL; + pointerPositionMsg.Free = nullptr; pointerAlphaMsg.id = 0; - pointerAlphaMsg.Free = NULL; + pointerAlphaMsg.Free = nullptr; audioVolumeMsg.id = 0; - audioVolumeMsg.Free = NULL; + audioVolumeMsg.Free = nullptr; while (MessageQueue_Peek(MsgQueue, &message, TRUE)) { @@ -2646,7 +2647,7 @@ fail: if (UpdateSubscriber) { shadow_multiclient_release_subscriber(UpdateSubscriber); - UpdateSubscriber = NULL; + UpdateSubscriber = nullptr; } if (peer->connected && subsystem->ClientDisconnect) @@ -2665,8 +2666,8 @@ out: BOOL shadow_client_accepted(freerdp_listener* listener, freerdp_peer* peer) { - rdpShadowClient* client = NULL; - rdpShadowServer* server = NULL; + rdpShadowClient* client = nullptr; + rdpShadowServer* server = nullptr; if (!listener || !peer) return FALSE; @@ -2685,7 +2686,7 @@ BOOL shadow_client_accepted(freerdp_listener* listener, freerdp_peer* peer) client = (rdpShadowClient*)peer->context; WINPR_ASSERT(client); - if (!(client->thread = CreateThread(NULL, 0, shadow_client_thread, client, 0, NULL))) + if (!(client->thread = CreateThread(nullptr, 0, shadow_client_thread, client, 0, nullptr))) { freerdp_peer_context_free(peer); return FALSE; @@ -2694,7 +2695,7 @@ BOOL shadow_client_accepted(freerdp_listener* listener, freerdp_peer* peer) { /* Close the thread handle to make it detached. */ (void)CloseHandle(client->thread); - client->thread = NULL; + client->thread = nullptr; } return TRUE; @@ -2702,7 +2703,7 @@ BOOL shadow_client_accepted(freerdp_listener* listener, freerdp_peer* peer) static void shadow_msg_out_addref(wMessage* message) { - SHADOW_MSG_OUT* msg = NULL; + SHADOW_MSG_OUT* msg = nullptr; WINPR_ASSERT(message); msg = (SHADOW_MSG_OUT*)message->wParam; @@ -2713,7 +2714,7 @@ static void shadow_msg_out_addref(wMessage* message) static void shadow_msg_out_release(wMessage* message) { - SHADOW_MSG_OUT* msg = NULL; + SHADOW_MSG_OUT* msg = nullptr; WINPR_ASSERT(message); msg = (SHADOW_MSG_OUT*)message->wParam; @@ -2796,7 +2797,7 @@ int shadow_client_boardcast_msg(rdpShadowServer* server, void* context, UINT32 t int shadow_client_boardcast_quit(rdpShadowServer* server, int nExitCode) { - wMessageQueue* queue = NULL; + wMessageQueue* queue = nullptr; int count = 0; WINPR_ASSERT(server); diff --git a/server/shadow/shadow_encoder.c b/server/shadow/shadow_encoder.c index c9d5b0f42..69f8a49c0 100644 --- a/server/shadow/shadow_encoder.c +++ b/server/shadow/shadow_encoder.c @@ -115,13 +115,13 @@ static int shadow_encoder_uninit_grid(rdpShadowEncoder* encoder) if (encoder->gridBuffer) { free(encoder->gridBuffer); - encoder->gridBuffer = NULL; + encoder->gridBuffer = nullptr; } if (encoder->grid) { free((void*)encoder->grid); - encoder->grid = NULL; + encoder->grid = nullptr; } encoder->gridWidth = 0; @@ -305,7 +305,7 @@ static int shadow_encoder_init(rdpShadowEncoder* encoder) return -1; if (!encoder->bs) - encoder->bs = Stream_New(NULL, 4ULL * encoder->maxTileWidth * encoder->maxTileHeight); + encoder->bs = Stream_New(nullptr, 4ULL * encoder->maxTileWidth * encoder->maxTileHeight); if (!encoder->bs) return -1; @@ -318,7 +318,7 @@ static int shadow_encoder_uninit_rfx(rdpShadowEncoder* encoder) if (encoder->rfx) { rfx_context_free(encoder->rfx); - encoder->rfx = NULL; + encoder->rfx = nullptr; } encoder->codecs &= (UINT32)~FREERDP_CODEC_REMOTEFX; @@ -330,7 +330,7 @@ static int shadow_encoder_uninit_nsc(rdpShadowEncoder* encoder) if (encoder->nsc) { nsc_context_free(encoder->nsc); - encoder->nsc = NULL; + encoder->nsc = nullptr; } encoder->codecs &= (UINT32)~FREERDP_CODEC_NSCODEC; @@ -342,7 +342,7 @@ static int shadow_encoder_uninit_planar(rdpShadowEncoder* encoder) if (encoder->planar) { freerdp_bitmap_planar_context_free(encoder->planar); - encoder->planar = NULL; + encoder->planar = nullptr; } encoder->codecs &= (UINT32)~FREERDP_CODEC_PLANAR; @@ -354,7 +354,7 @@ static int shadow_encoder_uninit_interleaved(rdpShadowEncoder* encoder) if (encoder->interleaved) { bitmap_interleaved_context_free(encoder->interleaved); - encoder->interleaved = NULL; + encoder->interleaved = nullptr; } encoder->codecs &= (UINT32)~FREERDP_CODEC_INTERLEAVED; @@ -366,7 +366,7 @@ static int shadow_encoder_uninit_h264(rdpShadowEncoder* encoder) if (encoder->h264) { h264_context_free(encoder->h264); - encoder->h264 = NULL; + encoder->h264 = nullptr; } encoder->codecs &= (UINT32) ~(FREERDP_CODEC_AVC420 | FREERDP_CODEC_AVC444); @@ -379,7 +379,7 @@ static int shadow_encoder_uninit_progressive(rdpShadowEncoder* encoder) if (encoder->progressive) { progressive_context_free(encoder->progressive); - encoder->progressive = NULL; + encoder->progressive = nullptr; } encoder->codecs &= (UINT32)~FREERDP_CODEC_PROGRESSIVE; @@ -393,7 +393,7 @@ static int shadow_encoder_uninit(rdpShadowEncoder* encoder) if (encoder->bs) { Stream_Free(encoder->bs, TRUE); - encoder->bs = NULL; + encoder->bs = nullptr; } shadow_encoder_uninit_rfx(encoder); @@ -503,12 +503,12 @@ int shadow_encoder_prepare(rdpShadowEncoder* encoder, UINT32 codecs) rdpShadowEncoder* shadow_encoder_new(rdpShadowClient* client) { - rdpShadowEncoder* encoder = NULL; + rdpShadowEncoder* encoder = nullptr; rdpShadowServer* server = client->server; encoder = (rdpShadowEncoder*)calloc(1, sizeof(rdpShadowEncoder)); if (!encoder) - return NULL; + return nullptr; encoder->client = client; encoder->server = server; @@ -518,7 +518,7 @@ rdpShadowEncoder* shadow_encoder_new(rdpShadowClient* client) if (shadow_encoder_init(encoder) < 0) { shadow_encoder_free(encoder); - return NULL; + return nullptr; } return encoder; diff --git a/server/shadow/shadow_encomsp.c b/server/shadow/shadow_encomsp.c index b3c48887c..e7e51bfe7 100644 --- a/server/shadow/shadow_encomsp.c +++ b/server/shadow/shadow_encomsp.c @@ -133,6 +133,6 @@ void shadow_client_encomsp_uninit(rdpShadowClient* client) { client->encomsp->Stop(client->encomsp); encomsp_server_context_free(client->encomsp); - client->encomsp = NULL; + client->encomsp = nullptr; } } diff --git a/server/shadow/shadow_lobby.c b/server/shadow/shadow_lobby.c index a85f8e619..0ee82d3dc 100644 --- a/server/shadow/shadow_lobby.c +++ b/server/shadow/shadow_lobby.c @@ -79,10 +79,10 @@ BOOL shadow_client_init_lobby(rdpShadowServer* server) goto fail; if (rdtk_label_draw(surface, invalidRect.left, invalidRect.top, (UINT16)width, (UINT16)height, - NULL, "Welcome", 0, 0) < 0) + nullptr, "Welcome", 0, 0) < 0) goto fail; - // rdtk_button_draw(surface, 16, 64, 128, 32, NULL, "button"); - // rdtk_text_field_draw(surface, 16, 128, 128, 32, NULL, "text field"); + // rdtk_button_draw(surface, 16, 64, 128, 32, nullptr, "button"); + // rdtk_text_field_draw(surface, 16, 128, 128, 32, nullptr, "text field"); #endif if (!region16_union_rect(&(lobby->invalidRegion), &(lobby->invalidRegion), &invalidRect)) diff --git a/server/shadow/shadow_mcevent.c b/server/shadow/shadow_mcevent.c index 905f5aa74..f4c9dc25b 100644 --- a/server/shadow/shadow_mcevent.c +++ b/server/shadow/shadow_mcevent.c @@ -51,15 +51,15 @@ rdpShadowMultiClientEvent* shadow_multiclient_new(void) if (!event) goto out_error; - event->event = CreateEvent(NULL, TRUE, FALSE, NULL); + event->event = CreateEvent(nullptr, TRUE, FALSE, nullptr); if (!event->event) goto out_free; - event->barrierEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + event->barrierEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr); if (!event->barrierEvent) goto out_free_event; - event->doneEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + event->doneEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr); if (!event->doneEvent) goto out_free_barrierEvent; @@ -87,7 +87,7 @@ out_free_event: out_free: free(event); out_error: - return (rdpShadowMultiClientEvent*)NULL; + return (rdpShadowMultiClientEvent*)nullptr; } void shadow_multiclient_free(rdpShadowMultiClientEvent* event) @@ -106,8 +106,8 @@ void shadow_multiclient_free(rdpShadowMultiClientEvent* event) static void Publish(rdpShadowMultiClientEvent* event) { - wArrayList* subscribers = NULL; - struct rdp_shadow_multiclient_subscriber* subscriber = NULL; + wArrayList* subscribers = nullptr; + struct rdp_shadow_multiclient_subscriber* subscriber = nullptr; subscribers = event->subscribers; @@ -240,10 +240,10 @@ static BOOL Consume(struct rdp_shadow_multiclient_subscriber* subscriber, BOOL w void* shadow_multiclient_get_subscriber(rdpShadowMultiClientEvent* event) { - struct rdp_shadow_multiclient_subscriber* subscriber = NULL; + struct rdp_shadow_multiclient_subscriber* subscriber = nullptr; if (!event) - return NULL; + return nullptr; EnterCriticalSection(&(event->lock)); @@ -272,7 +272,7 @@ out_free: free(subscriber); out_error: LeaveCriticalSection(&(event->lock)); - return NULL; + return nullptr; } /* @@ -283,8 +283,8 @@ out_error: */ void shadow_multiclient_release_subscriber(void* subscriber) { - struct rdp_shadow_multiclient_subscriber* s = NULL; - rdpShadowMultiClientEvent* event = NULL; + struct rdp_shadow_multiclient_subscriber* s = nullptr; + rdpShadowMultiClientEvent* event = nullptr; if (!subscriber) return; @@ -309,8 +309,8 @@ void shadow_multiclient_release_subscriber(void* subscriber) BOOL shadow_multiclient_consume(void* subscriber) { - struct rdp_shadow_multiclient_subscriber* s = NULL; - rdpShadowMultiClientEvent* event = NULL; + struct rdp_shadow_multiclient_subscriber* s = nullptr; + rdpShadowMultiClientEvent* event = nullptr; BOOL ret = FALSE; if (!subscriber) @@ -335,7 +335,7 @@ BOOL shadow_multiclient_consume(void* subscriber) HANDLE shadow_multiclient_getevent(void* subscriber) { if (!subscriber) - return (HANDLE)NULL; + return (HANDLE) nullptr; return ((struct rdp_shadow_multiclient_subscriber*)subscriber)->ref->event; } diff --git a/server/shadow/shadow_rdpgfx.c b/server/shadow/shadow_rdpgfx.c index 781ee20d2..aa193e5b6 100644 --- a/server/shadow/shadow_rdpgfx.c +++ b/server/shadow/shadow_rdpgfx.c @@ -54,6 +54,6 @@ void shadow_client_rdpgfx_uninit(rdpShadowClient* client) #if defined(CHANNEL_RDPGFX_SERVER) rdpgfx_server_context_free(client->rdpgfx); #endif - client->rdpgfx = NULL; + client->rdpgfx = nullptr; } } diff --git a/server/shadow/shadow_rdpsnd.c b/server/shadow/shadow_rdpsnd.c index 6c84a7c5d..76b2d8dcc 100644 --- a/server/shadow/shadow_rdpsnd.c +++ b/server/shadow/shadow_rdpsnd.c @@ -92,6 +92,6 @@ void shadow_client_rdpsnd_uninit(rdpShadowClient* client) { client->rdpsnd->Stop(client->rdpsnd); rdpsnd_server_context_free(client->rdpsnd); - client->rdpsnd = NULL; + client->rdpsnd = nullptr; } } diff --git a/server/shadow/shadow_remdesk.c b/server/shadow/shadow_remdesk.c index 15fd19b86..5a9800153 100644 --- a/server/shadow/shadow_remdesk.c +++ b/server/shadow/shadow_remdesk.c @@ -52,6 +52,6 @@ void shadow_client_remdesk_uninit(rdpShadowClient* client) { client->remdesk->Stop(client->remdesk); remdesk_server_context_free(client->remdesk); - client->remdesk = NULL; + client->remdesk = nullptr; } } diff --git a/server/shadow/shadow_screen.c b/server/shadow/shadow_screen.c index 779c7291b..16c942e62 100644 --- a/server/shadow/shadow_screen.c +++ b/server/shadow/shadow_screen.c @@ -95,7 +95,7 @@ fail: shadow_screen_free(screen); WINPR_PRAGMA_DIAG_POP - return NULL; + return nullptr; } void shadow_screen_free(rdpShadowScreen* screen) @@ -110,13 +110,13 @@ void shadow_screen_free(rdpShadowScreen* screen) if (screen->primary) { shadow_surface_free(screen->primary); - screen->primary = NULL; + screen->primary = nullptr; } if (screen->lobby) { shadow_surface_free(screen->lobby); - screen->lobby = NULL; + screen->lobby = nullptr; } free(screen); diff --git a/server/shadow/shadow_server.c b/server/shadow/shadow_server.c index 9adb406bc..51eff410f 100644 --- a/server/shadow/shadow_server.c +++ b/server/shadow/shadow_server.c @@ -106,7 +106,7 @@ static int shadow_server_print_command_line_help(int argc, char** argv, size_t nrArgs = 0; { const COMMAND_LINE_ARGUMENT_A* arg = largs; - while (arg->Name != NULL) + while (arg->Name != nullptr) { nrArgs++; arg++; @@ -170,7 +170,7 @@ static int shadow_server_print_command_line_help(int argc, char** argv, free(str); } - } while ((arg = CommandLineFindNextArgumentA(arg)) != NULL); + } while ((arg = CommandLineFindNextArgumentA(arg)) != nullptr); rc = 1; fail: @@ -213,7 +213,7 @@ int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** a { int status = 0; DWORD flags = 0; - const COMMAND_LINE_ARGUMENT_A* arg = NULL; + const COMMAND_LINE_ARGUMENT_A* arg = nullptr; rdpSettings* settings = server->settings; if ((argc < 2) || !argv || !cargs) @@ -222,7 +222,7 @@ int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** a CommandLineClearArgumentsA(cargs); flags = COMMAND_LINE_SEPARATOR_COLON; flags |= COMMAND_LINE_SIGIL_SLASH | COMMAND_LINE_SIGIL_PLUS_MINUS; - status = CommandLineParseArgumentsA(argc, argv, cargs, flags, server, NULL, NULL); + status = CommandLineParseArgumentsA(argc, argv, cargs, flags, server, nullptr, nullptr); if (status < 0) return status; @@ -237,7 +237,7 @@ int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** a CommandLineSwitchStart(arg) CommandLineSwitchCase(arg, "port") { - long val = strtol(arg->Value, NULL, 0); + long val = strtol(arg->Value, nullptr, 0); if ((errno != 0) || (val <= 0) || (val > UINT16_MAX)) return fail_at(arg, COMMAND_LINE_ERROR); @@ -272,23 +272,23 @@ int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** a } CommandLineSwitchCase(arg, "may-view") { - server->mayView = arg->Value != NULL; + server->mayView = arg->Value != nullptr; } CommandLineSwitchCase(arg, "bitmap-compat") { - server->SupportMultiRectBitmapUpdates = arg->Value == NULL; + server->SupportMultiRectBitmapUpdates = arg->Value == nullptr; } CommandLineSwitchCase(arg, "may-interact") { - server->mayInteract = arg->Value != NULL; + server->mayInteract = arg->Value != nullptr; } CommandLineSwitchCase(arg, "server-side-cursor") { - server->ShowMouseCursor = arg->Value != NULL; + server->ShowMouseCursor = arg->Value != nullptr; } CommandLineSwitchCase(arg, "mouse-relative") { - const BOOL val = arg->Value != NULL; + const BOOL val = arg->Value != nullptr; if (!freerdp_settings_set_bool(settings, FreeRDP_MouseUseRelativeMove, val) || !freerdp_settings_set_bool(settings, FreeRDP_HasRelativeMouseEvent, val)) return fail_at(arg, COMMAND_LINE_ERROR); @@ -296,7 +296,7 @@ int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** a CommandLineSwitchCase(arg, "max-connections") { errno = 0; - unsigned long val = strtoul(arg->Value, NULL, 0); + unsigned long val = strtoul(arg->Value, nullptr, 0); if ((errno != 0) || (val > UINT32_MAX)) return fail_at(arg, COMMAND_LINE_ERROR); @@ -304,7 +304,7 @@ int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** a } CommandLineSwitchCase(arg, "rect") { - char* p = NULL; + char* p = nullptr; char* tok[4]; long x = -1; long y = -1; @@ -346,22 +346,22 @@ int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** a *p++ = '\0'; tok[3] = p; - x = strtol(tok[0], NULL, 0); + x = strtol(tok[0], nullptr, 0); if (errno != 0) goto fail; - y = strtol(tok[1], NULL, 0); + y = strtol(tok[1], nullptr, 0); if (errno != 0) goto fail; - w = strtol(tok[2], NULL, 0); + w = strtol(tok[2], nullptr, 0); if (errno != 0) goto fail; - h = strtol(tok[3], NULL, 0); + h = strtol(tok[3], nullptr, 0); if (errno != 0) goto fail; @@ -383,23 +383,23 @@ int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** a } CommandLineSwitchCase(arg, "auth") { - server->authentication = arg->Value != NULL; + server->authentication = arg->Value != nullptr; } CommandLineSwitchCase(arg, "remote-guard") { if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteCredentialGuard, - arg->Value != NULL)) + arg->Value != nullptr)) return fail_at(arg, COMMAND_LINE_ERROR); } CommandLineSwitchCase(arg, "restricted-admin") { if (!freerdp_settings_set_bool(settings, FreeRDP_RestrictedAdminModeSupported, - arg->Value != NULL)) + arg->Value != nullptr)) return fail_at(arg, COMMAND_LINE_ERROR); } CommandLineSwitchCase(arg, "vmconnect") { - if (!freerdp_settings_set_bool(settings, FreeRDP_VmConnectMode, arg->Value != NULL)) + if (!freerdp_settings_set_bool(settings, FreeRDP_VmConnectMode, arg->Value != nullptr)) return fail_at(arg, COMMAND_LINE_ERROR); } CommandLineSwitchCase(arg, "sec") @@ -458,22 +458,22 @@ int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** a } CommandLineSwitchCase(arg, "sec-rdp") { - if (!freerdp_settings_set_bool(settings, FreeRDP_RdpSecurity, arg->Value != NULL)) + if (!freerdp_settings_set_bool(settings, FreeRDP_RdpSecurity, arg->Value != nullptr)) return fail_at(arg, COMMAND_LINE_ERROR); } CommandLineSwitchCase(arg, "sec-tls") { - if (!freerdp_settings_set_bool(settings, FreeRDP_TlsSecurity, arg->Value != NULL)) + if (!freerdp_settings_set_bool(settings, FreeRDP_TlsSecurity, arg->Value != nullptr)) return fail_at(arg, COMMAND_LINE_ERROR); } CommandLineSwitchCase(arg, "sec-nla") { - if (!freerdp_settings_set_bool(settings, FreeRDP_NlaSecurity, arg->Value != NULL)) + if (!freerdp_settings_set_bool(settings, FreeRDP_NlaSecurity, arg->Value != nullptr)) return fail_at(arg, COMMAND_LINE_ERROR); } CommandLineSwitchCase(arg, "sec-ext") { - if (!freerdp_settings_set_bool(settings, FreeRDP_ExtSecurity, arg->Value != NULL)) + if (!freerdp_settings_set_bool(settings, FreeRDP_ExtSecurity, arg->Value != nullptr)) return fail_at(arg, COMMAND_LINE_ERROR); } CommandLineSwitchCase(arg, "sam-file") @@ -495,45 +495,45 @@ int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** a } CommandLineSwitchCase(arg, "nsc") { - if (!freerdp_settings_set_bool(settings, FreeRDP_NSCodec, arg->Value != NULL)) + if (!freerdp_settings_set_bool(settings, FreeRDP_NSCodec, arg->Value != nullptr)) return fail_at(arg, COMMAND_LINE_ERROR); } CommandLineSwitchCase(arg, "rfx") { - if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteFxCodec, arg->Value != NULL)) + if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteFxCodec, arg->Value != nullptr)) return fail_at(arg, COMMAND_LINE_ERROR); } CommandLineSwitchCase(arg, "gfx") { if (!freerdp_settings_set_bool(settings, FreeRDP_SupportGraphicsPipeline, - arg->Value != NULL)) + arg->Value != nullptr)) return fail_at(arg, COMMAND_LINE_ERROR); } CommandLineSwitchCase(arg, "gfx-progressive") { - if (!freerdp_settings_set_bool(settings, FreeRDP_GfxProgressive, arg->Value != NULL)) + if (!freerdp_settings_set_bool(settings, FreeRDP_GfxProgressive, arg->Value != nullptr)) return fail_at(arg, COMMAND_LINE_ERROR); } CommandLineSwitchCase(arg, "gfx-rfx") { - if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteFxCodec, arg->Value != NULL)) + if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteFxCodec, arg->Value != nullptr)) return fail_at(arg, COMMAND_LINE_ERROR); } CommandLineSwitchCase(arg, "gfx-planar") { - if (!freerdp_settings_set_bool(settings, FreeRDP_GfxPlanar, arg->Value != NULL)) + if (!freerdp_settings_set_bool(settings, FreeRDP_GfxPlanar, arg->Value != nullptr)) return fail_at(arg, COMMAND_LINE_ERROR); } CommandLineSwitchCase(arg, "gfx-avc420") { - if (!freerdp_settings_set_bool(settings, FreeRDP_GfxH264, arg->Value != NULL)) + if (!freerdp_settings_set_bool(settings, FreeRDP_GfxH264, arg->Value != nullptr)) return fail_at(arg, COMMAND_LINE_ERROR); } CommandLineSwitchCase(arg, "gfx-avc444") { - if (!freerdp_settings_set_bool(settings, FreeRDP_GfxAVC444v2, arg->Value != NULL)) + if (!freerdp_settings_set_bool(settings, FreeRDP_GfxAVC444v2, arg->Value != nullptr)) return fail_at(arg, COMMAND_LINE_ERROR); - if (!freerdp_settings_set_bool(settings, FreeRDP_GfxAVC444, arg->Value != NULL)) + if (!freerdp_settings_set_bool(settings, FreeRDP_GfxAVC444, arg->Value != nullptr)) return fail_at(arg, COMMAND_LINE_ERROR); } CommandLineSwitchCase(arg, "keytab") @@ -555,7 +555,7 @@ int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** a { } CommandLineSwitchEnd(arg) - } while ((arg = CommandLineFindNextArgumentA(arg)) != NULL); + } while ((arg = CommandLineFindNextArgumentA(arg)) != nullptr); arg = CommandLineFindArgumentA(cargs, "monitors"); @@ -568,7 +568,7 @@ int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** a if (arg->Flags & COMMAND_LINE_VALUE_PRESENT) { /* Select monitors */ - long val = strtol(arg->Value, NULL, 0); + long val = strtol(arg->Value, nullptr, 0); if ((val < 0) || (errno != 0) || ((UINT32)val >= numMonitors)) status = COMMAND_LINE_STATUS_PRINT; @@ -751,12 +751,12 @@ int shadow_server_start(rdpShadowServer* server) { size_t count = 0; - char** ptr = CommandLineParseCommaSeparatedValuesEx(NULL, server->ipcSocket, &count); + char** ptr = CommandLineParseCommaSeparatedValuesEx(nullptr, server->ipcSocket, &count); if (!ptr || (count <= 1)) { - if (server->ipcSocket == NULL) + if (server->ipcSocket == nullptr) { - if (!open_port(server, NULL)) + if (!open_port(server, nullptr)) { CommandLineParserFree(ptr); return -1; @@ -793,7 +793,8 @@ int shadow_server_start(rdpShadowServer* server) } } - if (!(server->thread = CreateThread(NULL, 0, shadow_server_thread, (void*)server, 0, NULL))) + if (!(server->thread = + CreateThread(nullptr, 0, shadow_server_thread, (void*)server, 0, nullptr))) { return -1; } @@ -811,7 +812,7 @@ int shadow_server_stop(rdpShadowServer* server) (void)SetEvent(server->StopEvent); (void)WaitForSingleObject(server->thread, INFINITE); (void)CloseHandle(server->thread); - server->thread = NULL; + server->thread = nullptr; if (server->listener && server->listener->Close) server->listener->Close(server->listener); } @@ -819,13 +820,13 @@ int shadow_server_stop(rdpShadowServer* server) if (server->screen) { shadow_screen_free(server->screen); - server->screen = NULL; + server->screen = nullptr; } if (server->capture) { shadow_capture_free(server->capture); - server->capture = NULL; + server->capture = nullptr; } return 0; @@ -840,7 +841,7 @@ static int shadow_server_init_config_path(rdpShadowServer* server) if (configHome) { - if (!winpr_PathFileExists(configHome) && !winpr_PathMakePath(configHome, 0)) + if (!winpr_PathFileExists(configHome) && !winpr_PathMakePath(configHome, nullptr)) { WLog_ERR(TAG, "Failed to create directory '%s'", configHome); free(configHome); @@ -899,12 +900,13 @@ out_fail: WINPR_ATTR_NODISCARD static BOOL shadow_server_init_certificate(rdpShadowServer* server) { - char* filepath = NULL; + char* filepath = nullptr; BOOL ret = FALSE; WINPR_ASSERT(server); - if (!winpr_PathFileExists(server->ConfigPath) && !winpr_PathMakePath(server->ConfigPath, 0)) + if (!winpr_PathFileExists(server->ConfigPath) && + !winpr_PathMakePath(server->ConfigPath, nullptr)) { WLog_ERR(TAG, "Failed to create directory '%s'", server->ConfigPath); return FALSE; @@ -913,9 +915,9 @@ static BOOL shadow_server_init_certificate(rdpShadowServer* server) if (!(filepath = GetCombinedPath(server->ConfigPath, "shadow"))) return FALSE; - if (!winpr_PathFileExists(filepath) && !winpr_PathMakePath(filepath, 0)) + if (!winpr_PathFileExists(filepath) && !winpr_PathMakePath(filepath, nullptr)) { - if (!winpr_PathMakePath(filepath, NULL)) + if (!winpr_PathMakePath(filepath, nullptr)) { WLog_ERR(TAG, "Failed to create directory '%s'", filepath); goto out_fail; @@ -940,7 +942,7 @@ static BOOL shadow_server_init_certificate(rdpShadowServer* server) WINPR_ASSERT(settings); { - rdpPrivateKey* key = freerdp_key_new_from_file_enc(server->PrivateKeyFile, NULL); + rdpPrivateKey* key = freerdp_key_new_from_file_enc(server->PrivateKeyFile, nullptr); if (!key) goto out_fail; if (!freerdp_settings_set_pointer_len(settings, FreeRDP_RdpServerRsaKey, key, 1)) @@ -1002,7 +1004,7 @@ int shadow_server_init(rdpShadowServer* server) if (!(server->clients = ArrayList_New(TRUE))) goto fail; - if (!(server->StopEvent = CreateEvent(NULL, TRUE, FALSE, NULL))) + if (!(server->StopEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr))) goto fail; if (!InitializeCriticalSectionAndSpinCount(&(server->lock), 4000)) @@ -1049,30 +1051,30 @@ int shadow_server_uninit(rdpShadowServer* server) shadow_server_stop(server); shadow_subsystem_uninit(server->subsystem); shadow_subsystem_free(server->subsystem); - server->subsystem = NULL; + server->subsystem = nullptr; freerdp_listener_free(server->listener); - server->listener = NULL; + server->listener = nullptr; free(server->CertificateFile); - server->CertificateFile = NULL; + server->CertificateFile = nullptr; free(server->PrivateKeyFile); - server->PrivateKeyFile = NULL; + server->PrivateKeyFile = nullptr; free(server->ConfigPath); - server->ConfigPath = NULL; + server->ConfigPath = nullptr; DeleteCriticalSection(&(server->lock)); (void)CloseHandle(server->StopEvent); - server->StopEvent = NULL; + server->StopEvent = nullptr; ArrayList_Free(server->clients); - server->clients = NULL; + server->clients = nullptr; return 1; } rdpShadowServer* shadow_server_new(void) { - rdpShadowServer* server = NULL; + rdpShadowServer* server = nullptr; server = (rdpShadowServer*)calloc(1, sizeof(rdpShadowServer)); if (!server) - return NULL; + return nullptr; server->SupportMultiRectBitmapUpdates = TRUE; server->port = 3389; @@ -1093,8 +1095,8 @@ void shadow_server_free(rdpShadowServer* server) return; free(server->ipcSocket); - server->ipcSocket = NULL; + server->ipcSocket = nullptr; freerdp_settings_free(server->settings); - server->settings = NULL; + server->settings = nullptr; free(server); } diff --git a/server/shadow/shadow_subsystem.c b/server/shadow/shadow_subsystem.c index d756c56f2..fde21807c 100644 --- a/server/shadow/shadow_subsystem.c +++ b/server/shadow/shadow_subsystem.c @@ -22,7 +22,7 @@ #include "shadow_subsystem.h" -static pfnShadowSubsystemEntry pSubsystemEntry = NULL; +static pfnShadowSubsystemEntry pSubsystemEntry = nullptr; void shadow_subsystem_set_entry(pfnShadowSubsystemEntry pEntry) { @@ -49,15 +49,15 @@ rdpShadowSubsystem* shadow_subsystem_new(void) RDP_SHADOW_ENTRY_POINTS ep = WINPR_C_ARRAY_INIT; if (shadow_subsystem_load_entry_points(&ep) < 0) - return NULL; + return nullptr; if (!ep.New) - return NULL; + return nullptr; rdpShadowSubsystem* subsystem = ep.New(); if (!subsystem) - return NULL; + return nullptr; subsystem->ep = ep; @@ -94,13 +94,13 @@ fail: if (subsystem->MsgPipe) { MessagePipe_Free(subsystem->MsgPipe); - subsystem->MsgPipe = NULL; + subsystem->MsgPipe = nullptr; } if (subsystem->updateEvent) { shadow_multiclient_free(subsystem->updateEvent); - subsystem->updateEvent = NULL; + subsystem->updateEvent = nullptr; } return status; @@ -112,7 +112,7 @@ static void shadow_subsystem_free_queued_message(void* obj) if (message->Free) { message->Free(message); - message->Free = NULL; + message->Free = nullptr; } } @@ -126,8 +126,8 @@ void shadow_subsystem_uninit(rdpShadowSubsystem* subsystem) if (subsystem->MsgPipe) { - wObject* obj1 = NULL; - wObject* obj2 = NULL; + wObject* obj1 = nullptr; + wObject* obj2 = nullptr; /* Release resource in messages before free */ obj1 = MessageQueue_Object(subsystem->MsgPipe->In); @@ -138,13 +138,13 @@ void shadow_subsystem_uninit(rdpShadowSubsystem* subsystem) obj2->fnObjectFree = shadow_subsystem_free_queued_message; MessageQueue_Clear(subsystem->MsgPipe->Out); MessagePipe_Free(subsystem->MsgPipe); - subsystem->MsgPipe = NULL; + subsystem->MsgPipe = nullptr; } if (subsystem->updateEvent) { shadow_multiclient_free(subsystem->updateEvent); - subsystem->updateEvent = NULL; + subsystem->updateEvent = nullptr; } } @@ -208,7 +208,7 @@ int shadow_subsystem_pointer_convert_alpha_pointer_data_to_format( UINT32 xorStep = 0; UINT32 andStep = 0; UINT32 andBit = 0; - BYTE* andBits = NULL; + BYTE* andBits = nullptr; UINT32 andPixel = 0; const size_t bpp = FreeRDPGetBytesPerPixel(format); @@ -230,7 +230,7 @@ int shadow_subsystem_pointer_convert_alpha_pointer_data_to_format( if (!pointerColor->andMaskData) { free(pointerColor->xorMaskData); - pointerColor->xorMaskData = NULL; + pointerColor->xorMaskData = nullptr; return -1; } @@ -250,7 +250,7 @@ int shadow_subsystem_pointer_convert_alpha_pointer_data_to_format( BYTE A = 0; const UINT32 color = FreeRDPReadColor(&pSrc8[x * bpp], format); - FreeRDPSplitColor(color, format, &R, &G, &B, &A, NULL); + FreeRDPSplitColor(color, format, &R, &G, &B, &A, nullptr); andPixel = 0; diff --git a/server/shadow/shadow_subsystem_builtin.c b/server/shadow/shadow_subsystem_builtin.c index 3fbabdc70..5f91c9133 100644 --- a/server/shadow/shadow_subsystem_builtin.c +++ b/server/shadow/shadow_subsystem_builtin.c @@ -49,7 +49,7 @@ static pfnShadowSubsystemEntry shadow_subsystem_load_static_entry(const char* na return cur->entry; } - return NULL; + return nullptr; } for (size_t index = 0; index < g_SubsystemCount; index++) @@ -62,7 +62,7 @@ static pfnShadowSubsystemEntry shadow_subsystem_load_static_entry(const char* na return cur->entry; } - return NULL; + return nullptr; } void shadow_subsystem_set_entry_builtin(const char* name) diff --git a/server/shadow/shadow_surface.c b/server/shadow/shadow_surface.c index 16aeccef1..190cac787 100644 --- a/server/shadow/shadow_surface.c +++ b/server/shadow/shadow_surface.c @@ -27,11 +27,11 @@ rdpShadowSurface* shadow_surface_new(rdpShadowServer* server, UINT16 x, UINT16 y, UINT32 width, UINT32 height) { - rdpShadowSurface* surface = NULL; + rdpShadowSurface* surface = nullptr; surface = (rdpShadowSurface*)calloc(1, sizeof(rdpShadowSurface)); if (!surface) - return NULL; + return nullptr; surface->server = server; surface->x = x; @@ -45,14 +45,14 @@ rdpShadowSurface* shadow_surface_new(rdpShadowServer* server, UINT16 x, UINT16 y if (!surface->data) { free(surface); - return NULL; + return nullptr; } if (!InitializeCriticalSectionAndSpinCount(&(surface->lock), 4000)) { free(surface->data); free(surface); - return NULL; + return nullptr; } region16_init(&(surface->invalidRegion)); @@ -73,7 +73,7 @@ void shadow_surface_free(rdpShadowSurface* surface) BOOL shadow_surface_resize(rdpShadowSurface* surface, UINT16 x, UINT16 y, UINT32 width, UINT32 height) { - BYTE* buffer = NULL; + BYTE* buffer = nullptr; UINT32 scanline = ALIGN_SCREEN_SIZE(width, 4) * 4; if (!surface)