From 7d67b8e2042ac78ab72e758c5d5917c80b006576 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Mon, 16 Sep 2024 04:50:45 +0200 Subject: [PATCH 01/13] [return checks] fix use of SetEvent --- channels/ainput/server/ainput_main.c | 2 +- channels/audin/client/alsa/audin_alsa.c | 2 +- channels/audin/client/oss/audin_oss.c | 2 +- channels/audin/client/sndio/audin_sndio.c | 2 +- channels/audin/client/winmm/audin_winmm.c | 2 +- channels/audin/server/audin.c | 2 +- channels/cliprdr/server/cliprdr_main.c | 2 +- channels/disp/server/disp_main.c | 2 +- channels/drdynvc/server/drdynvc_main.c | 2 +- channels/echo/server/echo_main.c | 2 +- channels/encomsp/server/encomsp_main.c | 2 +- channels/gfxredir/server/gfxredir_main.c | 2 +- channels/location/server/location_main.c | 2 +- channels/printer/client/printer_main.c | 4 ++-- channels/rail/server/rail_main.c | 2 +- channels/rdp2tcp/client/rdp2tcp_main.c | 2 +- channels/rdpdr/client/rdpdr_main.c | 2 +- channels/rdpdr/server/rdpdr_main.c | 2 +- .../rdpecam/server/camera_device_enumerator_main.c | 2 +- channels/rdpecam/server/camera_device_main.c | 2 +- channels/rdpei/client/rdpei_main.c | 6 +++--- channels/rdpemsc/server/mouse_cursor_main.c | 2 +- channels/rdpgfx/server/rdpgfx_main.c | 2 +- channels/rdpsnd/server/rdpsnd_main.c | 2 +- channels/remdesk/server/remdesk_main.c | 2 +- channels/telemetry/server/telemetry_main.c | 2 +- channels/tsmf/client/tsmf_media.c | 8 ++++---- .../Studio/freeRDPCore/src/main/cpp/android_cliprdr.c | 4 ++-- client/Mac/Clipboard.m | 6 +++--- client/SDL/SDL2/sdl_utils.cpp | 2 +- client/SDL/SDL3/sdl_clip.cpp | 2 +- client/SDL/SDL3/sdl_utils.cpp | 2 +- client/common/client_cliprdr_file.c | 6 +++--- client/iOS/FreeRDP/ios_cliprdr.m | 4 ++-- libfreerdp/core/freerdp.c | 2 +- libfreerdp/core/gateway/rpc_client.c | 2 +- libfreerdp/core/transport.c | 2 +- server/Sample/sfreerdp.c | 2 +- server/Windows/wf_peer.c | 2 +- server/Windows/wf_update.c | 3 ++- server/proxy/pf_context.c | 2 +- server/proxy/pf_server.c | 4 ++-- server/shadow/Win/win_rdp.c | 4 ++-- server/shadow/Win/win_shadow.c | 2 +- server/shadow/shadow_mcevent.c | 10 +++++----- server/shadow/shadow_server.c | 2 +- winpr/libwinpr/pipe/pipe.c | 6 +++--- winpr/libwinpr/pipe/test/TestPipeCreateNamedPipe.c | 2 +- .../pipe/test/TestPipeCreateNamedPipeOverlapped.c | 6 +++--- winpr/libwinpr/pool/pool.c | 4 ++-- winpr/libwinpr/synch/barrier.c | 2 +- winpr/libwinpr/synch/test/TestSynchInit.c | 2 +- winpr/libwinpr/synch/test/TestSynchMutex.c | 2 +- winpr/libwinpr/synch/test/TestSynchTimerQueue.c | 2 +- winpr/libwinpr/synch/test/TestSynchWaitableTimerAPC.c | 2 +- winpr/libwinpr/synch/timer.c | 4 ++-- winpr/libwinpr/utils/collections/CountdownEvent.c | 2 +- winpr/libwinpr/utils/collections/MessageQueue.c | 2 +- winpr/libwinpr/utils/collections/Queue.c | 2 +- winpr/libwinpr/wtsapi/wtsapi_win32.c | 2 +- 60 files changed, 85 insertions(+), 84 deletions(-) diff --git a/channels/ainput/server/ainput_main.c b/channels/ainput/server/ainput_main.c index 81a9b5113..7cbbdb29e 100644 --- a/channels/ainput/server/ainput_main.c +++ b/channels/ainput/server/ainput_main.c @@ -351,7 +351,7 @@ static UINT ainput_server_close(ainput_server_context* context) if (!ainput->externalThread && ainput->thread) { - SetEvent(ainput->stopEvent); + (void)SetEvent(ainput->stopEvent); if (WaitForSingleObject(ainput->thread, INFINITE) == WAIT_FAILED) { diff --git a/channels/audin/client/alsa/audin_alsa.c b/channels/audin/client/alsa/audin_alsa.c index adf3ddbc8..e82662451 100644 --- a/channels/audin/client/alsa/audin_alsa.c +++ b/channels/audin/client/alsa/audin_alsa.c @@ -322,7 +322,7 @@ static UINT audin_alsa_close(IAudinDevice* device) if (alsa->stopEvent) { - SetEvent(alsa->stopEvent); + (void)SetEvent(alsa->stopEvent); if (WaitForSingleObject(alsa->thread, INFINITE) == WAIT_FAILED) { diff --git a/channels/audin/client/oss/audin_oss.c b/channels/audin/client/oss/audin_oss.c index ca14dd593..b9db46a88 100644 --- a/channels/audin/client/oss/audin_oss.c +++ b/channels/audin/client/oss/audin_oss.c @@ -332,7 +332,7 @@ static UINT audin_oss_close(IAudinDevice* device) if (oss->stopEvent != NULL) { - SetEvent(oss->stopEvent); + (void)SetEvent(oss->stopEvent); if (WaitForSingleObject(oss->thread, INFINITE) == WAIT_FAILED) { diff --git a/channels/audin/client/sndio/audin_sndio.c b/channels/audin/client/sndio/audin_sndio.c index f7c6a8a39..291b16d20 100644 --- a/channels/audin/client/sndio/audin_sndio.c +++ b/channels/audin/client/sndio/audin_sndio.c @@ -227,7 +227,7 @@ static UINT audin_sndio_close(IAudinDevice* device) if (sndio->stopEvent != NULL) { - SetEvent(sndio->stopEvent); + (void)SetEvent(sndio->stopEvent); if (WaitForSingleObject(sndio->thread, INFINITE) == WAIT_FAILED) { diff --git a/channels/audin/client/winmm/audin_winmm.c b/channels/audin/client/winmm/audin_winmm.c index aefef8433..c94e41a34 100644 --- a/channels/audin/client/winmm/audin_winmm.c +++ b/channels/audin/client/winmm/audin_winmm.c @@ -293,7 +293,7 @@ static UINT audin_winmm_close(IAudinDevice* device) if (!winmm) return ERROR_INVALID_PARAMETER; - SetEvent(winmm->stopEvent); + (void)SetEvent(winmm->stopEvent); status = WaitForSingleObject(winmm->thread, INFINITE); if (status == WAIT_FAILED) diff --git a/channels/audin/server/audin.c b/channels/audin/server/audin.c index ac1e53626..a898fff1c 100644 --- a/channels/audin/server/audin.c +++ b/channels/audin/server/audin.c @@ -516,7 +516,7 @@ static BOOL audin_server_close(audin_server_context* context) if (audin->thread) { - SetEvent(audin->stopEvent); + (void)SetEvent(audin->stopEvent); if (WaitForSingleObject(audin->thread, INFINITE) == WAIT_FAILED) { diff --git a/channels/cliprdr/server/cliprdr_main.c b/channels/cliprdr/server/cliprdr_main.c index c8f961d52..a14b5a45f 100644 --- a/channels/cliprdr/server/cliprdr_main.c +++ b/channels/cliprdr/server/cliprdr_main.c @@ -1420,7 +1420,7 @@ static UINT cliprdr_server_stop(CliprdrServerContext* context) if (cliprdr->StopEvent) { - SetEvent(cliprdr->StopEvent); + (void)SetEvent(cliprdr->StopEvent); if (WaitForSingleObject(cliprdr->Thread, INFINITE) == WAIT_FAILED) { diff --git a/channels/disp/server/disp_main.c b/channels/disp/server/disp_main.c index b7bbde684..49920e682 100644 --- a/channels/disp/server/disp_main.c +++ b/channels/disp/server/disp_main.c @@ -550,7 +550,7 @@ static UINT disp_server_close(DispServerContext* context) if (priv->thread) { - SetEvent(priv->stopEvent); + (void)SetEvent(priv->stopEvent); if (WaitForSingleObject(priv->thread, INFINITE) == WAIT_FAILED) { diff --git a/channels/drdynvc/server/drdynvc_main.c b/channels/drdynvc/server/drdynvc_main.c index d8cbf2462..e6c951549 100644 --- a/channels/drdynvc/server/drdynvc_main.c +++ b/channels/drdynvc/server/drdynvc_main.c @@ -154,7 +154,7 @@ static UINT drdynvc_server_start(DrdynvcServerContext* context) static UINT drdynvc_server_stop(DrdynvcServerContext* context) { UINT error = 0; - SetEvent(context->priv->StopEvent); + (void)SetEvent(context->priv->StopEvent); if (WaitForSingleObject(context->priv->Thread, INFINITE) == WAIT_FAILED) { diff --git a/channels/echo/server/echo_main.c b/channels/echo/server/echo_main.c index c31c55eae..1eb416cda 100644 --- a/channels/echo/server/echo_main.c +++ b/channels/echo/server/echo_main.c @@ -328,7 +328,7 @@ static UINT echo_server_close(echo_server_context* context) if (echo->thread) { - SetEvent(echo->stopEvent); + (void)SetEvent(echo->stopEvent); if (WaitForSingleObject(echo->thread, INFINITE) == WAIT_FAILED) { diff --git a/channels/encomsp/server/encomsp_main.c b/channels/encomsp/server/encomsp_main.c index a7bf075b4..009e2d9e0 100644 --- a/channels/encomsp/server/encomsp_main.c +++ b/channels/encomsp/server/encomsp_main.c @@ -327,7 +327,7 @@ static UINT encomsp_server_start(EncomspServerContext* context) static UINT encomsp_server_stop(EncomspServerContext* context) { UINT error = CHANNEL_RC_OK; - SetEvent(context->priv->StopEvent); + (void)SetEvent(context->priv->StopEvent); if (WaitForSingleObject(context->priv->Thread, INFINITE) == WAIT_FAILED) { diff --git a/channels/gfxredir/server/gfxredir_main.c b/channels/gfxredir/server/gfxredir_main.c index f661a9c12..3b398a167 100644 --- a/channels/gfxredir/server/gfxredir_main.c +++ b/channels/gfxredir/server/gfxredir_main.c @@ -705,7 +705,7 @@ static UINT gfxredir_server_close(GfxRedirServerContext* context) if (priv->thread) { - SetEvent(priv->stopEvent); + (void)SetEvent(priv->stopEvent); if (WaitForSingleObject(priv->thread, INFINITE) == WAIT_FAILED) { diff --git a/channels/location/server/location_main.c b/channels/location/server/location_main.c index 549cfc019..3f2e06d26 100644 --- a/channels/location/server/location_main.c +++ b/channels/location/server/location_main.c @@ -475,7 +475,7 @@ static UINT location_server_close(LocationServerContext* context) if (!location->externalThread && location->thread) { - SetEvent(location->stopEvent); + (void)SetEvent(location->stopEvent); if (WaitForSingleObject(location->thread, INFINITE) == WAIT_FAILED) { diff --git a/channels/printer/client/printer_main.c b/channels/printer/client/printer_main.c index f53a085b4..ec32a3176 100644 --- a/channels/printer/client/printer_main.c +++ b/channels/printer/client/printer_main.c @@ -690,7 +690,7 @@ static UINT printer_irp_request(DEVICE* device, IRP* irp) if (printer_dev->async) { InterlockedPushEntrySList(printer_dev->pIrpList, &(irp->ItemEntry)); - SetEvent(printer_dev->event); + (void)SetEvent(printer_dev->event); } else { @@ -908,7 +908,7 @@ static UINT printer_free(DEVICE* device) if (printer_dev->async) { - SetEvent(printer_dev->stopEvent); + (void)SetEvent(printer_dev->stopEvent); if (WaitForSingleObject(printer_dev->thread, INFINITE) == WAIT_FAILED) { diff --git a/channels/rail/server/rail_main.c b/channels/rail/server/rail_main.c index bc569bba7..fb76e5f44 100644 --- a/channels/rail/server/rail_main.c +++ b/channels/rail/server/rail_main.c @@ -1473,7 +1473,7 @@ static BOOL rail_server_stop(RailServerContext* context) if (priv->thread) { - SetEvent(priv->stopEvent); + (void)SetEvent(priv->stopEvent); if (WaitForSingleObject(priv->thread, INFINITE) == WAIT_FAILED) { diff --git a/channels/rdp2tcp/client/rdp2tcp_main.c b/channels/rdp2tcp/client/rdp2tcp_main.c index ae2314636..2a7e724ed 100644 --- a/channels/rdp2tcp/client/rdp2tcp_main.c +++ b/channels/rdp2tcp/client/rdp2tcp_main.c @@ -246,7 +246,7 @@ static void VCAPITYPE VirtualChannelOpenEventEx(LPVOID lpUserParam, DWORD openHa free(pData); break; case CHANNEL_EVENT_WRITE_COMPLETE: - SetEvent(plugin->writeComplete); + (void)SetEvent(plugin->writeComplete); free(pData); break; } diff --git a/channels/rdpdr/client/rdpdr_main.c b/channels/rdpdr/client/rdpdr_main.c index 8acfbf2de..dbfebc343 100644 --- a/channels/rdpdr/client/rdpdr_main.c +++ b/channels/rdpdr/client/rdpdr_main.c @@ -1109,7 +1109,7 @@ static UINT drive_hotplug_thread_terminate(rdpdrPlugin* rdpdr) { #if !defined(_WIN32) if (rdpdr->stopEvent) - SetEvent(rdpdr->stopEvent); + (void)SetEvent(rdpdr->stopEvent); #endif #ifdef __MACOSX__ CFRunLoopStop(rdpdr->runLoop); diff --git a/channels/rdpdr/server/rdpdr_main.c b/channels/rdpdr/server/rdpdr_main.c index 70c13fb1c..6d1c690ba 100644 --- a/channels/rdpdr/server/rdpdr_main.c +++ b/channels/rdpdr/server/rdpdr_main.c @@ -2168,7 +2168,7 @@ static UINT rdpdr_server_stop(RdpdrServerContext* context) if (context->priv->StopEvent) { - SetEvent(context->priv->StopEvent); + (void)SetEvent(context->priv->StopEvent); if (WaitForSingleObject(context->priv->Thread, INFINITE) == WAIT_FAILED) { diff --git a/channels/rdpecam/server/camera_device_enumerator_main.c b/channels/rdpecam/server/camera_device_enumerator_main.c index 195ec8454..89fb75782 100644 --- a/channels/rdpecam/server/camera_device_enumerator_main.c +++ b/channels/rdpecam/server/camera_device_enumerator_main.c @@ -468,7 +468,7 @@ static UINT enumerator_server_close(CamDevEnumServerContext* context) if (!enumerator->externalThread && enumerator->thread) { - SetEvent(enumerator->stopEvent); + (void)SetEvent(enumerator->stopEvent); if (WaitForSingleObject(enumerator->thread, INFINITE) == WAIT_FAILED) { diff --git a/channels/rdpecam/server/camera_device_main.c b/channels/rdpecam/server/camera_device_main.c index 0d3acdd2e..1b1915f97 100644 --- a/channels/rdpecam/server/camera_device_main.c +++ b/channels/rdpecam/server/camera_device_main.c @@ -620,7 +620,7 @@ static UINT device_server_close(CameraDeviceServerContext* context) if (!device->externalThread && device->thread) { - SetEvent(device->stopEvent); + (void)SetEvent(device->stopEvent); if (WaitForSingleObject(device->thread, INFINITE) == WAIT_FAILED) { diff --git a/channels/rdpei/client/rdpei_main.c b/channels/rdpei/client/rdpei_main.c index 78ed5e7fd..c374ce64d 100644 --- a/channels/rdpei/client/rdpei_main.c +++ b/channels/rdpei/client/rdpei_main.c @@ -963,7 +963,7 @@ static UINT rdpei_add_contact(RdpeiClientContext* context, const RDPINPUT_CONTAC contactPoint = &rdpei->contactPoints[contact->contactId]; contactPoint->data = *contact; contactPoint->dirty = TRUE; - SetEvent(rdpei->event); + (void)SetEvent(rdpei->event); LeaveCriticalSection(&rdpei->lock); return CHANNEL_RC_OK; @@ -1175,7 +1175,7 @@ static UINT rdpei_add_pen(RdpeiClientContext* context, INT32 externalId, { contactPoint->data = *contact; contactPoint->dirty = TRUE; - SetEvent(rdpei->event); + (void)SetEvent(rdpei->event); } LeaveCriticalSection(&rdpei->lock); @@ -1442,7 +1442,7 @@ static void terminate_plugin_cb(GENERIC_DYNVC_PLUGIN* base) rdpei->running = FALSE; if (rdpei->event) - SetEvent(rdpei->event); + (void)SetEvent(rdpei->event); if (rdpei->thread) { diff --git a/channels/rdpemsc/server/mouse_cursor_main.c b/channels/rdpemsc/server/mouse_cursor_main.c index 1e5225dfb..8e8aa899a 100644 --- a/channels/rdpemsc/server/mouse_cursor_main.c +++ b/channels/rdpemsc/server/mouse_cursor_main.c @@ -425,7 +425,7 @@ static UINT mouse_cursor_server_close(MouseCursorServerContext* context) if (!mouse_cursor->externalThread && mouse_cursor->thread) { - SetEvent(mouse_cursor->stopEvent); + (void)SetEvent(mouse_cursor->stopEvent); if (WaitForSingleObject(mouse_cursor->thread, INFINITE) == WAIT_FAILED) { diff --git a/channels/rdpgfx/server/rdpgfx_main.c b/channels/rdpgfx/server/rdpgfx_main.c index 3b21d03cb..d9a92499b 100644 --- a/channels/rdpgfx/server/rdpgfx_main.c +++ b/channels/rdpgfx/server/rdpgfx_main.c @@ -1630,7 +1630,7 @@ BOOL rdpgfx_server_close(RdpgfxServerContext* context) if (priv->ownThread && priv->thread) { - SetEvent(priv->stopEvent); + (void)SetEvent(priv->stopEvent); if (WaitForSingleObject(priv->thread, INFINITE) == WAIT_FAILED) { diff --git a/channels/rdpsnd/server/rdpsnd_main.c b/channels/rdpsnd/server/rdpsnd_main.c index 9d3e3e616..d7b498ddd 100644 --- a/channels/rdpsnd/server/rdpsnd_main.c +++ b/channels/rdpsnd/server/rdpsnd_main.c @@ -989,7 +989,7 @@ static UINT rdpsnd_server_stop(RdpsndServerContext* context) { if (context->priv->StopEvent) { - SetEvent(context->priv->StopEvent); + (void)SetEvent(context->priv->StopEvent); if (WaitForSingleObject(context->priv->Thread, INFINITE) == WAIT_FAILED) { diff --git a/channels/remdesk/server/remdesk_main.c b/channels/remdesk/server/remdesk_main.c index 90f7e97ec..a1b24b87a 100644 --- a/channels/remdesk/server/remdesk_main.c +++ b/channels/remdesk/server/remdesk_main.c @@ -685,7 +685,7 @@ static UINT remdesk_server_start(RemdeskServerContext* context) static UINT remdesk_server_stop(RemdeskServerContext* context) { UINT error = 0; - SetEvent(context->priv->StopEvent); + (void)SetEvent(context->priv->StopEvent); if (WaitForSingleObject(context->priv->Thread, INFINITE) == WAIT_FAILED) { diff --git a/channels/telemetry/server/telemetry_main.c b/channels/telemetry/server/telemetry_main.c index 329fd7b55..cf7a2d982 100644 --- a/channels/telemetry/server/telemetry_main.c +++ b/channels/telemetry/server/telemetry_main.c @@ -344,7 +344,7 @@ static UINT telemetry_server_close(TelemetryServerContext* context) if (!telemetry->externalThread && telemetry->thread) { - SetEvent(telemetry->stopEvent); + (void)SetEvent(telemetry->stopEvent); if (WaitForSingleObject(telemetry->thread, INFINITE) == WAIT_FAILED) { diff --git a/channels/tsmf/client/tsmf_media.c b/channels/tsmf/client/tsmf_media.c index 6b4afeaa5..63d409fe5 100644 --- a/channels/tsmf/client/tsmf_media.c +++ b/channels/tsmf/client/tsmf_media.c @@ -1261,13 +1261,13 @@ TSMF_STREAM* tsmf_stream_new(TSMF_PRESENTATION* presentation, UINT32 stream_id, stream->rdpcontext = rdpcontext; return stream; error_add: - SetEvent(stream->stopEvent); + (void)SetEvent(stream->stopEvent); if (WaitForSingleObject(stream->ack_thread, INFINITE) == WAIT_FAILED) WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", GetLastError()); error_ack_thread: - SetEvent(stream->stopEvent); + (void)SetEvent(stream->stopEvent); if (WaitForSingleObject(stream->play_thread, INFINITE) == WAIT_FAILED) WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", GetLastError()); @@ -1402,7 +1402,7 @@ void s_tsmf_stream_free(void* obj) return; tsmf_stream_stop(stream); - SetEvent(stream->stopEvent); + (void)SetEvent(stream->stopEvent); if (stream->play_thread) { @@ -1454,7 +1454,7 @@ BOOL tsmf_stream_push_sample(TSMF_STREAM* stream, IWTSVirtualChannelCallback* pC UINT32 extensions, UINT32 data_size, BYTE* data) { TSMF_SAMPLE* sample = NULL; - SetEvent(stream->ready); + (void)SetEvent(stream->ready); if (TERMINATING) return TRUE; diff --git a/client/Android/Studio/freeRDPCore/src/main/cpp/android_cliprdr.c b/client/Android/Studio/freeRDPCore/src/main/cpp/android_cliprdr.c index 9363431b9..0f777df67 100644 --- a/client/Android/Studio/freeRDPCore/src/main/cpp/android_cliprdr.c +++ b/client/Android/Studio/freeRDPCore/src/main/cpp/android_cliprdr.c @@ -397,7 +397,7 @@ android_cliprdr_server_format_data_response(CliprdrClientContext* cliprdr, if (!format) { - SetEvent(afc->clipboardRequestEvent); + (void)SetEvent(afc->clipboardRequestEvent); return ERROR_INTERNAL_ERROR; } @@ -411,7 +411,7 @@ android_cliprdr_server_format_data_response(CliprdrClientContext* cliprdr, if (!ClipboardSetData(afc->clipboard, formatId, formatDataResponse->requestedFormatData, size)) return ERROR_INTERNAL_ERROR; - SetEvent(afc->clipboardRequestEvent); + (void)SetEvent(afc->clipboardRequestEvent); if ((formatId == CF_TEXT) || (formatId == CF_UNICODETEXT)) { diff --git a/client/Mac/Clipboard.m b/client/Mac/Clipboard.m index c14d15cfc..dee7da518 100644 --- a/client/Mac/Clipboard.m +++ b/client/Mac/Clipboard.m @@ -330,7 +330,7 @@ mac_cliprdr_server_format_data_response(CliprdrClientContext *cliprdr, if (formatDataResponse->common.msgFlags & CB_RESPONSE_FAIL) { - SetEvent(mfc->clipboardRequestEvent); + (void)SetEvent(mfc->clipboardRequestEvent); return ERROR_INTERNAL_ERROR; } @@ -342,7 +342,7 @@ mac_cliprdr_server_format_data_response(CliprdrClientContext *cliprdr, if (!format) { - SetEvent(mfc->clipboardRequestEvent); + (void)SetEvent(mfc->clipboardRequestEvent); return ERROR_INTERNAL_ERROR; } @@ -355,7 +355,7 @@ mac_cliprdr_server_format_data_response(CliprdrClientContext *cliprdr, ClipboardSetData(mfc->clipboard, formatId, formatDataResponse->requestedFormatData, size); - SetEvent(mfc->clipboardRequestEvent); + (void)SetEvent(mfc->clipboardRequestEvent); if ((formatId == CF_TEXT) || (formatId == CF_OEMTEXT) || (formatId == CF_UNICODETEXT)) { diff --git a/client/SDL/SDL2/sdl_utils.cpp b/client/SDL/SDL2/sdl_utils.cpp index 65be03dc4..be8c363da 100644 --- a/client/SDL/SDL2/sdl_utils.cpp +++ b/client/SDL/SDL2/sdl_utils.cpp @@ -265,7 +265,7 @@ WinPREvent::~WinPREvent() void WinPREvent::set() { - SetEvent(_handle); + (void)SetEvent(_handle); } void WinPREvent::clear() diff --git a/client/SDL/SDL3/sdl_clip.cpp b/client/SDL/SDL3/sdl_clip.cpp index 5ee1f9150..a0f739a9e 100644 --- a/client/SDL/SDL3/sdl_clip.cpp +++ b/client/SDL/SDL3/sdl_clip.cpp @@ -638,7 +638,7 @@ UINT sdlClip::ReceiveFormatDataResponse(CliprdrClientContext* context, if (!sres) return ERROR_INTERNAL_ERROR; - SetEvent(clipboard->_event); + (void)SetEvent(clipboard->_event); return CHANNEL_RC_OK; } diff --git a/client/SDL/SDL3/sdl_utils.cpp b/client/SDL/SDL3/sdl_utils.cpp index 5aad402a7..f456b6258 100644 --- a/client/SDL/SDL3/sdl_utils.cpp +++ b/client/SDL/SDL3/sdl_utils.cpp @@ -311,7 +311,7 @@ WinPREvent::~WinPREvent() void WinPREvent::set() { - SetEvent(_handle); + (void)SetEvent(_handle); } void WinPREvent::clear() diff --git a/client/common/client_cliprdr_file.c b/client/common/client_cliprdr_file.c index 840694c25..84f3a292d 100644 --- a/client/common/client_cliprdr_file.c +++ b/client/common/client_cliprdr_file.c @@ -1144,7 +1144,7 @@ static DWORD WINAPI cliprdr_file_fuse_thread(LPVOID arg) fuse_opt_add_arg(&args, file->path); file->fuse_sess = fuse_session_new(&args, &cliprdr_file_fuse_oper, sizeof(cliprdr_file_fuse_oper), (void*)file); - SetEvent(file->fuse_start_sync); + (void)SetEvent(file->fuse_start_sync); if (file->fuse_sess != NULL) { @@ -2046,7 +2046,7 @@ void cliprdr_file_session_terminate(CliprdrFileContext* file, BOOL stop_thread) if (stop_thread) { WLog_Print(file->log, WLOG_DEBUG, "Setting FUSE stop event"); - SetEvent(file->fuse_stop_sync); + (void)SetEvent(file->fuse_stop_sync); } #endif /* not elegant but works for umounting FUSE @@ -2055,7 +2055,7 @@ void cliprdr_file_session_terminate(CliprdrFileContext* file, BOOL stop_thread) #if defined(WITH_FUSE) WLog_Print(file->log, WLOG_DEBUG, "Forcing FUSE to check exit flag"); #endif - winpr_PathFileExists(file->path); + (void)winpr_PathFileExists(file->path); } void cliprdr_file_context_free(CliprdrFileContext* file) diff --git a/client/iOS/FreeRDP/ios_cliprdr.m b/client/iOS/FreeRDP/ios_cliprdr.m index 5d666d3de..f79f4525c 100644 --- a/client/iOS/FreeRDP/ios_cliprdr.m +++ b/client/iOS/FreeRDP/ios_cliprdr.m @@ -391,7 +391,7 @@ ios_cliprdr_server_format_data_response(CliprdrClientContext *cliprdr, if (!format) { - SetEvent(afc->clipboardRequestEvent); + (void)SetEvent(afc->clipboardRequestEvent); return ERROR_INTERNAL_ERROR; } @@ -406,7 +406,7 @@ ios_cliprdr_server_format_data_response(CliprdrClientContext *cliprdr, if (!ClipboardSetData(afc->clipboard, formatId, formatDataResponse->requestedFormatData, size)) return ERROR_INTERNAL_ERROR; - SetEvent(afc->clipboardRequestEvent); + (void)SetEvent(afc->clipboardRequestEvent); if ((formatId == CF_TEXT) || (formatId == CF_UNICODETEXT)) { diff --git a/libfreerdp/core/freerdp.c b/libfreerdp/core/freerdp.c index e4b3a364a..18c58323e 100644 --- a/libfreerdp/core/freerdp.c +++ b/libfreerdp/core/freerdp.c @@ -1306,7 +1306,7 @@ void setChannelError(rdpContext* context, UINT errorNum, WINPR_FORMAT_ARG const context->channelErrorNum = errorNum; (void)vsnprintf(context->errorDescription, 499, format, ap); va_end(ap); - SetEvent(context->channelErrorEvent); + (void)SetEvent(context->channelErrorEvent); } const char* freerdp_nego_get_routing_token(rdpContext* context, DWORD* length) diff --git a/libfreerdp/core/gateway/rpc_client.c b/libfreerdp/core/gateway/rpc_client.c index 1ff2e1924..74ce882ec 100644 --- a/libfreerdp/core/gateway/rpc_client.c +++ b/libfreerdp/core/gateway/rpc_client.c @@ -137,7 +137,7 @@ static int rpc_client_receive_pipe_write(RpcClient* client, const BYTE* buffer, status += (int)length; if (ringbuffer_used(&(client->ReceivePipe)) > 0) - SetEvent(client->PipeEvent); + (void)SetEvent(client->PipeEvent); LeaveCriticalSection(&(client->PipeLock)); return status; diff --git a/libfreerdp/core/transport.c b/libfreerdp/core/transport.c index 120c369a3..e60b4ae6a 100644 --- a/libfreerdp/core/transport.c +++ b/libfreerdp/core/transport.c @@ -1462,7 +1462,7 @@ int transport_check_fds(rdpTransport* transport) if (!transport->haveMoreBytesToRead) { transport->haveMoreBytesToRead = TRUE; - SetEvent(transport->rereadEvent); + (void)SetEvent(transport->rereadEvent); } return recv_status; } diff --git a/server/Sample/sfreerdp.c b/server/Sample/sfreerdp.c index c873efcc5..b7d29c905 100644 --- a/server/Sample/sfreerdp.c +++ b/server/Sample/sfreerdp.c @@ -82,7 +82,7 @@ static void test_peer_context_free(freerdp_peer* client, rdpContext* ctx) if (context->debug_channel_thread) { WINPR_ASSERT(context->stopEvent); - SetEvent(context->stopEvent); + (void)SetEvent(context->stopEvent); WaitForSingleObject(context->debug_channel_thread, INFINITE); CloseHandle(context->debug_channel_thread); } diff --git a/server/Windows/wf_peer.c b/server/Windows/wf_peer.c index 4342a3b46..d213d23a1 100644 --- a/server/Windows/wf_peer.c +++ b/server/Windows/wf_peer.c @@ -217,7 +217,7 @@ static DWORD WINAPI wf_peer_socket_listener(LPVOID lpParam) break; } - SetEvent(context->socketEvent); + (void)SetEvent(context->socketEvent); WaitForSingleObject(context->socketSemaphore, INFINITE); if (context->socketClose) diff --git a/server/Windows/wf_update.c b/server/Windows/wf_update.c index 06d60c9b0..1a6b02d5b 100644 --- a/server/Windows/wf_update.c +++ b/server/Windows/wf_update.c @@ -70,7 +70,8 @@ DWORD WINAPI wf_update_thread(LPVOID lpParam) { // WLog_DBG(TAG, "Setting event for %d of %d", index + 1, // wfi->activePeerCount); - SetEvent(((wfPeerContext*)wfi->peers[index]->context)->updateEvent); + (void)SetEvent( + ((wfPeerContext*)wfi->peers[index]->context)->updateEvent); } } } diff --git a/server/proxy/pf_context.c b/server/proxy/pf_context.c index 0ee86a402..7b7e63416 100644 --- a/server/proxy/pf_context.c +++ b/server/proxy/pf_context.c @@ -409,7 +409,7 @@ void proxy_data_abort_connect(proxyData* pdata) { WINPR_ASSERT(pdata); WINPR_ASSERT(pdata->abort_event); - SetEvent(pdata->abort_event); + (void)SetEvent(pdata->abort_event); if (pdata->pc) freerdp_abort_connect_context(&pdata->pc->context); } diff --git a/server/proxy/pf_server.c b/server/proxy/pf_server.c index 1562bb123..6d34f0670 100644 --- a/server/proxy/pf_server.c +++ b/server/proxy/pf_server.c @@ -679,7 +679,7 @@ static DWORD WINAPI pf_server_handle_peer(LPVOID arg) case DRDYNVC_STATE_READY: if (WaitForSingleObject(ps->dynvcReady, 0) == WAIT_TIMEOUT) { - SetEvent(ps->dynvcReady); + (void)SetEvent(ps->dynvcReady); } break; @@ -1029,7 +1029,7 @@ void pf_server_stop(proxyServer* server) return; /* signal main thread to stop and wait for the thread to exit */ - SetEvent(server->stopEvent); + (void)SetEvent(server->stopEvent); } void pf_server_free(proxyServer* server) diff --git a/server/shadow/Win/win_rdp.c b/server/shadow/Win/win_rdp.c index 3db073da4..a28b9bf5b 100644 --- a/server/shadow/Win/win_rdp.c +++ b/server/shadow/Win/win_rdp.c @@ -79,7 +79,7 @@ static BOOL shw_end_paint(rdpContext* context) region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion), &invalidRect); } - SetEvent(subsystem->RdpUpdateEnterEvent); + (void)SetEvent(subsystem->RdpUpdateEnterEvent); WaitForSingleObject(subsystem->RdpUpdateLeaveEvent, INFINITE); ResetEvent(subsystem->RdpUpdateLeaveEvent); return TRUE; @@ -261,7 +261,7 @@ static int shw_freerdp_client_start(rdpContext* context) static int shw_freerdp_client_stop(rdpContext* context) { shwContext* shw = (shwContext*)context; - SetEvent(shw->StopEvent); + (void)SetEvent(shw->StopEvent); return 0; } diff --git a/server/shadow/Win/win_shadow.c b/server/shadow/Win/win_shadow.c index f05a55cf2..b55565b38 100644 --- a/server/shadow/Win/win_shadow.c +++ b/server/shadow/Win/win_shadow.c @@ -354,7 +354,7 @@ static DWORD WINAPI win_shadow_subsystem_thread(LPVOID arg) { win_shadow_surface_copy(subsystem); ResetEvent(subsystem->RdpUpdateEnterEvent); - SetEvent(subsystem->RdpUpdateLeaveEvent); + (void)SetEvent(subsystem->RdpUpdateLeaveEvent); } } diff --git a/server/shadow/shadow_mcevent.c b/server/shadow/shadow_mcevent.c index 5a4ad37c0..f94b66845 100644 --- a/server/shadow/shadow_mcevent.c +++ b/server/shadow/shadow_mcevent.c @@ -73,7 +73,7 @@ rdpShadowMultiClientEvent* shadow_multiclient_new(void) event->consuming = 0; event->waiting = 0; event->eventid = 0; - SetEvent(event->doneEvent); + (void)SetEvent(event->doneEvent); return event; out_free_subscribers: @@ -129,7 +129,7 @@ static void Publish(rdpShadowMultiClientEvent* event) event->eventid = (event->eventid & 0xff) + 1; WLog_VRB(TAG, "Server published event %d. %d clients.\n", event->eventid, event->consuming); ResetEvent(event->doneEvent); - SetEvent(event->event); + (void)SetEvent(event->event); } } @@ -200,12 +200,12 @@ static BOOL Consume(struct rdp_shadow_multiclient_subscriber* subscriber, BOOL w if (event->waiting > 0) { /* Notify other clients to continue */ - SetEvent(event->barrierEvent); + (void)SetEvent(event->barrierEvent); } else { /* Only one client. Notify server directly */ - SetEvent(event->doneEvent); + (void)SetEvent(event->doneEvent); } } else /* (event->consuming > 0) */ @@ -230,7 +230,7 @@ static BOOL Consume(struct rdp_shadow_multiclient_subscriber* subscriber, BOOL w * server to continue. */ ResetEvent(event->barrierEvent); - SetEvent(event->doneEvent); + (void)SetEvent(event->doneEvent); } } } diff --git a/server/shadow/shadow_server.c b/server/shadow/shadow_server.c index 28a690460..3962a8c70 100644 --- a/server/shadow/shadow_server.c +++ b/server/shadow/shadow_server.c @@ -742,7 +742,7 @@ int shadow_server_stop(rdpShadowServer* server) if (server->thread) { - SetEvent(server->StopEvent); + (void)SetEvent(server->StopEvent); WaitForSingleObject(server->thread, INFINITE); CloseHandle(server->thread); server->thread = NULL; diff --git a/winpr/libwinpr/pipe/pipe.c b/winpr/libwinpr/pipe/pipe.c index d95df5a3e..13522d935 100644 --- a/winpr/libwinpr/pipe/pipe.c +++ b/winpr/libwinpr/pipe/pipe.c @@ -331,7 +331,7 @@ BOOL NamedPipeRead(PVOID Object, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, lpOverlapped->Internal = 0; lpOverlapped->InternalHigh = (ULONG_PTR)nNumberOfBytesToRead; lpOverlapped->Pointer = (PVOID)lpBuffer; - SetEvent(lpOverlapped->hEvent); + (void)SetEvent(lpOverlapped->hEvent); #endif } @@ -426,7 +426,7 @@ BOOL NamedPipeWrite(PVOID Object, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, cnv.cpv = lpBuffer; lpOverlapped->Pointer = cnv.pv; } - SetEvent(lpOverlapped->hEvent); + (void)SetEvent(lpOverlapped->hEvent); #endif } @@ -781,7 +781,7 @@ BOOL ConnectNamedPipe(HANDLE hNamedPipe, LPOVERLAPPED lpOverlapped) lpOverlapped->Internal = 2; lpOverlapped->InternalHigh = (ULONG_PTR)0; lpOverlapped->Pointer = (PVOID)NULL; - SetEvent(lpOverlapped->hEvent); + (void)SetEvent(lpOverlapped->hEvent); } return TRUE; diff --git a/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipe.c b/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipe.c index c6c4abc03..b1849a8fd 100644 --- a/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipe.c +++ b/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipe.c @@ -120,7 +120,7 @@ static DWORD WINAPI named_pipe_server_thread(LPVOID arg) goto out; } - SetEvent(ReadyEvent); + (void)SetEvent(ReadyEvent); /** * Note: diff --git a/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipeOverlapped.c b/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipeOverlapped.c index f234a5fa7..a22b3ffdf 100644 --- a/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipeOverlapped.c +++ b/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipeOverlapped.c @@ -172,7 +172,7 @@ static DWORD WINAPI named_pipe_server_thread(LPVOID arg) if (!(hEvent = CreateEvent(NULL, TRUE, FALSE, NULL))) { printf("server: CreateEvent failure: %" PRIu32 "\n", GetLastError()); - SetEvent(serverReadyEvent); /* unblock client thread */ + (void)SetEvent(serverReadyEvent); /* unblock client thread */ goto finish; } overlapped.hEvent = hEvent; @@ -187,11 +187,11 @@ static DWORD WINAPI named_pipe_server_thread(LPVOID arg) if (hNamedPipe == INVALID_HANDLE_VALUE) { printf("server: CreateNamedPipe failure: %" PRIu32 "\n", GetLastError()); - SetEvent(serverReadyEvent); /* unblock client thread */ + (void)SetEvent(serverReadyEvent); /* unblock client thread */ goto finish; } - SetEvent(serverReadyEvent); + (void)SetEvent(serverReadyEvent); /* 3: connect named pipe */ diff --git a/winpr/libwinpr/pool/pool.c b/winpr/libwinpr/pool/pool.c index a4c285dee..f36dcdc47 100644 --- a/winpr/libwinpr/pool/pool.c +++ b/winpr/libwinpr/pool/pool.c @@ -185,7 +185,7 @@ VOID winpr_CloseThreadpool(PTP_POOL ptpp) return; } #endif - SetEvent(ptpp->TerminateEvent); + (void)SetEvent(ptpp->TerminateEvent); ArrayList_Free(ptpp->Threads); Queue_Free(ptpp->PendingQueue); @@ -247,7 +247,7 @@ VOID winpr_SetThreadpoolThreadMaximum(PTP_POOL ptpp, DWORD cthrdMost) ArrayList_Lock(ptpp->Threads); if (ArrayList_Count(ptpp->Threads) > ptpp->Maximum) { - SetEvent(ptpp->TerminateEvent); + (void)SetEvent(ptpp->TerminateEvent); ArrayList_Clear(ptpp->Threads); ResetEvent(ptpp->TerminateEvent); } diff --git a/winpr/libwinpr/synch/barrier.c b/winpr/libwinpr/synch/barrier.c index 2b61a5918..0bb07cf9a 100644 --- a/winpr/libwinpr/synch/barrier.c +++ b/winpr/libwinpr/synch/barrier.c @@ -224,7 +224,7 @@ BOOL WINAPI winpr_EnterSynchronizationBarrier(LPSYNCHRONIZATION_BARRIER lpBarrie lpBarrier->Reserved3[0] = (ULONG_PTR)hDormantEvent; /* signal the blocked threads */ - SetEvent(hCurrentEvent); + (void)SetEvent(hCurrentEvent); return TRUE; } diff --git a/winpr/libwinpr/synch/test/TestSynchInit.c b/winpr/libwinpr/synch/test/TestSynchInit.c index 2baee47a9..7e0ffd7c1 100644 --- a/winpr/libwinpr/synch/test/TestSynchInit.c +++ b/winpr/libwinpr/synch/test/TestSynchInit.c @@ -120,7 +120,7 @@ int TestSynchInit(int argc, char* argv[]) } Sleep(100); - SetEvent(hStartEvent); + (void)SetEvent(hStartEvent); for (DWORD i = 0; i < dwCreatedThreads; i++) { diff --git a/winpr/libwinpr/synch/test/TestSynchMutex.c b/winpr/libwinpr/synch/test/TestSynchMutex.c index 509d3b949..0d4d05126 100644 --- a/winpr/libwinpr/synch/test/TestSynchMutex.c +++ b/winpr/libwinpr/synch/test/TestSynchMutex.c @@ -192,7 +192,7 @@ static BOOL test_mutex_threading(void) goto fail; } - SetEvent(hStartEvent); + (void)SetEvent(hStartEvent); if (WaitForSingleObject(hThread, 2000) != WAIT_OBJECT_0) { diff --git a/winpr/libwinpr/synch/test/TestSynchTimerQueue.c b/winpr/libwinpr/synch/test/TestSynchTimerQueue.c index 08cc95738..51d7fcd6c 100644 --- a/winpr/libwinpr/synch/test/TestSynchTimerQueue.c +++ b/winpr/libwinpr/synch/test/TestSynchTimerQueue.c @@ -46,7 +46,7 @@ static VOID CALLBACK TimerRoutine(PVOID lpParam, BOOLEAN TimerOrWaitFired) if (apcData->FireCount == apcData->MaxFireCount) { - SetEvent(apcData->CompletionEvent); + (void)SetEvent(apcData->CompletionEvent); } } diff --git a/winpr/libwinpr/synch/test/TestSynchWaitableTimerAPC.c b/winpr/libwinpr/synch/test/TestSynchWaitableTimerAPC.c index cf1f677dd..bc289e97d 100644 --- a/winpr/libwinpr/synch/test/TestSynchWaitableTimerAPC.c +++ b/winpr/libwinpr/synch/test/TestSynchWaitableTimerAPC.c @@ -28,7 +28,7 @@ static VOID CALLBACK TimerAPCProc(LPVOID lpArg, DWORD dwTimerLowValue, DWORD dwT if (g_Count >= 5) { - SetEvent(g_Event); + (void)SetEvent(g_Event); } } diff --git a/winpr/libwinpr/synch/timer.c b/winpr/libwinpr/synch/timer.c index 120b933e0..5c1564ef7 100644 --- a/winpr/libwinpr/synch/timer.c +++ b/winpr/libwinpr/synch/timer.c @@ -980,7 +980,7 @@ BOOL DeleteTimerQueueEx(HANDLE TimerQueue, HANDLE CompletionEvent) free(timerQueue); if (CompletionEvent && (CompletionEvent != INVALID_HANDLE_VALUE)) - SetEvent(CompletionEvent); + (void)SetEvent(CompletionEvent); return TRUE; } @@ -1081,7 +1081,7 @@ BOOL DeleteTimerQueueTimer(HANDLE TimerQueue, HANDLE Timer, HANDLE CompletionEve free(timer); if (CompletionEvent && (CompletionEvent != INVALID_HANDLE_VALUE)) - SetEvent(CompletionEvent); + (void)SetEvent(CompletionEvent); return TRUE; } diff --git a/winpr/libwinpr/utils/collections/CountdownEvent.c b/winpr/libwinpr/utils/collections/CountdownEvent.c index 0e8c27df0..0bb11d7c7 100644 --- a/winpr/libwinpr/utils/collections/CountdownEvent.c +++ b/winpr/libwinpr/utils/collections/CountdownEvent.c @@ -142,7 +142,7 @@ BOOL CountdownEvent_Signal(wCountdownEvent* countdown, size_t signalCount) if (newStatus && (!oldStatus)) { - SetEvent(countdown->event); + (void)SetEvent(countdown->event); status = TRUE; } diff --git a/winpr/libwinpr/utils/collections/MessageQueue.c b/winpr/libwinpr/utils/collections/MessageQueue.c index 5481bd4ab..0a2e98444 100644 --- a/winpr/libwinpr/utils/collections/MessageQueue.c +++ b/winpr/libwinpr/utils/collections/MessageQueue.c @@ -146,7 +146,7 @@ BOOL MessageQueue_Dispatch(wMessageQueue* queue, const wMessage* message) queue->size++; if (queue->size > 0) - SetEvent(queue->event); + (void)SetEvent(queue->event); if (message->id == WMQ_QUIT) queue->closed = TRUE; diff --git a/winpr/libwinpr/utils/collections/Queue.c b/winpr/libwinpr/utils/collections/Queue.c index 8bbdea83a..76cb2fbfd 100644 --- a/winpr/libwinpr/utils/collections/Queue.c +++ b/winpr/libwinpr/utils/collections/Queue.c @@ -220,7 +220,7 @@ BOOL Queue_Enqueue(wQueue* queue, const void* obj) queue->size++; if (signalSet) - SetEvent(queue->event); + (void)SetEvent(queue->event); out: Queue_Unlock(queue); diff --git a/winpr/libwinpr/wtsapi/wtsapi_win32.c b/winpr/libwinpr/wtsapi/wtsapi_win32.c index 0be7d0bce..8481d3442 100644 --- a/winpr/libwinpr/wtsapi/wtsapi_win32.c +++ b/winpr/libwinpr/wtsapi/wtsapi_win32.c @@ -146,7 +146,7 @@ BOOL Win32_WTSVirtualChannelReadAsync(WTSAPI_CHANNEL* pChannel) pChannel->header->length = numBytes; pChannel->readDone = TRUE; - SetEvent(pChannel->hEvent); + (void)SetEvent(pChannel->hEvent); return TRUE; } From 7c8c14294f6f5b5a0776e30272ffee690324baae Mon Sep 17 00:00:00 2001 From: akallabeth Date: Mon, 16 Sep 2024 05:47:55 +0200 Subject: [PATCH 02/13] [return checks] fix use of ReleaseMutex --- channels/urbdrc/client/libusb/libusb_udevman.c | 2 +- client/X11/xf_client.c | 2 +- winpr/libwinpr/interlocked/interlocked.c | 2 +- winpr/libwinpr/synch/test/TestSynchMutex.c | 4 ++-- winpr/libwinpr/utils/ssl.c | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/channels/urbdrc/client/libusb/libusb_udevman.c b/channels/urbdrc/client/libusb/libusb_udevman.c index 27f9644db..541d0e366 100644 --- a/channels/urbdrc/client/libusb/libusb_udevman.c +++ b/channels/urbdrc/client/libusb/libusb_udevman.c @@ -442,7 +442,7 @@ static void udevman_loading_lock(IUDEVMAN* idevman) static void udevman_loading_unlock(IUDEVMAN* idevman) { UDEVMAN* udevman = (UDEVMAN*)idevman; - ReleaseMutex(udevman->devman_loading); + (void)ReleaseMutex(udevman->devman_loading); } BASIC_STATE_FUNC_DEFINED(device_num, UINT32) diff --git a/client/X11/xf_client.c b/client/X11/xf_client.c index cb599e0f4..d02134830 100644 --- a/client/X11/xf_client.c +++ b/client/X11/xf_client.c @@ -827,7 +827,7 @@ void xf_unlock_x11_(xfContext* xfc, const char* fkt) #endif if (!xfc->UseXThreads) - ReleaseMutex(xfc->mutex); + (void)ReleaseMutex(xfc->mutex); else XUnlockDisplay(xfc->display); } diff --git a/winpr/libwinpr/interlocked/interlocked.c b/winpr/libwinpr/interlocked/interlocked.c index b560f5947..c9a83de16 100644 --- a/winpr/libwinpr/interlocked/interlocked.c +++ b/winpr/libwinpr/interlocked/interlocked.c @@ -330,7 +330,7 @@ LONGLONG InterlockedCompareExchange64(LONGLONG volatile* Destination, LONGLONG E *Destination = Exchange; if (locked) - ReleaseMutex(mutex); + (void)ReleaseMutex(mutex); else (void)fprintf(stderr, "WARNING: InterlockedCompareExchange64 operation might have failed\n"); diff --git a/winpr/libwinpr/synch/test/TestSynchMutex.c b/winpr/libwinpr/synch/test/TestSynchMutex.c index 0d4d05126..4744f054a 100644 --- a/winpr/libwinpr/synch/test/TestSynchMutex.c +++ b/winpr/libwinpr/synch/test/TestSynchMutex.c @@ -229,8 +229,8 @@ static BOOL test_mutex_threading(void) CloseHandle(thread1_mutex2); return TRUE; fail: - ReleaseMutex(thread1_mutex1); - ReleaseMutex(thread1_mutex2); + (void)ReleaseMutex(thread1_mutex1); + (void)ReleaseMutex(thread1_mutex2); CloseHandle(thread1_mutex1); CloseHandle(thread1_mutex2); CloseHandle(hStartEvent); diff --git a/winpr/libwinpr/utils/ssl.c b/winpr/libwinpr/utils/ssl.c index 2f85206ed..08002dc1b 100644 --- a/winpr/libwinpr/utils/ssl.c +++ b/winpr/libwinpr/utils/ssl.c @@ -79,7 +79,7 @@ static void _winpr_openssl_locking(int mode, int type, const char* file, int lin } else { - ReleaseMutex(g_winpr_openssl_locks[type]); + (void)ReleaseMutex(g_winpr_openssl_locks[type]); } } @@ -108,7 +108,7 @@ static void _winpr_openssl_dynlock_lock(int mode, struct CRYPTO_dynlock_value* d } else { - ReleaseMutex(dynlock->mutex); + (void)ReleaseMutex(dynlock->mutex); } } From 94020c183c5fcf141e1d6827da8917f81c9f7a53 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Mon, 16 Sep 2024 04:53:18 +0200 Subject: [PATCH 03/13] [return checks] fix use of ResetEvent --- channels/printer/client/printer_main.c | 2 +- channels/rdp2tcp/client/rdp2tcp_main.c | 2 +- channels/rdpei/client/rdpei_main.c | 2 +- channels/tsmf/client/tsmf_media.c | 2 +- .../Studio/freeRDPCore/src/main/cpp/android_cliprdr.c | 2 +- client/Mac/Clipboard.m | 2 +- client/SDL/SDL2/sdl_utils.cpp | 2 +- client/SDL/SDL3/sdl_clip.cpp | 2 +- client/SDL/SDL3/sdl_utils.cpp | 2 +- client/iOS/FreeRDP/ios_cliprdr.m | 2 +- libfreerdp/core/freerdp.c | 2 +- libfreerdp/core/gateway/rpc_client.c | 2 +- libfreerdp/core/listener.c | 2 +- libfreerdp/core/tcp.c | 4 ++-- libfreerdp/core/transport.c | 2 +- server/Windows/wf_peer.c | 6 +++--- server/shadow/Win/win_rdp.c | 2 +- server/shadow/Win/win_shadow.c | 2 +- server/shadow/shadow_mcevent.c | 6 +++--- winpr/libwinpr/pool/pool.c | 2 +- winpr/libwinpr/synch/barrier.c | 2 +- winpr/libwinpr/utils/collections/CountdownEvent.c | 2 +- winpr/libwinpr/utils/collections/MessageQueue.c | 6 +++--- winpr/libwinpr/utils/collections/Queue.c | 4 ++-- winpr/libwinpr/wtsapi/wtsapi_win32.c | 2 +- 25 files changed, 33 insertions(+), 33 deletions(-) diff --git a/channels/printer/client/printer_main.c b/channels/printer/client/printer_main.c index ec32a3176..40cfeda70 100644 --- a/channels/printer/client/printer_main.c +++ b/channels/printer/client/printer_main.c @@ -651,7 +651,7 @@ static DWORD WINAPI printer_thread_func(LPVOID arg) else if (rc != WAIT_OBJECT_0) continue; - ResetEvent(printer_dev->event); + (void)ResetEvent(printer_dev->event); irp = (IRP*)InterlockedPopEntrySList(printer_dev->pIrpList); if (irp == NULL) diff --git a/channels/rdp2tcp/client/rdp2tcp_main.c b/channels/rdp2tcp/client/rdp2tcp_main.c index 2a7e724ed..5b3340b0b 100644 --- a/channels/rdp2tcp/client/rdp2tcp_main.c +++ b/channels/rdp2tcp/client/rdp2tcp_main.c @@ -175,7 +175,7 @@ static DWORD WINAPI copyThread(void* data) handles[1] = freerdp_abort_event(plugin->channelEntryPoints.context); status = WaitForMultipleObjects(2, handles, FALSE, INFINITE); if (status == WAIT_OBJECT_0) - ResetEvent(plugin->writeComplete); + (void)ResetEvent(plugin->writeComplete); } fail: diff --git a/channels/rdpei/client/rdpei_main.c b/channels/rdpei/client/rdpei_main.c index c374ce64d..8a3e06109 100644 --- a/channels/rdpei/client/rdpei_main.c +++ b/channels/rdpei/client/rdpei_main.c @@ -464,7 +464,7 @@ static DWORD WINAPI rdpei_periodic_update(LPVOID arg) } if (status == WAIT_OBJECT_0) - ResetEvent(rdpei->event); + (void)ResetEvent(rdpei->event); LeaveCriticalSection(&rdpei->lock); } diff --git a/channels/tsmf/client/tsmf_media.c b/channels/tsmf/client/tsmf_media.c index 63d409fe5..81717bc66 100644 --- a/channels/tsmf/client/tsmf_media.c +++ b/channels/tsmf/client/tsmf_media.c @@ -1316,7 +1316,7 @@ TSMF_STREAM* tsmf_stream_find_by_id(TSMF_PRESENTATION* presentation, UINT32 stre static void tsmf_stream_resync(void* arg) { TSMF_STREAM* stream = arg; - ResetEvent(stream->ready); + (void)ResetEvent(stream->ready); } BOOL tsmf_stream_set_format(TSMF_STREAM* stream, const char* name, wStream* s) diff --git a/client/Android/Studio/freeRDPCore/src/main/cpp/android_cliprdr.c b/client/Android/Studio/freeRDPCore/src/main/cpp/android_cliprdr.c index 0f777df67..b6601e95e 100644 --- a/client/Android/Studio/freeRDPCore/src/main/cpp/android_cliprdr.c +++ b/client/Android/Studio/freeRDPCore/src/main/cpp/android_cliprdr.c @@ -108,7 +108,7 @@ static UINT android_cliprdr_send_client_format_data_request(CliprdrClientContext formatDataRequest.common.msgFlags = 0; formatDataRequest.requestedFormatId = formatId; afc->requestedFormatId = formatId; - ResetEvent(afc->clipboardRequestEvent); + (void)ResetEvent(afc->clipboardRequestEvent); rc = cliprdr->ClientFormatDataRequest(cliprdr, &formatDataRequest); fail: return rc; diff --git a/client/Mac/Clipboard.m b/client/Mac/Clipboard.m index dee7da518..02d7b39be 100644 --- a/client/Mac/Clipboard.m +++ b/client/Mac/Clipboard.m @@ -99,7 +99,7 @@ static int mac_cliprdr_send_client_format_data_request(CliprdrClientContext *cli formatDataRequest.requestedFormatId = formatId; mfc->requestedFormatId = formatId; - ResetEvent(mfc->clipboardRequestEvent); + (void)ResetEvent(mfc->clipboardRequestEvent); cliprdr->ClientFormatDataRequest(cliprdr, &formatDataRequest); diff --git a/client/SDL/SDL2/sdl_utils.cpp b/client/SDL/SDL2/sdl_utils.cpp index be8c363da..a10bd1ed3 100644 --- a/client/SDL/SDL2/sdl_utils.cpp +++ b/client/SDL/SDL2/sdl_utils.cpp @@ -270,7 +270,7 @@ void WinPREvent::set() void WinPREvent::clear() { - ResetEvent(_handle); + (void)ResetEvent(_handle); } bool WinPREvent::isSet() const diff --git a/client/SDL/SDL3/sdl_clip.cpp b/client/SDL/SDL3/sdl_clip.cpp index a0f739a9e..7e19d15b2 100644 --- a/client/SDL/SDL3/sdl_clip.cpp +++ b/client/SDL/SDL3/sdl_clip.cpp @@ -681,7 +681,7 @@ const void* sdlClip::ClipDataCb(void* userdata, const char* mime_type, size_t* s std::lock_guard lock(clip->_lock); auto request = clip->_request_queue.front(); clip->_request_queue.pop(); - ResetEvent(clip->_event); + (void)ResetEvent(clip->_event); auto formatID = ClipboardRegisterFormat(clip->_system, mime_type); auto data = ClipboardGetData(clip->_system, formatID, &len); diff --git a/client/SDL/SDL3/sdl_utils.cpp b/client/SDL/SDL3/sdl_utils.cpp index f456b6258..6e59a2b73 100644 --- a/client/SDL/SDL3/sdl_utils.cpp +++ b/client/SDL/SDL3/sdl_utils.cpp @@ -316,7 +316,7 @@ void WinPREvent::set() void WinPREvent::clear() { - ResetEvent(_handle); + (void)ResetEvent(_handle); } bool WinPREvent::isSet() const diff --git a/client/iOS/FreeRDP/ios_cliprdr.m b/client/iOS/FreeRDP/ios_cliprdr.m index f79f4525c..92780129a 100644 --- a/client/iOS/FreeRDP/ios_cliprdr.m +++ b/client/iOS/FreeRDP/ios_cliprdr.m @@ -106,7 +106,7 @@ static UINT ios_cliprdr_send_client_format_data_request(CliprdrClientContext *cl formatDataRequest.common.msgFlags = 0; formatDataRequest.requestedFormatId = formatId; afc->requestedFormatId = formatId; - ResetEvent(afc->clipboardRequestEvent); + (void)ResetEvent(afc->clipboardRequestEvent); rc = cliprdr->ClientFormatDataRequest(cliprdr, &formatDataRequest); fail: return rc; diff --git a/libfreerdp/core/freerdp.c b/libfreerdp/core/freerdp.c index 18c58323e..140de6591 100644 --- a/libfreerdp/core/freerdp.c +++ b/libfreerdp/core/freerdp.c @@ -1292,7 +1292,7 @@ void clearChannelError(rdpContext* context) WINPR_ASSERT(context); context->channelErrorNum = 0; memset(context->errorDescription, 0, 500); - ResetEvent(context->channelErrorEvent); + (void)ResetEvent(context->channelErrorEvent); } WINPR_ATTR_FORMAT_ARG(3, 4) diff --git a/libfreerdp/core/gateway/rpc_client.c b/libfreerdp/core/gateway/rpc_client.c index 74ce882ec..3083d4aa2 100644 --- a/libfreerdp/core/gateway/rpc_client.c +++ b/libfreerdp/core/gateway/rpc_client.c @@ -165,7 +165,7 @@ int rpc_client_receive_pipe_read(RpcClient* client, BYTE* buffer, size_t length) ringbuffer_commit_read_bytes(&(client->ReceivePipe), status); if (ringbuffer_used(&(client->ReceivePipe)) < 1) - ResetEvent(client->PipeEvent); + (void)ResetEvent(client->PipeEvent); LeaveCriticalSection(&(client->PipeLock)); diff --git a/libfreerdp/core/listener.c b/libfreerdp/core/listener.c index a7592da13..4726b19b6 100644 --- a/libfreerdp/core/listener.c +++ b/libfreerdp/core/listener.c @@ -476,7 +476,7 @@ static BOOL freerdp_listener_check_fds(freerdp_listener* instance) { struct sockaddr_storage peer_addr = { 0 }; - WSAResetEvent(listener->events[i]); + (void)WSAResetEvent(listener->events[i]); int peer_addr_size = sizeof(peer_addr); int peer_sockfd = _accept(listener->sockfds[i], (struct sockaddr*)&peer_addr, &peer_addr_size); diff --git a/libfreerdp/core/tcp.c b/libfreerdp/core/tcp.c index beaf6c584..62240361d 100644 --- a/libfreerdp/core/tcp.c +++ b/libfreerdp/core/tcp.c @@ -149,7 +149,7 @@ static int transport_bio_simple_read(BIO* bio, char* buf, int size) return 0; BIO_clear_flags(bio, BIO_FLAGS_READ); - WSAResetEvent(ptr->hEvent); + (void)WSAResetEvent(ptr->hEvent); status = _recv(ptr->socket, buf, size, 0); if (status > 0) @@ -1356,7 +1356,7 @@ static int freerdp_tcp_layer_read(void* userContext, void* data, int bytes) int error = 0; int status = 0; - WSAResetEvent(tcpLayer->hEvent); + (void)WSAResetEvent(tcpLayer->hEvent); status = _recv(tcpLayer->sockfd, data, bytes, 0); if (status > 0) diff --git a/libfreerdp/core/transport.c b/libfreerdp/core/transport.c index e60b4ae6a..814f3d656 100644 --- a/libfreerdp/core/transport.c +++ b/libfreerdp/core/transport.c @@ -1427,7 +1427,7 @@ int transport_check_fds(rdpTransport* transport) if (transport->haveMoreBytesToRead) { transport->haveMoreBytesToRead = FALSE; - ResetEvent(transport->rereadEvent); + (void)ResetEvent(transport->rereadEvent); } return status; } diff --git a/server/Windows/wf_peer.c b/server/Windows/wf_peer.c index d213d23a1..bea273b8e 100644 --- a/server/Windows/wf_peer.c +++ b/server/Windows/wf_peer.c @@ -357,7 +357,7 @@ DWORD WINAPI wf_peer_main_loop(LPVOID lpParam) if (client->activated) wf_update_peer_send(wfi, context); - ResetEvent(context->updateEvent); + (void)ResetEvent(context->updateEvent); ReleaseSemaphore(wfi->updateSemaphore, 1, NULL); } @@ -369,7 +369,7 @@ DWORD WINAPI wf_peer_main_loop(LPVOID lpParam) context->socketClose = TRUE; } - ResetEvent(context->socketEvent); + (void)ResetEvent(context->socketEvent); ReleaseSemaphore(context->socketSemaphore, 1, NULL); if (context->socketClose) @@ -392,7 +392,7 @@ DWORD WINAPI wf_peer_main_loop(LPVOID lpParam) if (WaitForSingleObject(context->updateEvent, 0) == 0) { - ResetEvent(context->updateEvent); + (void)ResetEvent(context->updateEvent); ReleaseSemaphore(wfi->updateSemaphore, 1, NULL); } diff --git a/server/shadow/Win/win_rdp.c b/server/shadow/Win/win_rdp.c index a28b9bf5b..fc112ed43 100644 --- a/server/shadow/Win/win_rdp.c +++ b/server/shadow/Win/win_rdp.c @@ -81,7 +81,7 @@ static BOOL shw_end_paint(rdpContext* context) (void)SetEvent(subsystem->RdpUpdateEnterEvent); WaitForSingleObject(subsystem->RdpUpdateLeaveEvent, INFINITE); - ResetEvent(subsystem->RdpUpdateLeaveEvent); + (void)ResetEvent(subsystem->RdpUpdateLeaveEvent); return TRUE; } diff --git a/server/shadow/Win/win_shadow.c b/server/shadow/Win/win_shadow.c index b55565b38..2a6d62347 100644 --- a/server/shadow/Win/win_shadow.c +++ b/server/shadow/Win/win_shadow.c @@ -353,7 +353,7 @@ static DWORD WINAPI win_shadow_subsystem_thread(LPVOID arg) if (WaitForSingleObject(subsystem->RdpUpdateEnterEvent, 0) == WAIT_OBJECT_0) { win_shadow_surface_copy(subsystem); - ResetEvent(subsystem->RdpUpdateEnterEvent); + (void)ResetEvent(subsystem->RdpUpdateEnterEvent); (void)SetEvent(subsystem->RdpUpdateLeaveEvent); } } diff --git a/server/shadow/shadow_mcevent.c b/server/shadow/shadow_mcevent.c index f94b66845..0829f86dd 100644 --- a/server/shadow/shadow_mcevent.c +++ b/server/shadow/shadow_mcevent.c @@ -128,7 +128,7 @@ static void Publish(rdpShadowMultiClientEvent* event) { event->eventid = (event->eventid & 0xff) + 1; WLog_VRB(TAG, "Server published event %d. %d clients.\n", event->eventid, event->consuming); - ResetEvent(event->doneEvent); + (void)ResetEvent(event->doneEvent); (void)SetEvent(event->event); } } @@ -195,7 +195,7 @@ static BOOL Consume(struct rdp_shadow_multiclient_subscriber* subscriber, BOOL w if (event->consuming == 0) { /* Last client reset event before notify clients to continue */ - ResetEvent(event->event); + (void)ResetEvent(event->event); if (event->waiting > 0) { @@ -229,7 +229,7 @@ static BOOL Consume(struct rdp_shadow_multiclient_subscriber* subscriber, BOOL w * We can now discard barrierEvent and notify * server to continue. */ - ResetEvent(event->barrierEvent); + (void)ResetEvent(event->barrierEvent); (void)SetEvent(event->doneEvent); } } diff --git a/winpr/libwinpr/pool/pool.c b/winpr/libwinpr/pool/pool.c index f36dcdc47..b3d2ce7a5 100644 --- a/winpr/libwinpr/pool/pool.c +++ b/winpr/libwinpr/pool/pool.c @@ -249,7 +249,7 @@ VOID winpr_SetThreadpoolThreadMaximum(PTP_POOL ptpp, DWORD cthrdMost) { (void)SetEvent(ptpp->TerminateEvent); ArrayList_Clear(ptpp->Threads); - ResetEvent(ptpp->TerminateEvent); + (void)ResetEvent(ptpp->TerminateEvent); } ArrayList_Unlock(ptpp->Threads); winpr_SetThreadpoolThreadMinimum(ptpp, ptpp->Minimum); diff --git a/winpr/libwinpr/synch/barrier.c b/winpr/libwinpr/synch/barrier.c index 0bb07cf9a..ecee3b988 100644 --- a/winpr/libwinpr/synch/barrier.c +++ b/winpr/libwinpr/synch/barrier.c @@ -214,7 +214,7 @@ BOOL WINAPI winpr_EnterSynchronizationBarrier(LPSYNCHRONIZATION_BARRIER lpBarrie } /* reset the dormant event first */ - ResetEvent(hDormantEvent); + (void)ResetEvent(hDormantEvent); /* reset the remaining counter */ lpBarrier->Reserved1 = lpBarrier->Reserved2; diff --git a/winpr/libwinpr/utils/collections/CountdownEvent.c b/winpr/libwinpr/utils/collections/CountdownEvent.c index 0bb11d7c7..bbaa0fe09 100644 --- a/winpr/libwinpr/utils/collections/CountdownEvent.c +++ b/winpr/libwinpr/utils/collections/CountdownEvent.c @@ -109,7 +109,7 @@ void CountdownEvent_AddCount(wCountdownEvent* countdown, size_t signalCount) countdown->count += signalCount; if (signalSet) - ResetEvent(countdown->event); + (void)ResetEvent(countdown->event); LeaveCriticalSection(&countdown->lock); } diff --git a/winpr/libwinpr/utils/collections/MessageQueue.c b/winpr/libwinpr/utils/collections/MessageQueue.c index 0a2e98444..0d1b6f312 100644 --- a/winpr/libwinpr/utils/collections/MessageQueue.c +++ b/winpr/libwinpr/utils/collections/MessageQueue.c @@ -192,7 +192,7 @@ int MessageQueue_Get(wMessageQueue* queue, wMessage* message) queue->size--; if (queue->size < 1) - ResetEvent(queue->event); + (void)ResetEvent(queue->event); status = (message->id != WMQ_QUIT) ? 1 : 0; } @@ -221,7 +221,7 @@ int MessageQueue_Peek(wMessageQueue* queue, wMessage* message, BOOL remove) queue->size--; if (queue->size < 1) - ResetEvent(queue->event); + (void)ResetEvent(queue->event); } } @@ -304,7 +304,7 @@ int MessageQueue_Clear(wMessageQueue* queue) queue->head = (queue->head + 1) % queue->capacity; queue->size--; } - ResetEvent(queue->event); + (void)ResetEvent(queue->event); queue->closed = FALSE; LeaveCriticalSection(&queue->lock); diff --git a/winpr/libwinpr/utils/collections/Queue.c b/winpr/libwinpr/utils/collections/Queue.c index 76cb2fbfd..925d37632 100644 --- a/winpr/libwinpr/utils/collections/Queue.c +++ b/winpr/libwinpr/utils/collections/Queue.c @@ -131,7 +131,7 @@ void Queue_Clear(wQueue* queue) queue->size = 0; queue->head = queue->tail = 0; - ResetEvent(queue->event); + (void)ResetEvent(queue->event); Queue_Unlock(queue); } @@ -247,7 +247,7 @@ void* Queue_Dequeue(wQueue* queue) } if (queue->size < 1) - ResetEvent(queue->event); + (void)ResetEvent(queue->event); Queue_Unlock(queue); diff --git a/winpr/libwinpr/wtsapi/wtsapi_win32.c b/winpr/libwinpr/wtsapi/wtsapi_win32.c index 8481d3442..b0cce7896 100644 --- a/winpr/libwinpr/wtsapi/wtsapi_win32.c +++ b/winpr/libwinpr/wtsapi/wtsapi_win32.c @@ -126,7 +126,7 @@ BOOL Win32_WTSVirtualChannelReadAsync(WTSAPI_CHANNEL* pChannel) ZeroMemory(&(pChannel->overlapped), sizeof(OVERLAPPED)); pChannel->overlapped.hEvent = pChannel->hEvent; - ResetEvent(pChannel->hEvent); + (void)ResetEvent(pChannel->hEvent); if (pChannel->showProtocol) { From 4d2197eab09c4441901a8c42537ac1b4f1da639a Mon Sep 17 00:00:00 2001 From: akallabeth Date: Mon, 16 Sep 2024 05:08:35 +0200 Subject: [PATCH 04/13] [return checks] fix use of TerminateThread --- channels/rdp2tcp/client/rdp2tcp_main.c | 2 +- channels/serial/client/serial_main.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/channels/rdp2tcp/client/rdp2tcp_main.c b/channels/rdp2tcp/client/rdp2tcp_main.c index 5b3340b0b..ac966c1e5 100644 --- a/channels/rdp2tcp/client/rdp2tcp_main.c +++ b/channels/rdp2tcp/client/rdp2tcp_main.c @@ -261,7 +261,7 @@ static void channel_terminated(Plugin* plugin) return; if (plugin->copyThread) - TerminateThread(plugin->copyThread, 0); + (void)TerminateThread(plugin->copyThread, 0); if (plugin->writeComplete) CloseHandle(plugin->writeComplete); diff --git a/channels/serial/client/serial_main.c b/channels/serial/client/serial_main.c index 34d3ee96d..eb4cf3952 100644 --- a/channels/serial/client/serial_main.c +++ b/channels/serial/client/serial_main.c @@ -825,7 +825,7 @@ static void irp_thread_close(void* arg) WLog_WARN(TAG, "closing self, ignoring..."); else { - TerminateThread(hdl, 0); + (void)TerminateThread(hdl, 0); WaitForSingleObject(hdl, INFINITE); CloseHandle(hdl); } From 4c8f6383ae700d001427eae87799b8137dfc659b Mon Sep 17 00:00:00 2001 From: akallabeth Date: Mon, 16 Sep 2024 05:11:01 +0200 Subject: [PATCH 05/13] [return checks] fix use of freerdp_interruptible_getc --- client/common/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/common/client.c b/client/common/client.c index a1d011bb2..f8c29b089 100644 --- a/client/common/client.c +++ b/client/common/client.c @@ -980,7 +980,7 @@ BOOL client_cli_present_gateway_message(freerdp* instance, UINT32 type, BOOL isD case 'n': case 'N': - freerdp_interruptible_getc(instance->context, stdin); + (void)freerdp_interruptible_getc(instance->context, stdin); return FALSE; default: From 07ea37d1d7ed16e8e5b69e9d88fb85d6e56825c4 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Mon, 16 Sep 2024 05:19:49 +0200 Subject: [PATCH 06/13] [return checks] fix use of CommandLineParseArgumentsA --- client/common/cmdline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/common/cmdline.c b/client/common/cmdline.c index cddb58f0d..5b25ea371 100644 --- a/client/common/cmdline.c +++ b/client/common/cmdline.c @@ -1779,7 +1779,7 @@ int freerdp_client_settings_command_line_status_print_ex(rdpSettings* settings, } else if (status == COMMAND_LINE_STATUS_PRINT) { - CommandLineParseArgumentsA(argc, argv, largs, 0x112, NULL, NULL, NULL); + (void)CommandLineParseArgumentsA(argc, argv, largs, 0x112, NULL, NULL, NULL); arg = CommandLineFindArgumentA(largs, "list"); WINPR_ASSERT(arg); From c0d06c782b47d5e2558cb46f8bb1e4ebc69b9e8c Mon Sep 17 00:00:00 2001 From: akallabeth Date: Mon, 16 Sep 2024 05:16:18 +0200 Subject: [PATCH 07/13] [return checks] fix missing checks * Stream_EnsureRemainingCapacity * rdp_client_transition_to_state --- libfreerdp/core/rdp.c | 2 +- libfreerdp/emu/scard/smartcard_virtual_gids.c | 4 ++-- server/Sample/sfreerdp.c | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/libfreerdp/core/rdp.c b/libfreerdp/core/rdp.c index 655b017af..689c738b4 100644 --- a/libfreerdp/core/rdp.c +++ b/libfreerdp/core/rdp.c @@ -2047,7 +2047,7 @@ static state_run_t rdp_recv_callback_int(rdpTransport* transport, wStream* s, vo case CONNECTION_STATE_MULTITRANSPORT_BOOTSTRAPPING_REQUEST: if (!rdp_client_connect_auto_detect(rdp, s)) { - rdp_client_transition_to_state( + (void)rdp_client_transition_to_state( rdp, CONNECTION_STATE_CAPABILITIES_EXCHANGE_DEMAND_ACTIVE); status = STATE_RUN_TRY_AGAIN; } diff --git a/libfreerdp/emu/scard/smartcard_virtual_gids.c b/libfreerdp/emu/scard/smartcard_virtual_gids.c index 9e0e8d53f..a81569a3b 100644 --- a/libfreerdp/emu/scard/smartcard_virtual_gids.c +++ b/libfreerdp/emu/scard/smartcard_virtual_gids.c @@ -1257,8 +1257,8 @@ static BOOL vgids_ins_perform_security_operation(vgidsContext* context, wStream* if (!context->commandData) return FALSE; } - else - Stream_EnsureRemainingCapacity(context->commandData, lc); + else if (!Stream_EnsureRemainingCapacity(context->commandData, lc)) + return FALSE; Stream_Write(context->commandData, Stream_Pointer(s), lc); Stream_SealLength(context->commandData); diff --git a/server/Sample/sfreerdp.c b/server/Sample/sfreerdp.c index b7d29c905..e64fbcccc 100644 --- a/server/Sample/sfreerdp.c +++ b/server/Sample/sfreerdp.c @@ -659,7 +659,8 @@ static DWORD WINAPI tf_debug_channel_thread_func(LPVOID arg) if (BytesReturned == 0) break; - Stream_EnsureRemainingCapacity(s, BytesReturned); + if (!Stream_EnsureRemainingCapacity(s, BytesReturned)) + break; if (WTSVirtualChannelRead(context->debug_channel, 0, (PCHAR)Stream_Buffer(s), (ULONG)Stream_Capacity(s), &BytesReturned) == FALSE) From f655843260a1c6e0b5ee9a862b693de68a975028 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Mon, 16 Sep 2024 05:18:43 +0200 Subject: [PATCH 08/13] [return checks] fix use of rdpSettings getter/setter --- client/common/client.c | 3 ++- client/common/cmdline.c | 3 ++- libfreerdp/common/settings.c | 4 ++-- libfreerdp/core/gcc.c | 5 ++++- server/proxy/pf_server.c | 10 ++++++++-- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/client/common/client.c b/client/common/client.c index f8c29b089..632d7e197 100644 --- a/client/common/client.c +++ b/client/common/client.c @@ -1411,7 +1411,8 @@ client_encomsp_participant_created(EncomspClientContext* context, /* if auto-request-control setting is enabled then only request control once upon connect, * otherwise it will auto request control again every time server turns off control which * is a bit annoying */ - freerdp_settings_set_bool(settings, FreeRDP_RemoteAssistanceRequestControl, FALSE); + if (!freerdp_settings_set_bool(settings, FreeRDP_RemoteAssistanceRequestControl, FALSE)) + return ERROR_INTERNAL_ERROR; } return CHANNEL_RC_OK; diff --git a/client/common/cmdline.c b/client/common/cmdline.c index 5b25ea371..263640830 100644 --- a/client/common/cmdline.c +++ b/client/common/cmdline.c @@ -2464,7 +2464,8 @@ static int parse_host_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT if (!arg->Value) return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; - freerdp_settings_set_string(settings, FreeRDP_ServerHostname, NULL); + if (!freerdp_settings_set_string(settings, FreeRDP_ServerHostname, NULL)) + return COMMAND_LINE_ERROR_MEMORY; char* p = strchr(arg->Value, '['); /* ipv4 */ diff --git a/libfreerdp/common/settings.c b/libfreerdp/common/settings.c index 9995dd8eb..a0157e43c 100644 --- a/libfreerdp/common/settings.c +++ b/libfreerdp/common/settings.c @@ -677,9 +677,9 @@ void freerdp_static_channel_collection_free(rdpSettings* settings) } free(settings->StaticChannelArray); - freerdp_settings_set_uint32(settings, FreeRDP_StaticChannelArraySize, 0); + (void)freerdp_settings_set_uint32(settings, FreeRDP_StaticChannelArraySize, 0); settings->StaticChannelArray = NULL; - freerdp_settings_set_uint32(settings, FreeRDP_StaticChannelCount, 0); + (void)freerdp_settings_set_uint32(settings, FreeRDP_StaticChannelCount, 0); } BOOL freerdp_dynamic_channel_collection_del(rdpSettings* settings, const char* name) diff --git a/libfreerdp/core/gcc.c b/libfreerdp/core/gcc.c index 2bf7ff553..8c088de06 100644 --- a/libfreerdp/core/gcc.c +++ b/libfreerdp/core/gcc.c @@ -1366,7 +1366,10 @@ BOOL gcc_read_client_core_data(wStream* s, rdpMcs* mcs) */ if ((clientColorDepth < freerdp_settings_get_uint32(settings, FreeRDP_ColorDepth)) || !settings->ServerMode) - freerdp_settings_set_uint32(settings, FreeRDP_ColorDepth, clientColorDepth); + { + if (!freerdp_settings_set_uint32(settings, FreeRDP_ColorDepth, clientColorDepth)) + return FALSE; + } WLog_DBG(TAG, "Received EarlyCapabilityFlags=%s", rdp_early_client_caps_string(settings->EarlyCapabilityFlags, buffer, sizeof(buffer))); diff --git a/server/proxy/pf_server.c b/server/proxy/pf_server.c index 6d34f0670..8f026fbbc 100644 --- a/server/proxy/pf_server.c +++ b/server/proxy/pf_server.c @@ -137,9 +137,15 @@ static BOOL pf_server_get_target_info(rdpContext* context, rdpSettings* settings WINPR_ASSERT(config); if (config->TargetPort > 0) - freerdp_settings_set_uint32(settings, FreeRDP_ServerPort, config->TargetPort); + { + if (!freerdp_settings_set_uint32(settings, FreeRDP_ServerPort, config->TargetPort)) + return FALSE; + } else - freerdp_settings_set_uint32(settings, FreeRDP_ServerPort, 3389); + { + if (!freerdp_settings_set_uint32(settings, FreeRDP_ServerPort, 3389)) + return FALSE; + } if (!freerdp_settings_set_uint32(settings, FreeRDP_TlsSecLevel, config->TargetTlsSecLevel)) From cd18dea17452cf3d930b1448809c60394ae9bde7 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Mon, 16 Sep 2024 05:14:10 +0200 Subject: [PATCH 09/13] [return checks] fix use of unicode functions --- channels/drive/client/drive_file.c | 14 ++++---- client/Windows/wf_client.c | 15 +++++---- client/common/client_cliprdr_file.c | 4 +-- client/common/cmdline.c | 8 ++--- libfreerdp/core/childsession.c | 2 +- libfreerdp/core/smartcardlogon.c | 4 +-- libfreerdp/core/timezone.c | 8 ++--- libfreerdp/utils/rdpdr_utils.c | 4 +-- libfreerdp/utils/smartcard_pack.c | 16 +++++----- winpr/libwinpr/crt/string.c | 2 +- winpr/libwinpr/crt/test/TestString.c | 19 +++++++---- winpr/libwinpr/dsparse/test/TestDsMakeSpn.c | 16 +++++----- winpr/libwinpr/file/file.c | 2 +- winpr/libwinpr/file/test/TestFileDeleteFile.c | 2 +- .../file/test/TestFileFindFirstFile.c | 8 ++--- winpr/libwinpr/ncrypt/ncrypt.c | 2 +- winpr/libwinpr/ncrypt/ncrypt_pkcs11.c | 4 +-- .../ncrypt/test/TestNCryptProviders.c | 2 +- .../ncrypt/test/TestNCryptSmartcard.c | 2 +- winpr/libwinpr/smartcard/smartcard_pcsc.c | 2 +- winpr/libwinpr/timezone/timezone.c | 32 +++++++++---------- 21 files changed, 87 insertions(+), 81 deletions(-) diff --git a/channels/drive/client/drive_file.c b/channels/drive/client/drive_file.c index ed66592e2..fef202687 100644 --- a/channels/drive/client/drive_file.c +++ b/channels/drive/client/drive_file.c @@ -45,12 +45,12 @@ #include "drive_file.h" #ifdef WITH_DEBUG_RDPDR -#define DEBUG_WSTR(msg, wstr) \ - do \ - { \ - char lpstr[1024] = { 0 }; \ - ConvertWCharToUtf8(wstr, lpstr, ARRAYSIZE(lpstr)); \ - WLog_DBG(TAG, msg, lpstr); \ +#define DEBUG_WSTR(msg, wstr) \ + do \ + { \ + char lpstr[1024] = { 0 }; \ + (void)ConvertWCharToUtf8(wstr, lpstr, ARRAYSIZE(lpstr)); \ + WLog_DBG(TAG, msg, lpstr); \ } while (0) #else #define DEBUG_WSTR(msg, wstr) \ @@ -147,7 +147,7 @@ static WCHAR* drive_file_combine_fullpath(const WCHAR* base_path, const WCHAR* p if (contains_dotdot(&fullpath[base_path_length], base_path_length, PathWCharLength)) { char abuffer[MAX_PATH] = { 0 }; - ConvertWCharToUtf8(&fullpath[base_path_length], abuffer, ARRAYSIZE(abuffer)); + (void)ConvertWCharToUtf8(&fullpath[base_path_length], abuffer, ARRAYSIZE(abuffer)); WLog_WARN(TAG, "[rdpdr] received invalid file path '%s' from server, aborting!", &abuffer[base_path_length]); diff --git a/client/Windows/wf_client.c b/client/Windows/wf_client.c index c7dbb2820..59f924f24 100644 --- a/client/Windows/wf_client.c +++ b/client/Windows/wf_client.c @@ -526,15 +526,15 @@ static BOOL wf_authenticate_ex(freerdp* instance, char** username, char** passwo if (*username) { - ConvertUtf8ToWChar(*username, UserNameW, ARRAYSIZE(UserNameW)); - ConvertUtf8ToWChar(*username, UserW, ARRAYSIZE(UserW)); + (void)ConvertUtf8ToWChar(*username, UserNameW, ARRAYSIZE(UserNameW)); + (void)ConvertUtf8ToWChar(*username, UserW, ARRAYSIZE(UserW)); } if (*password) - ConvertUtf8ToWChar(*password, PasswordW, ARRAYSIZE(PasswordW)); + (void)ConvertUtf8ToWChar(*password, PasswordW, ARRAYSIZE(PasswordW)); if (*domain) - ConvertUtf8ToWChar(*domain, DomainW, ARRAYSIZE(DomainW)); + (void)ConvertUtf8ToWChar(*domain, DomainW, ARRAYSIZE(DomainW)); if (_wcsnlen(PasswordW, ARRAYSIZE(PasswordW)) == 0) { @@ -566,9 +566,10 @@ static BOOL wf_authenticate_ex(freerdp* instance, char** username, char** passwo CHAR UserName[CREDUI_MAX_USERNAME_LENGTH + 1] = { 0 }; CHAR Domain[CREDUI_MAX_DOMAIN_TARGET_LENGTH + 1] = { 0 }; - ConvertWCharNToUtf8(UserNameW, ARRAYSIZE(UserNameW), UserName, ARRAYSIZE(UserName)); - ConvertWCharNToUtf8(UserW, ARRAYSIZE(UserW), User, ARRAYSIZE(User)); - ConvertWCharNToUtf8(DomainW, ARRAYSIZE(DomainW), Domain, ARRAYSIZE(Domain)); + (void)ConvertWCharNToUtf8(UserNameW, ARRAYSIZE(UserNameW), UserName, + ARRAYSIZE(UserName)); + (void)ConvertWCharNToUtf8(UserW, ARRAYSIZE(UserW), User, ARRAYSIZE(User)); + (void)ConvertWCharNToUtf8(DomainW, ARRAYSIZE(DomainW), Domain, ARRAYSIZE(Domain)); WLog_ERR(TAG, "Failed to parse UserName: %s into User: %s Domain: %s", UserName, User, Domain); return FALSE; diff --git a/client/common/client_cliprdr_file.c b/client/common/client_cliprdr_file.c index 84f3a292d..34cdefef3 100644 --- a/client/common/client_cliprdr_file.c +++ b/client/common/client_cliprdr_file.c @@ -2237,8 +2237,8 @@ static BOOL add_directory(CliprdrLocalStream* stream, const char* path) continue; char cFileName[MAX_PATH] = { 0 }; - ConvertWCharNToUtf8(FindFileData.cFileName, ARRAYSIZE(FindFileData.cFileName), cFileName, - ARRAYSIZE(cFileName)); + (void)ConvertWCharNToUtf8(FindFileData.cFileName, ARRAYSIZE(FindFileData.cFileName), + cFileName, ARRAYSIZE(cFileName)); free(next); next = GetCombinedPath(path, cFileName); diff --git a/client/common/cmdline.c b/client/common/cmdline.c index 263640830..00e6c7cf8 100644 --- a/client/common/cmdline.c +++ b/client/common/cmdline.c @@ -1692,8 +1692,8 @@ static void freerdp_client_print_timezone_list(void) { char TimeZoneKeyName[ARRAYSIZE(info.TimeZoneKeyName) + 1] = { 0 }; - ConvertWCharNToUtf8(info.TimeZoneKeyName, ARRAYSIZE(info.TimeZoneKeyName), TimeZoneKeyName, - ARRAYSIZE(TimeZoneKeyName)); + (void)ConvertWCharNToUtf8(info.TimeZoneKeyName, ARRAYSIZE(info.TimeZoneKeyName), + TimeZoneKeyName, ARRAYSIZE(TimeZoneKeyName)); printf("%" PRIu32 ": '%s'\n", index, TimeZoneKeyName); } } @@ -4775,8 +4775,8 @@ static int freerdp_client_settings_parse_command_line_arguments_int( char TimeZoneKeyName[ARRAYSIZE(info.TimeZoneKeyName) + 1] = { 0 }; while (EnumDynamicTimeZoneInformation(index++, &info) != ERROR_NO_MORE_ITEMS) { - ConvertWCharNToUtf8(info.TimeZoneKeyName, ARRAYSIZE(info.TimeZoneKeyName), - TimeZoneKeyName, ARRAYSIZE(TimeZoneKeyName)); + (void)ConvertWCharNToUtf8(info.TimeZoneKeyName, ARRAYSIZE(info.TimeZoneKeyName), + TimeZoneKeyName, ARRAYSIZE(TimeZoneKeyName)); WINPR_ASSERT(arg->Value); if (strncmp(TimeZoneKeyName, arg->Value, ARRAYSIZE(TimeZoneKeyName)) == 0) diff --git a/libfreerdp/core/childsession.c b/libfreerdp/core/childsession.c index cb863c36a..17a9e0b46 100644 --- a/libfreerdp/core/childsession.c +++ b/libfreerdp/core/childsession.c @@ -502,7 +502,7 @@ static BOOL createChildSessionTransport(HANDLE* pFile) memcpy(pipePath, startOfPath, 8); } - ConvertWCharNToUtf8(pipePath, 0x80, pipePathA, sizeof(pipePathA)); + (void)ConvertWCharNToUtf8(pipePath, 0x80, pipePathA, sizeof(pipePathA)); WLog_DBG(TAG, "child session is at '%s'", pipePathA); HANDLE f = CreateFileW(pipePath, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, diff --git a/libfreerdp/core/smartcardlogon.c b/libfreerdp/core/smartcardlogon.c index 95192324e..32d4bb357 100644 --- a/libfreerdp/core/smartcardlogon.c +++ b/libfreerdp/core/smartcardlogon.c @@ -547,9 +547,9 @@ out: { char cspa[128] = { 0 }; - ConvertWCharToUtf8(csp, cspa, sizeof(cspa)); + (void)ConvertWCharToUtf8(csp, cspa, sizeof(cspa)); char scopea[128] = { 0 }; - ConvertWCharToUtf8(scope, scopea, sizeof(scopea)); + (void)ConvertWCharToUtf8(scope, scopea, sizeof(scopea)); WLog_WARN(TAG, "%s [%s] no certificates found", cspa, scopea); } *pcount = count; diff --git a/libfreerdp/core/timezone.c b/libfreerdp/core/timezone.c index b16a30003..4facc0874 100644 --- a/libfreerdp/core/timezone.c +++ b/libfreerdp/core/timezone.c @@ -94,15 +94,15 @@ static void log_timezone_(const TIME_ZONE_INFORMATION* tzif, DWORD result, const wLog* log = WLog_Get(TIMEZONE_TAG); log_print(log, level, file, fkt, line, "TIME_ZONE_INFORMATION {"); log_print(log, level, file, fkt, line, " Bias=%" PRIu32, tzif->Bias); - ConvertWCharNToUtf8(tzif->StandardName, ARRAYSIZE(tzif->StandardName), buffer, - ARRAYSIZE(buffer)); + (void)ConvertWCharNToUtf8(tzif->StandardName, ARRAYSIZE(tzif->StandardName), buffer, + ARRAYSIZE(buffer)); log_print(log, level, file, fkt, line, " StandardName=%s", buffer); log_print(log, level, file, fkt, line, " StandardDate=%s", systemtime2str(&tzif->StandardDate, buffer, sizeof(buffer))); log_print(log, level, file, fkt, line, " StandardBias=%" PRIu32, tzif->StandardBias); - ConvertWCharNToUtf8(tzif->DaylightName, ARRAYSIZE(tzif->DaylightName), buffer, - ARRAYSIZE(buffer)); + (void)ConvertWCharNToUtf8(tzif->DaylightName, ARRAYSIZE(tzif->DaylightName), buffer, + ARRAYSIZE(buffer)); log_print(log, level, file, fkt, line, " DaylightName=%s", buffer); log_print(log, level, file, fkt, line, " DaylightDate=%s", systemtime2str(&tzif->DaylightDate, buffer, sizeof(buffer))); diff --git a/libfreerdp/utils/rdpdr_utils.c b/libfreerdp/utils/rdpdr_utils.c index 28cc97f29..d92d16225 100644 --- a/libfreerdp/utils/rdpdr_utils.c +++ b/libfreerdp/utils/rdpdr_utils.c @@ -325,8 +325,8 @@ static void rdpdr_dump_packet(wLog* log, DWORD lvl, wStream* s, const char* cust if (unicodeFlag == 0) Stream_Read(s, name, MIN(sizeof(name), computerNameLen)); else - ConvertWCharNToUtf8(Stream_ConstPointer(s), computerNameLen / sizeof(WCHAR), - name, sizeof(name)); + (void)ConvertWCharNToUtf8(Stream_ConstPointer(s), + computerNameLen / sizeof(WCHAR), name, sizeof(name)); } WLog_Print(log, lvl, "%s [%s | %s] [ucs:%" PRIu32 "|cp:%" PRIu32 "][len:0x%08" PRIx32 diff --git a/libfreerdp/utils/smartcard_pack.c b/libfreerdp/utils/smartcard_pack.c index e225549be..a83abf9f6 100644 --- a/libfreerdp/utils/smartcard_pack.c +++ b/libfreerdp/utils/smartcard_pack.c @@ -479,7 +479,7 @@ static void smartcard_trace_context_and_string_call_w(const char* name, return; if (sz) - ConvertWCharToUtf8(sz, tmp, ARRAYSIZE(tmp)); + (void)ConvertWCharToUtf8(sz, tmp, ARRAYSIZE(tmp)); WLog_LVL(TAG, g_LogLevel, "%s {", name); smartcard_log_context(TAG, phContext); @@ -532,7 +532,7 @@ static void smartcard_trace_get_status_change_w_call(const GetStatusChangeW_Call const LPSCARD_READERSTATEW readerState = &call->rgReaderStates[index]; char szReaderA[1024] = { 0 }; - ConvertWCharToUtf8(readerState->szReader, szReaderA, ARRAYSIZE(szReaderA)); + (void)ConvertWCharToUtf8(readerState->szReader, szReaderA, ARRAYSIZE(szReaderA)); WLog_LVL(TAG, g_LogLevel, "\t[%" PRIu32 "]: szReader: %s cbAtr: %" PRIu32 "", index, szReaderA, readerState->cbAtr); @@ -806,9 +806,9 @@ static void smartcard_trace_context_and_two_strings_w_call(const ContextAndTwoSt if (!WLog_IsLevelActive(WLog_Get(TAG), g_LogLevel)) return; if (call->sz1) - ConvertWCharToUtf8(call->sz1, sz1, ARRAYSIZE(sz1)); + (void)ConvertWCharToUtf8(call->sz1, sz1, ARRAYSIZE(sz1)); if (call->sz2) - ConvertWCharToUtf8(call->sz2, sz2, ARRAYSIZE(sz2)); + (void)ConvertWCharToUtf8(call->sz2, sz2, ARRAYSIZE(sz2)); WLog_LVL(TAG, g_LogLevel, "ContextAndTwoStringW_Call {"); smartcard_log_context(TAG, &call->handles.hContext); @@ -863,7 +863,7 @@ static void smartcard_trace_write_cache_w_call(const WriteCacheW_Call* call) WLog_LVL(TAG, g_LogLevel, "WriteCacheW_Call {"); if (call->szLookupName) - ConvertWCharToUtf8(call->szLookupName, tmp, ARRAYSIZE(tmp)); + (void)ConvertWCharToUtf8(call->szLookupName, tmp, ARRAYSIZE(tmp)); WLog_LVL(TAG, g_LogLevel, " szLookupName=%s", tmp); smartcard_log_context(TAG, &call->Common.handles.hContext); @@ -909,7 +909,7 @@ static void smartcard_trace_read_cache_w_call(const ReadCacheW_Call* call) WLog_LVL(TAG, g_LogLevel, "ReadCacheW_Call {"); if (call->szLookupName) - ConvertWCharToUtf8(call->szLookupName, tmp, ARRAYSIZE(tmp)); + (void)ConvertWCharToUtf8(call->szLookupName, tmp, ARRAYSIZE(tmp)); WLog_LVL(TAG, g_LogLevel, " szLookupName=%s", tmp); smartcard_log_context(TAG, &call->Common.handles.hContext); @@ -1011,7 +1011,7 @@ static void smartcard_trace_locate_cards_by_atr_w_call(const LocateCardsByATRW_C (const LPSCARD_READERSTATEW)&call->rgReaderStates[index]; if (readerState->szReader) - ConvertWCharToUtf8(readerState->szReader, tmp, ARRAYSIZE(tmp)); + (void)ConvertWCharToUtf8(readerState->szReader, tmp, ARRAYSIZE(tmp)); WLog_LVL(TAG, g_LogLevel, "\t[%" PRIu32 "]: szReader: %s cbAtr: %" PRIu32 "", index, tmp, readerState->cbAtr); szCurrentState = SCardGetReaderStateString(readerState->dwCurrentState); @@ -1307,7 +1307,7 @@ static void smartcard_trace_connect_w_call(const ConnectW_Call* call) return; if (call->szReader) - ConvertWCharToUtf8(call->szReader, szReaderA, ARRAYSIZE(szReaderA)); + (void)ConvertWCharToUtf8(call->szReader, szReaderA, ARRAYSIZE(szReaderA)); WLog_LVL(TAG, g_LogLevel, "ConnectW_Call {"); smartcard_log_context(TAG, &call->Common.handles.hContext); diff --git a/winpr/libwinpr/crt/string.c b/winpr/libwinpr/crt/string.c index 22b3feece..e385276f7 100644 --- a/winpr/libwinpr/crt/string.c +++ b/winpr/libwinpr/crt/string.c @@ -831,6 +831,6 @@ const WCHAR* InitializeConstWCharFromUtf8(const char* str, WCHAR* buffer, size_t { WINPR_ASSERT(str); WINPR_ASSERT(buffer || (len == 0)); - ConvertUtf8ToWChar(str, buffer, len); + (void)ConvertUtf8ToWChar(str, buffer, len); return buffer; } diff --git a/winpr/libwinpr/crt/test/TestString.c b/winpr/libwinpr/crt/test/TestString.c index cb7d0fbcd..9eda33e84 100644 --- a/winpr/libwinpr/crt/test/TestString.c +++ b/winpr/libwinpr/crt/test/TestString.c @@ -93,7 +93,8 @@ int TestString(int argc, char* argv[]) /* _wcslen */ WCHAR testStringW[ARRAYSIZE(testStringA)] = { 0 }; - ConvertUtf8NToWChar(testStringA, ARRAYSIZE(testStringA), testStringW, ARRAYSIZE(testStringW)); + (void)ConvertUtf8NToWChar(testStringA, ARRAYSIZE(testStringA), testStringW, + ARRAYSIZE(testStringW)); const size_t testStringW_Length = testStringA_Length; length = _wcslen(testStringW); @@ -143,13 +144,15 @@ int TestString(int argc, char* argv[]) /* wcstok_s */ WCHAR testDelimiterW[ARRAYSIZE(testDelimiterA)] = { 0 }; WCHAR testTokensW[ARRAYSIZE(testTokensA)] = { 0 }; - ConvertUtf8NToWChar(testTokensA, ARRAYSIZE(testTokensA), testTokensW, ARRAYSIZE(testTokensW)); - ConvertUtf8NToWChar(testDelimiterA, ARRAYSIZE(testDelimiterA), testDelimiterW, - ARRAYSIZE(testDelimiterW)); + (void)ConvertUtf8NToWChar(testTokensA, ARRAYSIZE(testTokensA), testTokensW, + ARRAYSIZE(testTokensW)); + (void)ConvertUtf8NToWChar(testDelimiterA, ARRAYSIZE(testDelimiterA), testDelimiterW, + ARRAYSIZE(testDelimiterW)); p = wcstok_s(testTokensW, testDelimiterW, &context); WCHAR testToken1W[ARRAYSIZE(testToken1A)] = { 0 }; - ConvertUtf8NToWChar(testToken1A, ARRAYSIZE(testToken1A), testToken1W, ARRAYSIZE(testToken1W)); + (void)ConvertUtf8NToWChar(testToken1A, ARRAYSIZE(testToken1A), testToken1W, + ARRAYSIZE(testToken1W)); if (memcmp(p, testToken1W, sizeof(testToken1W)) != 0) { printf("wcstok_s error: token #1 mismatch\n"); @@ -159,7 +162,8 @@ int TestString(int argc, char* argv[]) p = wcstok_s(NULL, testDelimiterW, &context); WCHAR testToken2W[ARRAYSIZE(testToken2A)] = { 0 }; - ConvertUtf8NToWChar(testToken2A, ARRAYSIZE(testToken2A), testToken2W, ARRAYSIZE(testToken2W)); + (void)ConvertUtf8NToWChar(testToken2A, ARRAYSIZE(testToken2A), testToken2W, + ARRAYSIZE(testToken2W)); if (memcmp(p, testToken2W, sizeof(testToken2W)) != 0) { printf("wcstok_s error: token #2 mismatch\n"); @@ -169,7 +173,8 @@ int TestString(int argc, char* argv[]) p = wcstok_s(NULL, testDelimiterW, &context); WCHAR testToken3W[ARRAYSIZE(testToken3A)] = { 0 }; - ConvertUtf8NToWChar(testToken3A, ARRAYSIZE(testToken3A), testToken3W, ARRAYSIZE(testToken3W)); + (void)ConvertUtf8NToWChar(testToken3A, ARRAYSIZE(testToken3A), testToken3W, + ARRAYSIZE(testToken3W)); if (memcmp(p, testToken3W, sizeof(testToken3W)) != 0) { printf("wcstok_s error: token #3 mismatch\n"); diff --git a/winpr/libwinpr/dsparse/test/TestDsMakeSpn.c b/winpr/libwinpr/dsparse/test/TestDsMakeSpn.c index dcaf6350e..91aa87923 100644 --- a/winpr/libwinpr/dsparse/test/TestDsMakeSpn.c +++ b/winpr/libwinpr/dsparse/test/TestDsMakeSpn.c @@ -76,11 +76,11 @@ static BOOL test_DsMakeSpnW(void) DWORD status = 0; DWORD SpnLength = -1; - ConvertUtf8NToWChar(ctestServiceClass, ARRAYSIZE(ctestServiceClass), testServiceClass, - ARRAYSIZE(testServiceClass)); - ConvertUtf8NToWChar(ctestServiceName, ARRAYSIZE(ctestServiceName), testServiceName, - ARRAYSIZE(testServiceName)); - ConvertUtf8NToWChar(ctestSpn, ARRAYSIZE(ctestSpn), testSpn, ARRAYSIZE(testSpn)); + (void)ConvertUtf8NToWChar(ctestServiceClass, ARRAYSIZE(ctestServiceClass), testServiceClass, + ARRAYSIZE(testServiceClass)); + (void)ConvertUtf8NToWChar(ctestServiceName, ARRAYSIZE(ctestServiceName), testServiceName, + ARRAYSIZE(testServiceName)); + (void)ConvertUtf8NToWChar(ctestSpn, ARRAYSIZE(ctestSpn), testSpn, ARRAYSIZE(testSpn)); status = DsMakeSpnW(testServiceClass, testServiceName, NULL, 0, NULL, &SpnLength, NULL); @@ -120,8 +120,8 @@ static BOOL test_DsMakeSpnW(void) char* SpnA = buffer1; char* testSpnA = buffer2; - ConvertWCharToUtf8(Spn, SpnA, ARRAYSIZE(buffer1)); - ConvertWCharToUtf8(testSpn, testSpnA, ARRAYSIZE(buffer2)); + (void)ConvertWCharToUtf8(Spn, SpnA, ARRAYSIZE(buffer1)); + (void)ConvertWCharToUtf8(testSpn, testSpnA, ARRAYSIZE(buffer2)); printf("DsMakeSpnW: SPN mismatch: Actual: %s, Expected: %s\n", SpnA, testSpnA); goto fail; } @@ -130,7 +130,7 @@ static BOOL test_DsMakeSpnW(void) char buffer[8192] = { 0 }; char* SpnA = buffer; - ConvertWCharToUtf8(Spn, SpnA, ARRAYSIZE(buffer)); + (void)ConvertWCharToUtf8(Spn, SpnA, ARRAYSIZE(buffer)); printf("DsMakeSpnW: %s\n", SpnA); } diff --git a/winpr/libwinpr/file/file.c b/winpr/libwinpr/file/file.c index 046417f4c..f43e38f26 100644 --- a/winpr/libwinpr/file/file.c +++ b/winpr/libwinpr/file/file.c @@ -1343,7 +1343,7 @@ DWORD GetFullPathNameA(LPCSTR lpFileName, DWORD nBufferLength, LPSTR lpBuffer, L dwStatus = GetFullPathNameW(lpFileNameW, nBufferLengthW, lpBufferW, &lpFilePartW); - ConvertWCharNToUtf8(lpBufferW, nBufferLengthW / sizeof(WCHAR), lpBuffer, nBufferLength); + (void)ConvertWCharNToUtf8(lpBufferW, nBufferLengthW / sizeof(WCHAR), lpBuffer, nBufferLength); if (lpFilePart) lpFilePart = lpBuffer + (lpFilePartW - lpBufferW); diff --git a/winpr/libwinpr/file/test/TestFileDeleteFile.c b/winpr/libwinpr/file/test/TestFileDeleteFile.c index 81f05997c..500693133 100644 --- a/winpr/libwinpr/file/test/TestFileDeleteFile.c +++ b/winpr/libwinpr/file/test/TestFileDeleteFile.c @@ -15,7 +15,7 @@ int TestFileDeleteFile(int argc, char* argv[]) const char invalidA[] = "/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; WCHAR invalidW[sizeof(invalidA)] = { 0 }; - ConvertUtf8NToWChar(invalidA, ARRAYSIZE(invalidA), invalidW, ARRAYSIZE(invalidW)); + (void)ConvertUtf8NToWChar(invalidA, ARRAYSIZE(invalidA), invalidW, ARRAYSIZE(invalidW)); WINPR_UNUSED(argc); WINPR_UNUSED(argv); diff --git a/winpr/libwinpr/file/test/TestFileFindFirstFile.c b/winpr/libwinpr/file/test/TestFileFindFirstFile.c index 4242f39c8..b40254840 100644 --- a/winpr/libwinpr/file/test/TestFileFindFirstFile.c +++ b/winpr/libwinpr/file/test/TestFileFindFirstFile.c @@ -264,7 +264,7 @@ static int TestFileFindFirstFileW(const char* str) WCHAR BasePath[PATHCCH_MAX_CCH] = { 0 }; - ConvertUtf8ToWChar(str, BasePath, ARRAYSIZE(BasePath)); + (void)ConvertUtf8ToWChar(str, BasePath, ARRAYSIZE(BasePath)); const size_t length = _wcsnlen(BasePath, PATHCCH_MAX_CCH - 1); @@ -275,7 +275,7 @@ static int TestFileFindFirstFileW(const char* str) NativePathCchAppendW(FilePath, PATHCCH_MAX_CCH, testFile1W); CHAR FilePathA[PATHCCH_MAX_CCH] = { 0 }; - ConvertWCharNToUtf8(FilePath, ARRAYSIZE(FilePath), FilePathA, ARRAYSIZE(FilePathA)); + (void)ConvertWCharNToUtf8(FilePath, ARRAYSIZE(FilePath), FilePathA, ARRAYSIZE(FilePathA)); printf("Finding file: %s\n", FilePathA); WIN32_FIND_DATAW FindData = { 0 }; @@ -288,8 +288,8 @@ static int TestFileFindFirstFileW(const char* str) } CHAR cFileName[MAX_PATH] = { 0 }; - ConvertWCharNToUtf8(FindData.cFileName, ARRAYSIZE(FindData.cFileName), cFileName, - ARRAYSIZE(cFileName)); + (void)ConvertWCharNToUtf8(FindData.cFileName, ARRAYSIZE(FindData.cFileName), cFileName, + ARRAYSIZE(cFileName)); printf("FindFirstFile: %s", cFileName); diff --git a/winpr/libwinpr/ncrypt/ncrypt.c b/winpr/libwinpr/ncrypt/ncrypt.c index c3fb7584e..d5b6e5f89 100644 --- a/winpr/libwinpr/ncrypt/ncrypt.c +++ b/winpr/libwinpr/ncrypt/ncrypt.c @@ -159,7 +159,7 @@ SECURITY_STATUS winpr_NCryptOpenStorageProviderEx(NCRYPT_PROV_HANDLE* phProvider return NCryptOpenP11StorageProviderEx(phProvider, pszProviderName, dwFlags, modulePaths); char buffer[128] = { 0 }; - ConvertWCharToUtf8(pszProviderName, buffer, sizeof(buffer)); + (void)ConvertWCharToUtf8(pszProviderName, buffer, sizeof(buffer)); WLog_WARN(TAG, "provider '%s' not supported", buffer); return ERROR_NOT_SUPPORTED; #else diff --git a/winpr/libwinpr/ncrypt/ncrypt_pkcs11.c b/winpr/libwinpr/ncrypt/ncrypt_pkcs11.c index 6a609d50c..8fc9aed33 100644 --- a/winpr/libwinpr/ncrypt/ncrypt_pkcs11.c +++ b/winpr/libwinpr/ncrypt/ncrypt_pkcs11.c @@ -568,8 +568,8 @@ static void wprintKeyName(LPWSTR str, CK_SLOT_ID slotId, CK_BYTE* id, CK_ULONG i for (CK_ULONG i = 0; i < idLen; i++, id++, ptr += 2) (void)snprintf(ptr, 3, "%.2x", *id); - ConvertUtf8NToWChar(asciiName, ARRAYSIZE(asciiName), str, - strnlen(asciiName, ARRAYSIZE(asciiName)) + 1); + (void)ConvertUtf8NToWChar(asciiName, ARRAYSIZE(asciiName), str, + strnlen(asciiName, ARRAYSIZE(asciiName)) + 1); } static size_t parseHex(const char* str, const char* end, CK_BYTE* target) diff --git a/winpr/libwinpr/ncrypt/test/TestNCryptProviders.c b/winpr/libwinpr/ncrypt/test/TestNCryptProviders.c index 8381e68d8..e27cf90d0 100644 --- a/winpr/libwinpr/ncrypt/test/TestNCryptProviders.c +++ b/winpr/libwinpr/ncrypt/test/TestNCryptProviders.c @@ -42,7 +42,7 @@ int TestNCryptProviders(int argc, char* argv[]) const NCryptProviderName* provider = &providers[i]; char providerNameStr[256] = { 0 }; - ConvertWCharToUtf8(provider->pszName, providerNameStr, ARRAYSIZE(providerNameStr)); + (void)ConvertWCharToUtf8(provider->pszName, providerNameStr, ARRAYSIZE(providerNameStr)); printf("%d: %s\n", i, providerNameStr); } diff --git a/winpr/libwinpr/ncrypt/test/TestNCryptSmartcard.c b/winpr/libwinpr/ncrypt/test/TestNCryptSmartcard.c index 06d81c888..34560ba2f 100644 --- a/winpr/libwinpr/ncrypt/test/TestNCryptSmartcard.c +++ b/winpr/libwinpr/ncrypt/test/TestNCryptSmartcard.c @@ -119,7 +119,7 @@ int TestNCryptSmartcard(int argc, char* argv[]) { char readerStr[1024] = { 0 }; - ConvertWCharNToUtf8(reader, cbOutput, readerStr, ARRAYSIZE(readerStr)); + (void)ConvertWCharNToUtf8(reader, cbOutput, readerStr, ARRAYSIZE(readerStr)); printf("\treader: %s\n", readerStr); } diff --git a/winpr/libwinpr/smartcard/smartcard_pcsc.c b/winpr/libwinpr/smartcard/smartcard_pcsc.c index 239f309d5..a719d269d 100644 --- a/winpr/libwinpr/smartcard/smartcard_pcsc.c +++ b/winpr/libwinpr/smartcard/smartcard_pcsc.c @@ -1658,7 +1658,7 @@ static LONG WINAPI PCSC_SCardGetStatusChangeW(SCARDCONTEXT hContext, DWORD dwTim if (!states) { - PCSC_UnlockCardContext(hContext); + (void)PCSC_UnlockCardContext(hContext); return SCARD_E_NO_MEMORY; } diff --git a/winpr/libwinpr/timezone/timezone.c b/winpr/libwinpr/timezone/timezone.c index 4348ead59..6c1a02666 100644 --- a/winpr/libwinpr/timezone/timezone.c +++ b/winpr/libwinpr/timezone/timezone.c @@ -541,11 +541,11 @@ static BOOL map_iana_id(const char* iana, LPDYNAMIC_TIME_ZONE_INFORMATION tz) const char* winDst = TimeZoneIanaToWindows(iana, TIME_ZONE_NAME_DAYLIGHT); if (winStd) - ConvertUtf8ToWChar(winStd, tz->StandardName, ARRAYSIZE(tz->StandardName)); + (void)ConvertUtf8ToWChar(winStd, tz->StandardName, ARRAYSIZE(tz->StandardName)); if (winDst) - ConvertUtf8ToWChar(winDst, tz->DaylightName, ARRAYSIZE(tz->DaylightName)); + (void)ConvertUtf8ToWChar(winDst, tz->DaylightName, ARRAYSIZE(tz->DaylightName)); if (winId) - ConvertUtf8ToWChar(winId, tz->TimeZoneKeyName, ARRAYSIZE(tz->TimeZoneKeyName)); + (void)ConvertUtf8ToWChar(winId, tz->TimeZoneKeyName, ARRAYSIZE(tz->TimeZoneKeyName)); return winId != NULL; } @@ -613,21 +613,21 @@ static void log_timezone_(const DYNAMIC_TIME_ZONE_INFORMATION* tzif, DWORD resul log_print(log, level, file, fkt, line, "DYNAMIC_TIME_ZONE_INFORMATION {"); log_print(log, level, file, fkt, line, " Bias=%" PRIu32, tzif->Bias); - ConvertWCharNToUtf8(tzif->StandardName, ARRAYSIZE(tzif->StandardName), buffer, - ARRAYSIZE(buffer)); + (void)ConvertWCharNToUtf8(tzif->StandardName, ARRAYSIZE(tzif->StandardName), buffer, + ARRAYSIZE(buffer)); log_print(log, level, file, fkt, line, " StandardName=%s", buffer); log_print(log, level, file, fkt, line, " StandardDate=%s", systemtime2str(&tzif->StandardDate, buffer, sizeof(buffer))); log_print(log, level, file, fkt, line, " StandardBias=%" PRIu32, tzif->StandardBias); - ConvertWCharNToUtf8(tzif->DaylightName, ARRAYSIZE(tzif->DaylightName), buffer, - ARRAYSIZE(buffer)); + (void)ConvertWCharNToUtf8(tzif->DaylightName, ARRAYSIZE(tzif->DaylightName), buffer, + ARRAYSIZE(buffer)); log_print(log, level, file, fkt, line, " DaylightName=%s", buffer); log_print(log, level, file, fkt, line, " DaylightDate=%s", systemtime2str(&tzif->DaylightDate, buffer, sizeof(buffer))); log_print(log, level, file, fkt, line, " DaylightBias=%" PRIu32, tzif->DaylightBias); - ConvertWCharNToUtf8(tzif->TimeZoneKeyName, ARRAYSIZE(tzif->TimeZoneKeyName), buffer, - ARRAYSIZE(buffer)); + (void)ConvertWCharNToUtf8(tzif->TimeZoneKeyName, ARRAYSIZE(tzif->TimeZoneKeyName), buffer, + ARRAYSIZE(buffer)); log_print(log, level, file, fkt, line, " TimeZoneKeyName=%s", buffer); log_print(log, level, file, fkt, line, " DynamicDaylightTimeDisabled=DST-%s", tzif->DynamicDaylightTimeDisabled ? "disabled" : "enabled"); @@ -751,7 +751,7 @@ DWORD GetDynamicTimeZoneInformation(PDYNAMIC_TIME_ZONE_INFORMATION tz) WINPR_ASSERT(tz); *tz = empty; - ConvertUtf8ToWChar(defaultName, tz->StandardName, ARRAYSIZE(tz->StandardName)); + (void)ConvertUtf8ToWChar(defaultName, tz->StandardName, ARRAYSIZE(tz->StandardName)); const time_t t = time(NULL); struct tm tres = { 0 }; @@ -858,14 +858,14 @@ DWORD EnumDynamicTimeZoneInformation(const DWORD dwIndex, return ERROR_NO_MORE_ITEMS; if (entry->DaylightName) - ConvertUtf8ToWChar(entry->DaylightName, lpTimeZoneInformation->DaylightName, - ARRAYSIZE(lpTimeZoneInformation->DaylightName)); + (void)ConvertUtf8ToWChar(entry->DaylightName, lpTimeZoneInformation->DaylightName, + ARRAYSIZE(lpTimeZoneInformation->DaylightName)); if (entry->StandardName) - ConvertUtf8ToWChar(entry->StandardName, lpTimeZoneInformation->StandardName, - ARRAYSIZE(lpTimeZoneInformation->StandardName)); + (void)ConvertUtf8ToWChar(entry->StandardName, lpTimeZoneInformation->StandardName, + ARRAYSIZE(lpTimeZoneInformation->StandardName)); if (entry->Id) - ConvertUtf8ToWChar(entry->Id, lpTimeZoneInformation->TimeZoneKeyName, - ARRAYSIZE(lpTimeZoneInformation->TimeZoneKeyName)); + (void)ConvertUtf8ToWChar(entry->Id, lpTimeZoneInformation->TimeZoneKeyName, + ARRAYSIZE(lpTimeZoneInformation->TimeZoneKeyName)); const time_t t = time(NULL); struct tm tres = { 0 }; From 965d231e49b47ae56a8f00246a1911a65c35c041 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Mon, 16 Sep 2024 04:58:36 +0200 Subject: [PATCH 10/13] [return checks] fix use of CloseHandle --- channels/ainput/server/ainput_main.c | 6 ++--- channels/audin/client/alsa/audin_alsa.c | 6 ++--- channels/audin/client/oss/audin_oss.c | 6 ++--- channels/audin/client/sndio/audin_sndio.c | 6 ++--- channels/audin/client/winmm/audin_winmm.c | 6 ++--- channels/audin/server/audin.c | 6 ++--- channels/client/addin.c | 2 +- channels/cliprdr/server/cliprdr_main.c | 6 ++--- channels/disp/server/disp_main.c | 6 ++--- channels/drdynvc/client/drdynvc_main.c | 2 +- channels/drdynvc/server/drdynvc_main.c | 4 +-- channels/drive/client/drive_file.c | 6 ++--- channels/drive/client/drive_main.c | 2 +- channels/echo/server/echo_main.c | 6 ++--- channels/encomsp/client/encomsp_main.c | 2 +- channels/encomsp/server/encomsp_main.c | 6 ++--- channels/gfxredir/server/gfxredir_main.c | 6 ++--- channels/location/server/location_main.c | 6 ++--- channels/parallel/client/parallel_main.c | 2 +- channels/printer/client/printer_main.c | 10 +++---- channels/rail/server/rail_main.c | 6 ++--- channels/rdp2tcp/client/rdp2tcp_main.c | 14 +++++----- channels/rdpdr/client/rdpdr_main.c | 8 +++--- channels/rdpdr/server/rdpdr_main.c | 6 ++--- channels/rdpecam/client/v4l/camera_v4l.c | 2 +- .../server/camera_device_enumerator_main.c | 6 ++--- channels/rdpecam/server/camera_device_main.c | 6 ++--- channels/rdpei/client/rdpei_main.c | 4 +-- channels/rdpemsc/server/mouse_cursor_main.c | 6 ++--- channels/rdpgfx/server/rdpgfx_main.c | 4 +-- channels/rdpsnd/client/rdpsnd_main.c | 2 +- channels/rdpsnd/client/winmm/rdpsnd_winmm.c | 2 +- channels/rdpsnd/server/rdpsnd_main.c | 6 ++--- channels/remdesk/client/remdesk_main.c | 2 +- channels/remdesk/server/remdesk_main.c | 6 ++--- channels/serial/client/serial_main.c | 8 +++--- channels/smartcard/client/smartcard_main.c | 4 +-- channels/sshagent/client/sshagent_main.c | 2 +- channels/telemetry/server/telemetry_main.c | 6 ++--- channels/tsmf/client/tsmf_media.c | 12 ++++----- .../urbdrc/client/libusb/libusb_udevman.c | 4 +-- .../src/main/cpp/android_cliprdr.c | 4 +-- .../freeRDPCore/src/main/cpp/android_event.c | 4 +-- client/Mac/Clipboard.m | 2 +- client/Mac/mf_client.m | 2 +- client/SDL/SDL2/sdl_utils.cpp | 2 +- client/SDL/SDL3/sdl_clip.cpp | 2 +- client/SDL/SDL3/sdl_utils.cpp | 2 +- client/Wayland/wlfreerdp.c | 4 +-- client/Windows/wf_client.c | 2 +- client/Windows/wf_cliprdr.c | 8 +++--- client/X11/xf_client.c | 8 +++--- client/common/client.c | 2 +- client/common/client_cliprdr_file.c | 8 +++--- client/iOS/FreeRDP/ios_cliprdr.m | 4 +-- client/iOS/FreeRDP/ios_freerdp_events.m | 2 +- libfreerdp/core/childsession.c | 6 ++--- libfreerdp/core/freerdp.c | 2 +- libfreerdp/core/gateway/rpc_client.c | 2 +- libfreerdp/core/listener.c | 2 +- libfreerdp/core/message.c | 2 +- libfreerdp/core/peer.c | 2 +- libfreerdp/core/rdp.c | 2 +- libfreerdp/core/tcp.c | 6 ++--- libfreerdp/core/test/TestConnect.c | 18 ++++++------- libfreerdp/core/transport.c | 6 ++--- libfreerdp/utils/smartcard_call.c | 2 +- server/Sample/sfreerdp.c | 6 ++--- server/Windows/wf_directsound.c | 2 +- server/Windows/wf_info.c | 16 ++++++------ server/Windows/wf_peer.c | 6 ++--- server/Windows/wf_wasapi.c | 2 +- server/proxy/pf_context.c | 8 +++--- server/proxy/pf_server.c | 6 ++--- server/shadow/Win/win_rdp.c | 4 +-- server/shadow/X11/x11_shadow.c | 4 +-- server/shadow/shadow_client.c | 2 +- server/shadow/shadow_mcevent.c | 12 ++++----- server/shadow/shadow_server.c | 4 +-- winpr/libwinpr/clipboard/synthetic_file.c | 2 +- winpr/libwinpr/comm/comm.c | 3 +-- winpr/libwinpr/comm/test/TestCommConfig.c | 2 +- winpr/libwinpr/comm/test/TestCommMonitor.c | 2 +- .../error/test/TestErrorSetLastError.c | 8 +++--- .../file/test/TestFileFindFirstFile.c | 4 +-- .../libwinpr/file/test/TestFileGetStdHandle.c | 2 +- .../file/test/TestSetFileAttributes.c | 4 +-- winpr/libwinpr/interlocked/interlocked.c | 2 +- .../pipe/test/TestPipeCreateNamedPipe.c | 26 +++++++++---------- .../test/TestPipeCreateNamedPipeOverlapped.c | 14 +++++----- winpr/libwinpr/pipe/test/TestPipeCreatePipe.c | 4 +-- winpr/libwinpr/pool/pool.c | 6 ++--- winpr/libwinpr/smartcard/smartcard_pcsc.c | 4 +-- winpr/libwinpr/synch/barrier.c | 6 ++--- winpr/libwinpr/synch/test/TestSynchAPC.c | 10 +++---- winpr/libwinpr/synch/test/TestSynchCritical.c | 6 ++--- winpr/libwinpr/synch/test/TestSynchEvent.c | 2 +- winpr/libwinpr/synch/test/TestSynchInit.c | 4 +-- winpr/libwinpr/synch/test/TestSynchMutex.c | 16 ++++++------ .../libwinpr/synch/test/TestSynchSemaphore.c | 2 +- .../libwinpr/synch/test/TestSynchTimerQueue.c | 2 +- .../synch/test/TestSynchWaitableTimer.c | 2 +- .../synch/test/TestSynchWaitableTimerAPC.c | 4 +-- .../thread/test/TestThreadCreateProcess.c | 16 ++++++------ .../thread/test/TestThreadExitThread.c | 2 +- .../utils/collections/CountdownEvent.c | 2 +- .../libwinpr/utils/collections/MessageQueue.c | 2 +- winpr/libwinpr/utils/collections/Queue.c | 2 +- winpr/libwinpr/utils/ssl.c | 6 ++--- winpr/libwinpr/utils/test/TestMessagePipe.c | 4 +-- winpr/libwinpr/utils/test/TestMessageQueue.c | 2 +- winpr/libwinpr/winsock/winsock.c | 3 +-- winpr/libwinpr/wtsapi/wtsapi_win32.c | 6 ++--- 113 files changed, 288 insertions(+), 290 deletions(-) diff --git a/channels/ainput/server/ainput_main.c b/channels/ainput/server/ainput_main.c index 7cbbdb29e..5659d5163 100644 --- a/channels/ainput/server/ainput_main.c +++ b/channels/ainput/server/ainput_main.c @@ -327,7 +327,7 @@ static UINT ainput_server_open(ainput_server_context* context) if (!ainput->thread) { WLog_ERR(TAG, "CreateEvent failed!"); - CloseHandle(ainput->stopEvent); + (void)CloseHandle(ainput->stopEvent); ainput->stopEvent = NULL; return ERROR_INTERNAL_ERROR; } @@ -360,8 +360,8 @@ static UINT ainput_server_close(ainput_server_context* context) return error; } - CloseHandle(ainput->thread); - CloseHandle(ainput->stopEvent); + (void)CloseHandle(ainput->thread); + (void)CloseHandle(ainput->stopEvent); ainput->thread = NULL; ainput->stopEvent = NULL; } diff --git a/channels/audin/client/alsa/audin_alsa.c b/channels/audin/client/alsa/audin_alsa.c index e82662451..e81ec63a5 100644 --- a/channels/audin/client/alsa/audin_alsa.c +++ b/channels/audin/client/alsa/audin_alsa.c @@ -302,7 +302,7 @@ static UINT audin_alsa_open(IAudinDevice* device, AudinReceive receive, void* us return CHANNEL_RC_OK; error_out: - CloseHandle(alsa->stopEvent); + (void)CloseHandle(alsa->stopEvent); alsa->stopEvent = NULL; return ERROR_INTERNAL_ERROR; } @@ -332,9 +332,9 @@ static UINT audin_alsa_close(IAudinDevice* device) return error; } - CloseHandle(alsa->stopEvent); + (void)CloseHandle(alsa->stopEvent); alsa->stopEvent = NULL; - CloseHandle(alsa->thread); + (void)CloseHandle(alsa->thread); alsa->thread = NULL; } diff --git a/channels/audin/client/oss/audin_oss.c b/channels/audin/client/oss/audin_oss.c index b9db46a88..7ffc0cdbc 100644 --- a/channels/audin/client/oss/audin_oss.c +++ b/channels/audin/client/oss/audin_oss.c @@ -309,7 +309,7 @@ static UINT audin_oss_open(IAudinDevice* device, AudinReceive receive, void* use if (!(oss->thread = CreateThread(NULL, 0, audin_oss_thread_func, oss, 0, NULL))) { WLog_ERR(TAG, "CreateThread failed!"); - CloseHandle(oss->stopEvent); + (void)CloseHandle(oss->stopEvent); oss->stopEvent = NULL; return ERROR_INTERNAL_ERROR; } @@ -341,9 +341,9 @@ static UINT audin_oss_close(IAudinDevice* device) return error; } - CloseHandle(oss->stopEvent); + (void)CloseHandle(oss->stopEvent); oss->stopEvent = NULL; - CloseHandle(oss->thread); + (void)CloseHandle(oss->thread); oss->thread = NULL; } diff --git a/channels/audin/client/sndio/audin_sndio.c b/channels/audin/client/sndio/audin_sndio.c index 291b16d20..af5426e72 100644 --- a/channels/audin/client/sndio/audin_sndio.c +++ b/channels/audin/client/sndio/audin_sndio.c @@ -204,7 +204,7 @@ static UINT audin_sndio_open(IAudinDevice* device, AudinReceive receive, void* u sndio, 0, NULL))) { WLog_ERR(TAG, "CreateThread failed"); - CloseHandle(sndio->stopEvent); + (void)CloseHandle(sndio->stopEvent); sndio->stopEvent = NULL; return ERROR_INTERNAL_ERROR; } @@ -236,9 +236,9 @@ static UINT audin_sndio_close(IAudinDevice* device) return error; } - CloseHandle(sndio->stopEvent); + (void)CloseHandle(sndio->stopEvent); sndio->stopEvent = NULL; - CloseHandle(sndio->thread); + (void)CloseHandle(sndio->thread); sndio->thread = NULL; } diff --git a/channels/audin/client/winmm/audin_winmm.c b/channels/audin/client/winmm/audin_winmm.c index c94e41a34..daa59254f 100644 --- a/channels/audin/client/winmm/audin_winmm.c +++ b/channels/audin/client/winmm/audin_winmm.c @@ -304,8 +304,8 @@ static UINT audin_winmm_close(IAudinDevice* device) return error; } - CloseHandle(winmm->thread); - CloseHandle(winmm->stopEvent); + (void)CloseHandle(winmm->thread); + (void)CloseHandle(winmm->stopEvent); winmm->thread = NULL; winmm->stopEvent = NULL; winmm->receive = NULL; @@ -436,7 +436,7 @@ static UINT audin_winmm_open(IAudinDevice* device, AudinReceive receive, void* u if (!(winmm->thread = CreateThread(NULL, 0, audin_winmm_thread_func, winmm, 0, NULL))) { WLog_Print(winmm->log, WLOG_ERROR, "CreateThread failed!"); - CloseHandle(winmm->stopEvent); + (void)CloseHandle(winmm->stopEvent); winmm->stopEvent = NULL; return ERROR_INTERNAL_ERROR; } diff --git a/channels/audin/server/audin.c b/channels/audin/server/audin.c index a898fff1c..0726632a8 100644 --- a/channels/audin/server/audin.c +++ b/channels/audin/server/audin.c @@ -489,7 +489,7 @@ static BOOL audin_server_open(audin_server_context* context) CreateThread(NULL, 0, audin_server_thread_func, (void*)audin, 0, NULL))) { WLog_Print(audin->log, WLOG_ERROR, "CreateThread failed!"); - CloseHandle(audin->stopEvent); + (void)CloseHandle(audin->stopEvent); audin->stopEvent = NULL; return FALSE; } @@ -525,8 +525,8 @@ static BOOL audin_server_close(audin_server_context* context) return FALSE; } - CloseHandle(audin->thread); - CloseHandle(audin->stopEvent); + (void)CloseHandle(audin->thread); + (void)CloseHandle(audin->stopEvent); audin->thread = NULL; audin->stopEvent = NULL; } diff --git a/channels/client/addin.c b/channels/client/addin.c index 76d96b215..4b9bf624b 100644 --- a/channels/client/addin.c +++ b/channels/client/addin.c @@ -594,7 +594,7 @@ static void channel_client_handler_free(msg_proc_internals* internals) return; if (internals->thread) - CloseHandle(internals->thread); + (void)CloseHandle(internals->thread); MessageQueue_Free(internals->queue); Stream_Free(internals->data_in, TRUE); free(internals->channel_name); diff --git a/channels/cliprdr/server/cliprdr_main.c b/channels/cliprdr/server/cliprdr_main.c index a14b5a45f..8e374eb20 100644 --- a/channels/cliprdr/server/cliprdr_main.c +++ b/channels/cliprdr/server/cliprdr_main.c @@ -1395,7 +1395,7 @@ static UINT cliprdr_server_start(CliprdrServerContext* context) if (!(cliprdr->Thread = CreateThread(NULL, 0, cliprdr_server_thread, (void*)context, 0, NULL))) { WLog_ERR(TAG, "CreateThread failed!"); - CloseHandle(cliprdr->StopEvent); + (void)CloseHandle(cliprdr->StopEvent); cliprdr->StopEvent = NULL; return ERROR_INTERNAL_ERROR; } @@ -1429,8 +1429,8 @@ static UINT cliprdr_server_stop(CliprdrServerContext* context) return error; } - CloseHandle(cliprdr->Thread); - CloseHandle(cliprdr->StopEvent); + (void)CloseHandle(cliprdr->Thread); + (void)CloseHandle(cliprdr->StopEvent); } if (cliprdr->ChannelHandle) diff --git a/channels/disp/server/disp_main.c b/channels/disp/server/disp_main.c index 49920e682..620cf8cd0 100644 --- a/channels/disp/server/disp_main.c +++ b/channels/disp/server/disp_main.c @@ -465,7 +465,7 @@ static UINT disp_server_open(DispServerContext* context) CreateThread(NULL, 0, disp_server_thread_func, (void*)context, 0, NULL))) { WLog_ERR(TAG, "CreateEvent failed!"); - CloseHandle(priv->stopEvent); + (void)CloseHandle(priv->stopEvent); priv->stopEvent = NULL; rc = ERROR_INTERNAL_ERROR; goto out_close; @@ -559,8 +559,8 @@ static UINT disp_server_close(DispServerContext* context) return error; } - CloseHandle(priv->thread); - CloseHandle(priv->stopEvent); + (void)CloseHandle(priv->thread); + (void)CloseHandle(priv->stopEvent); priv->thread = NULL; priv->stopEvent = NULL; } diff --git a/channels/drdynvc/client/drdynvc_main.c b/channels/drdynvc/client/drdynvc_main.c index 0ca38887e..4fb9f800e 100644 --- a/channels/drdynvc/client/drdynvc_main.c +++ b/channels/drdynvc/client/drdynvc_main.c @@ -1770,7 +1770,7 @@ static UINT drdynvc_virtual_channel_event_disconnected(drdynvcPlugin* drdynvc) return status; } - CloseHandle(drdynvc->thread); + (void)CloseHandle(drdynvc->thread); drdynvc->thread = NULL; } else diff --git a/channels/drdynvc/server/drdynvc_main.c b/channels/drdynvc/server/drdynvc_main.c index e6c951549..67cf6a5c4 100644 --- a/channels/drdynvc/server/drdynvc_main.c +++ b/channels/drdynvc/server/drdynvc_main.c @@ -138,7 +138,7 @@ static UINT drdynvc_server_start(DrdynvcServerContext* context) CreateThread(NULL, 0, drdynvc_server_thread, (void*)context, 0, NULL))) { WLog_ERR(TAG, "CreateThread failed!"); - CloseHandle(context->priv->StopEvent); + (void)CloseHandle(context->priv->StopEvent); context->priv->StopEvent = NULL; return ERROR_INTERNAL_ERROR; } @@ -163,7 +163,7 @@ static UINT drdynvc_server_stop(DrdynvcServerContext* context) return error; } - CloseHandle(context->priv->Thread); + (void)CloseHandle(context->priv->Thread); return CHANNEL_RC_OK; } diff --git a/channels/drive/client/drive_file.c b/channels/drive/client/drive_file.c index fef202687..840d9163b 100644 --- a/channels/drive/client/drive_file.c +++ b/channels/drive/client/drive_file.c @@ -361,7 +361,7 @@ BOOL drive_file_free(DRIVE_FILE* file) if (file->file_handle != INVALID_HANDLE_VALUE) { - CloseHandle(file->file_handle); + (void)CloseHandle(file->file_handle); file->file_handle = INVALID_HANDLE_VALUE; } @@ -585,7 +585,7 @@ BOOL drive_file_query_information(DRIVE_FILE* file, UINT32 FsInformationClass, w if (hFile != INVALID_HANDLE_VALUE) { status = GetFileInformationByHandle(hFile, &fileInformation); - CloseHandle(hFile); + (void)CloseHandle(hFile); if (!status) goto out_fail; @@ -790,7 +790,7 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN if (file->file_handle != INVALID_HANDLE_VALUE) { - CloseHandle(file->file_handle); + (void)CloseHandle(file->file_handle); file->file_handle = INVALID_HANDLE_VALUE; } diff --git a/channels/drive/client/drive_main.c b/channels/drive/client/drive_main.c index 089ea2cb7..b85fc7e24 100644 --- a/channels/drive/client/drive_main.c +++ b/channels/drive/client/drive_main.c @@ -822,7 +822,7 @@ static UINT drive_free_int(DRIVE_DEVICE* drive) if (!drive) return ERROR_INVALID_PARAMETER; - CloseHandle(drive->thread); + (void)CloseHandle(drive->thread); ListDictionary_Free(drive->files); MessageQueue_Free(drive->IrpQueue); Stream_Free(drive->device.data, TRUE); diff --git a/channels/echo/server/echo_main.c b/channels/echo/server/echo_main.c index 1eb416cda..52a4fa678 100644 --- a/channels/echo/server/echo_main.c +++ b/channels/echo/server/echo_main.c @@ -307,7 +307,7 @@ static UINT echo_server_open(echo_server_context* context) if (!(echo->thread = CreateThread(NULL, 0, echo_server_thread_func, (void*)echo, 0, NULL))) { WLog_ERR(TAG, "CreateEvent failed!"); - CloseHandle(echo->stopEvent); + (void)CloseHandle(echo->stopEvent); echo->stopEvent = NULL; return ERROR_INTERNAL_ERROR; } @@ -337,8 +337,8 @@ static UINT echo_server_close(echo_server_context* context) return error; } - CloseHandle(echo->thread); - CloseHandle(echo->stopEvent); + (void)CloseHandle(echo->thread); + (void)CloseHandle(echo->stopEvent); echo->thread = NULL; echo->stopEvent = NULL; } diff --git a/channels/encomsp/client/encomsp_main.c b/channels/encomsp/client/encomsp_main.c index a4fe9888e..e725872f7 100644 --- a/channels/encomsp/client/encomsp_main.c +++ b/channels/encomsp/client/encomsp_main.c @@ -1137,7 +1137,7 @@ static UINT encomsp_virtual_channel_event_disconnected(encomspPlugin* encomsp) } MessageQueue_Free(encomsp->queue); - CloseHandle(encomsp->thread); + (void)CloseHandle(encomsp->thread); encomsp->queue = NULL; encomsp->thread = NULL; diff --git a/channels/encomsp/server/encomsp_main.c b/channels/encomsp/server/encomsp_main.c index 009e2d9e0..2122bcb8f 100644 --- a/channels/encomsp/server/encomsp_main.c +++ b/channels/encomsp/server/encomsp_main.c @@ -311,7 +311,7 @@ static UINT encomsp_server_start(EncomspServerContext* context) CreateThread(NULL, 0, encomsp_server_thread, (void*)context, 0, NULL))) { WLog_ERR(TAG, "CreateThread failed!"); - CloseHandle(context->priv->StopEvent); + (void)CloseHandle(context->priv->StopEvent); context->priv->StopEvent = NULL; return ERROR_INTERNAL_ERROR; } @@ -336,8 +336,8 @@ static UINT encomsp_server_stop(EncomspServerContext* context) return error; } - CloseHandle(context->priv->Thread); - CloseHandle(context->priv->StopEvent); + (void)CloseHandle(context->priv->Thread); + (void)CloseHandle(context->priv->StopEvent); return error; } diff --git a/channels/gfxredir/server/gfxredir_main.c b/channels/gfxredir/server/gfxredir_main.c index 3b398a167..0d1b0371b 100644 --- a/channels/gfxredir/server/gfxredir_main.c +++ b/channels/gfxredir/server/gfxredir_main.c @@ -679,7 +679,7 @@ static UINT gfxredir_server_open(GfxRedirServerContext* context) CreateThread(NULL, 0, gfxredir_server_thread_func, (void*)context, 0, NULL))) { WLog_ERR(TAG, "CreateEvent failed!"); - CloseHandle(priv->stopEvent); + (void)CloseHandle(priv->stopEvent); priv->stopEvent = NULL; rc = ERROR_INTERNAL_ERROR; } @@ -714,8 +714,8 @@ static UINT gfxredir_server_close(GfxRedirServerContext* context) return error; } - CloseHandle(priv->thread); - CloseHandle(priv->stopEvent); + (void)CloseHandle(priv->thread); + (void)CloseHandle(priv->stopEvent); priv->thread = NULL; priv->stopEvent = NULL; } diff --git a/channels/location/server/location_main.c b/channels/location/server/location_main.c index 3f2e06d26..93f8cf339 100644 --- a/channels/location/server/location_main.c +++ b/channels/location/server/location_main.c @@ -456,7 +456,7 @@ static UINT location_server_open(LocationServerContext* context) if (!location->thread) { WLog_ERR(TAG, "CreateThread failed!"); - CloseHandle(location->stopEvent); + (void)CloseHandle(location->stopEvent); location->stopEvent = NULL; return ERROR_INTERNAL_ERROR; } @@ -484,8 +484,8 @@ static UINT location_server_close(LocationServerContext* context) return error; } - CloseHandle(location->thread); - CloseHandle(location->stopEvent); + (void)CloseHandle(location->thread); + (void)CloseHandle(location->stopEvent); location->thread = NULL; location->stopEvent = NULL; } diff --git a/channels/parallel/client/parallel_main.c b/channels/parallel/client/parallel_main.c index 1eb2320f6..c459a77d9 100644 --- a/channels/parallel/client/parallel_main.c +++ b/channels/parallel/client/parallel_main.c @@ -395,7 +395,7 @@ static UINT parallel_free_int(PARALLEL_DEVICE* parallel) "WaitForSingleObject failed with error %" PRIu32 "!", error); } - CloseHandle(parallel->thread); + (void)CloseHandle(parallel->thread); Stream_Free(parallel->device.data, TRUE); MessageQueue_Free(parallel->queue); } diff --git a/channels/printer/client/printer_main.c b/channels/printer/client/printer_main.c index 40cfeda70..fda39541f 100644 --- a/channels/printer/client/printer_main.c +++ b/channels/printer/client/printer_main.c @@ -139,7 +139,7 @@ static BOOL printer_write_setting(const char* path, prn_conf_t type, const void* rc = TRUE; fail: - CloseHandle(file); + (void)CloseHandle(file); free(base64); return rc; } @@ -194,7 +194,7 @@ static BOOL printer_read_setting(const char* path, prn_conf_t type, void** data, } fail: - CloseHandle(file); + (void)CloseHandle(file); if (rc && (lowSize <= INT_MAX)) { @@ -929,9 +929,9 @@ static UINT printer_free(DEVICE* device) irp->Discard(irp); } - CloseHandle(printer_dev->thread); - CloseHandle(printer_dev->stopEvent); - CloseHandle(printer_dev->event); + (void)CloseHandle(printer_dev->thread); + (void)CloseHandle(printer_dev->stopEvent); + (void)CloseHandle(printer_dev->event); winpr_aligned_free(printer_dev->pIrpList); } diff --git a/channels/rail/server/rail_main.c b/channels/rail/server/rail_main.c index fb76e5f44..428178db6 100644 --- a/channels/rail/server/rail_main.c +++ b/channels/rail/server/rail_main.c @@ -1459,7 +1459,7 @@ static UINT rail_server_start(RailServerContext* context) return CHANNEL_RC_OK; out_stop_event: - CloseHandle(context->priv->stopEvent); + (void)CloseHandle(context->priv->stopEvent); context->priv->stopEvent = NULL; out_close: (void)WTSVirtualChannelClose(context->priv->rail_channel); @@ -1481,8 +1481,8 @@ static BOOL rail_server_stop(RailServerContext* context) return FALSE; } - CloseHandle(priv->thread); - CloseHandle(priv->stopEvent); + (void)CloseHandle(priv->thread); + (void)CloseHandle(priv->stopEvent); priv->thread = NULL; priv->stopEvent = NULL; } diff --git a/channels/rdp2tcp/client/rdp2tcp_main.c b/channels/rdp2tcp/client/rdp2tcp_main.c index ac966c1e5..e59adf47b 100644 --- a/channels/rdp2tcp/client/rdp2tcp_main.c +++ b/channels/rdp2tcp/client/rdp2tcp_main.c @@ -103,9 +103,9 @@ static int init_external_addin(Plugin* plugin) } plugin->hProcess = procInfo.hProcess; - CloseHandle(procInfo.hThread); - CloseHandle(siStartInfo.hStdOutput); - CloseHandle(siStartInfo.hStdInput); + (void)CloseHandle(procInfo.hThread); + (void)CloseHandle(siStartInfo.hStdOutput); + (void)CloseHandle(siStartInfo.hStdInput); return 0; } @@ -263,12 +263,12 @@ static void channel_terminated(Plugin* plugin) if (plugin->copyThread) (void)TerminateThread(plugin->copyThread, 0); if (plugin->writeComplete) - CloseHandle(plugin->writeComplete); + (void)CloseHandle(plugin->writeComplete); - CloseHandle(plugin->hStdInputWrite); - CloseHandle(plugin->hStdOutputRead); + (void)CloseHandle(plugin->hStdInputWrite); + (void)CloseHandle(plugin->hStdOutputRead); TerminateProcess(plugin->hProcess, 0); - CloseHandle(plugin->hProcess); + (void)CloseHandle(plugin->hProcess); free(plugin->commandline); free(plugin); } diff --git a/channels/rdpdr/client/rdpdr_main.c b/channels/rdpdr/client/rdpdr_main.c index dbfebc343..9788736da 100644 --- a/channels/rdpdr/client/rdpdr_main.c +++ b/channels/rdpdr/client/rdpdr_main.c @@ -706,7 +706,7 @@ static DWORD WINAPI drive_hotplug_thread_func(LPVOID arg) out: if (rdpdr->stopEvent) { - CloseHandle(rdpdr->stopEvent); + (void)CloseHandle(rdpdr->stopEvent); rdpdr->stopEvent = NULL; } ExitThread(CHANNEL_RC_OK); @@ -1083,7 +1083,7 @@ out: if (rdpdr->stopEvent) { - CloseHandle(rdpdr->stopEvent); + (void)CloseHandle(rdpdr->stopEvent); rdpdr->stopEvent = NULL; } @@ -1123,7 +1123,7 @@ static UINT drive_hotplug_thread_terminate(rdpdrPlugin* rdpdr) return error; } - CloseHandle(rdpdr->hotplugThread); + (void)CloseHandle(rdpdr->hotplugThread); rdpdr->hotplugThread = NULL; } @@ -2193,7 +2193,7 @@ static UINT rdpdr_virtual_channel_event_disconnected(rdpdrPlugin* rdpdr) } if (rdpdr->thread) - CloseHandle(rdpdr->thread); + (void)CloseHandle(rdpdr->thread); MessageQueue_Free(rdpdr->queue); rdpdr->queue = NULL; rdpdr->thread = NULL; diff --git a/channels/rdpdr/server/rdpdr_main.c b/channels/rdpdr/server/rdpdr_main.c index 6d1c690ba..e0fde30a2 100644 --- a/channels/rdpdr/server/rdpdr_main.c +++ b/channels/rdpdr/server/rdpdr_main.c @@ -2147,7 +2147,7 @@ static UINT rdpdr_server_start(RdpdrServerContext* context) CreateThread(NULL, 0, rdpdr_server_thread, (void*)context, 0, NULL))) { WLog_Print(context->priv->log, WLOG_ERROR, "CreateThread failed!"); - CloseHandle(context->priv->StopEvent); + (void)CloseHandle(context->priv->StopEvent); context->priv->StopEvent = NULL; return ERROR_INTERNAL_ERROR; } @@ -2178,9 +2178,9 @@ static UINT rdpdr_server_stop(RdpdrServerContext* context) return error; } - CloseHandle(context->priv->Thread); + (void)CloseHandle(context->priv->Thread); context->priv->Thread = NULL; - CloseHandle(context->priv->StopEvent); + (void)CloseHandle(context->priv->StopEvent); context->priv->StopEvent = NULL; } diff --git a/channels/rdpecam/client/v4l/camera_v4l.c b/channels/rdpecam/client/v4l/camera_v4l.c index e27bd4b74..601ba083e 100644 --- a/channels/rdpecam/client/v4l/camera_v4l.c +++ b/channels/rdpecam/client/v4l/camera_v4l.c @@ -531,7 +531,7 @@ UINT cam_v4l_stream_stop(CamV4lStream* stream) if (stream->captureThread) { WaitForSingleObject(stream->captureThread, INFINITE); - CloseHandle(stream->captureThread); + (void)CloseHandle(stream->captureThread); stream->captureThread = NULL; } diff --git a/channels/rdpecam/server/camera_device_enumerator_main.c b/channels/rdpecam/server/camera_device_enumerator_main.c index 89fb75782..57e6c61d5 100644 --- a/channels/rdpecam/server/camera_device_enumerator_main.c +++ b/channels/rdpecam/server/camera_device_enumerator_main.c @@ -449,7 +449,7 @@ static UINT enumerator_server_open(CamDevEnumServerContext* context) if (!enumerator->thread) { WLog_ERR(TAG, "CreateThread failed!"); - CloseHandle(enumerator->stopEvent); + (void)CloseHandle(enumerator->stopEvent); enumerator->stopEvent = NULL; return ERROR_INTERNAL_ERROR; } @@ -477,8 +477,8 @@ static UINT enumerator_server_close(CamDevEnumServerContext* context) return error; } - CloseHandle(enumerator->thread); - CloseHandle(enumerator->stopEvent); + (void)CloseHandle(enumerator->thread); + (void)CloseHandle(enumerator->stopEvent); enumerator->thread = NULL; enumerator->stopEvent = NULL; } diff --git a/channels/rdpecam/server/camera_device_main.c b/channels/rdpecam/server/camera_device_main.c index 1b1915f97..555c39a3f 100644 --- a/channels/rdpecam/server/camera_device_main.c +++ b/channels/rdpecam/server/camera_device_main.c @@ -601,7 +601,7 @@ static UINT device_server_open(CameraDeviceServerContext* context) if (!device->thread) { WLog_ERR(TAG, "CreateThread failed!"); - CloseHandle(device->stopEvent); + (void)CloseHandle(device->stopEvent); device->stopEvent = NULL; return ERROR_INTERNAL_ERROR; } @@ -629,8 +629,8 @@ static UINT device_server_close(CameraDeviceServerContext* context) return error; } - CloseHandle(device->thread); - CloseHandle(device->stopEvent); + (void)CloseHandle(device->thread); + (void)CloseHandle(device->stopEvent); device->thread = NULL; device->stopEvent = NULL; } diff --git a/channels/rdpei/client/rdpei_main.c b/channels/rdpei/client/rdpei_main.c index 8a3e06109..4adb700d5 100644 --- a/channels/rdpei/client/rdpei_main.c +++ b/channels/rdpei/client/rdpei_main.c @@ -1447,11 +1447,11 @@ static void terminate_plugin_cb(GENERIC_DYNVC_PLUGIN* base) if (rdpei->thread) { WaitForSingleObject(rdpei->thread, INFINITE); - CloseHandle(rdpei->thread); + (void)CloseHandle(rdpei->thread); } if (rdpei->event) - CloseHandle(rdpei->event); + (void)CloseHandle(rdpei->event); DeleteCriticalSection(&rdpei->lock); free(rdpei->context); diff --git a/channels/rdpemsc/server/mouse_cursor_main.c b/channels/rdpemsc/server/mouse_cursor_main.c index 8e8aa899a..747bc77ef 100644 --- a/channels/rdpemsc/server/mouse_cursor_main.c +++ b/channels/rdpemsc/server/mouse_cursor_main.c @@ -406,7 +406,7 @@ static UINT mouse_cursor_server_open(MouseCursorServerContext* context) if (!mouse_cursor->thread) { WLog_ERR(TAG, "CreateThread failed!"); - CloseHandle(mouse_cursor->stopEvent); + (void)CloseHandle(mouse_cursor->stopEvent); mouse_cursor->stopEvent = NULL; return ERROR_INTERNAL_ERROR; } @@ -434,8 +434,8 @@ static UINT mouse_cursor_server_close(MouseCursorServerContext* context) return error; } - CloseHandle(mouse_cursor->thread); - CloseHandle(mouse_cursor->stopEvent); + (void)CloseHandle(mouse_cursor->thread); + (void)CloseHandle(mouse_cursor->stopEvent); mouse_cursor->thread = NULL; mouse_cursor->stopEvent = NULL; } diff --git a/channels/rdpgfx/server/rdpgfx_main.c b/channels/rdpgfx/server/rdpgfx_main.c index d9a92499b..2dc76b6cf 100644 --- a/channels/rdpgfx/server/rdpgfx_main.c +++ b/channels/rdpgfx/server/rdpgfx_main.c @@ -1638,8 +1638,8 @@ BOOL rdpgfx_server_close(RdpgfxServerContext* context) return FALSE; } - CloseHandle(priv->thread); - CloseHandle(priv->stopEvent); + (void)CloseHandle(priv->thread); + (void)CloseHandle(priv->stopEvent); priv->thread = NULL; priv->stopEvent = NULL; } diff --git a/channels/rdpsnd/client/rdpsnd_main.c b/channels/rdpsnd/client/rdpsnd_main.c index f87ab007c..6efefbeea 100644 --- a/channels/rdpsnd/client/rdpsnd_main.c +++ b/channels/rdpsnd/client/rdpsnd_main.c @@ -1462,7 +1462,7 @@ void rdpsnd_virtual_channel_event_terminated(rdpsndPlugin* rdpsnd) if (rdpsnd->thread) { WaitForSingleObject(rdpsnd->thread, INFINITE); - CloseHandle(rdpsnd->thread); + (void)CloseHandle(rdpsnd->thread); } MessageQueue_Free(rdpsnd->queue); diff --git a/channels/rdpsnd/client/winmm/rdpsnd_winmm.c b/channels/rdpsnd/client/winmm/rdpsnd_winmm.c index 205a6cb2d..6a39aebbb 100644 --- a/channels/rdpsnd/client/winmm/rdpsnd_winmm.c +++ b/channels/rdpsnd/client/winmm/rdpsnd_winmm.c @@ -181,7 +181,7 @@ static void rdpsnd_winmm_close(rdpsndDevicePlugin* device) if (winmm->hThread) { WaitForSingleObject(winmm->hThread, INFINITE); - CloseHandle(winmm->hThread); + (void)CloseHandle(winmm->hThread); winmm->hThread = NULL; } } diff --git a/channels/rdpsnd/server/rdpsnd_main.c b/channels/rdpsnd/server/rdpsnd_main.c index d7b498ddd..436060e84 100644 --- a/channels/rdpsnd/server/rdpsnd_main.c +++ b/channels/rdpsnd/server/rdpsnd_main.c @@ -957,7 +957,7 @@ static UINT rdpsnd_server_start(RdpsndServerContext* context) return CHANNEL_RC_OK; out_stopEvent: - CloseHandle(context->priv->StopEvent); + (void)CloseHandle(context->priv->StopEvent); context->priv->StopEvent = NULL; out_lock: DeleteCriticalSection(&context->priv->lock); @@ -998,8 +998,8 @@ static UINT rdpsnd_server_stop(RdpsndServerContext* context) return error; } - CloseHandle(context->priv->Thread); - CloseHandle(context->priv->StopEvent); + (void)CloseHandle(context->priv->Thread); + (void)CloseHandle(context->priv->StopEvent); context->priv->Thread = NULL; context->priv->StopEvent = NULL; } diff --git a/channels/remdesk/client/remdesk_main.c b/channels/remdesk/client/remdesk_main.c index 978f5c6e2..837f69dcc 100644 --- a/channels/remdesk/client/remdesk_main.c +++ b/channels/remdesk/client/remdesk_main.c @@ -970,7 +970,7 @@ static UINT remdesk_virtual_channel_event_disconnected(remdeskPlugin* remdesk) remdesk->OpenHandle = 0; } MessageQueue_Free(remdesk->queue); - CloseHandle(remdesk->thread); + (void)CloseHandle(remdesk->thread); Stream_Free(remdesk->data_in, TRUE); remdesk->data_in = NULL; remdesk->queue = NULL; diff --git a/channels/remdesk/server/remdesk_main.c b/channels/remdesk/server/remdesk_main.c index a1b24b87a..4c876819f 100644 --- a/channels/remdesk/server/remdesk_main.c +++ b/channels/remdesk/server/remdesk_main.c @@ -669,7 +669,7 @@ static UINT remdesk_server_start(RemdeskServerContext* context) CreateThread(NULL, 0, remdesk_server_thread, (void*)context, 0, NULL))) { WLog_ERR(TAG, "CreateThread failed!"); - CloseHandle(context->priv->StopEvent); + (void)CloseHandle(context->priv->StopEvent); context->priv->StopEvent = NULL; return ERROR_INTERNAL_ERROR; } @@ -694,8 +694,8 @@ static UINT remdesk_server_stop(RemdeskServerContext* context) return error; } - CloseHandle(context->priv->Thread); - CloseHandle(context->priv->StopEvent); + (void)CloseHandle(context->priv->Thread); + (void)CloseHandle(context->priv->StopEvent); return CHANNEL_RC_OK; } diff --git a/channels/serial/client/serial_main.c b/channels/serial/client/serial_main.c index eb4cf3952..fe363a46e 100644 --- a/channels/serial/client/serial_main.c +++ b/channels/serial/client/serial_main.c @@ -685,7 +685,7 @@ static void create_irp_thread(SERIAL_DEVICE* serial, IRP* irp) return; error_handle: if (irpThread) - CloseHandle(irpThread); + (void)CloseHandle(irpThread); irp->IoStatus = STATUS_NO_MEMORY; irp->Complete(irp); free(data); @@ -785,11 +785,11 @@ static UINT serial_free(DEVICE* device) WLog_Print(serial->log, WLOG_ERROR, "WaitForSingleObject failed with error %" PRIu32 "!", error); } - CloseHandle(serial->MainThread); + (void)CloseHandle(serial->MainThread); } if (serial->hComm) - CloseHandle(serial->hComm); + (void)CloseHandle(*serial->hComm); /* Clean up resources */ Stream_Free(serial->device.data, TRUE); @@ -827,7 +827,7 @@ static void irp_thread_close(void* arg) { (void)TerminateThread(hdl, 0); WaitForSingleObject(hdl, INFINITE); - CloseHandle(hdl); + (void)CloseHandle(hdl); } } } diff --git a/channels/smartcard/client/smartcard_main.c b/channels/smartcard/client/smartcard_main.c index 71951a6a5..00e559a98 100644 --- a/channels/smartcard/client/smartcard_main.c +++ b/channels/smartcard/client/smartcard_main.c @@ -232,7 +232,7 @@ void smartcard_context_free(void* pCtx) if (WaitForSingleObject(pContext->thread, INFINITE) == WAIT_FAILED) WLog_ERR(TAG, "WaitForSingleObject failed with error %" PRIu32 "!", GetLastError()); - CloseHandle(pContext->thread); + (void)CloseHandle(pContext->thread); } MessageQueue_Free(pContext->IrpQueue); } @@ -253,7 +253,7 @@ static UINT smartcard_free_(SMARTCARD_DEVICE* smartcard) if (smartcard->IrpQueue) { MessageQueue_Free(smartcard->IrpQueue); - CloseHandle(smartcard->thread); + (void)CloseHandle(smartcard->thread); } Stream_Free(smartcard->device.data, TRUE); diff --git a/channels/sshagent/client/sshagent_main.c b/channels/sshagent/client/sshagent_main.c index 293ea2989..508278908 100644 --- a/channels/sshagent/client/sshagent_main.c +++ b/channels/sshagent/client/sshagent_main.c @@ -233,7 +233,7 @@ static UINT sshagent_on_close(IWTSVirtualChannelCallback* pChannelCallback) return error; } - CloseHandle(callback->thread); + (void)CloseHandle(callback->thread); LeaveCriticalSection(&callback->lock); DeleteCriticalSection(&callback->lock); free(callback); diff --git a/channels/telemetry/server/telemetry_main.c b/channels/telemetry/server/telemetry_main.c index cf7a2d982..ae099f0f4 100644 --- a/channels/telemetry/server/telemetry_main.c +++ b/channels/telemetry/server/telemetry_main.c @@ -325,7 +325,7 @@ static UINT telemetry_server_open(TelemetryServerContext* context) if (!telemetry->thread) { WLog_ERR(TAG, "CreateThread failed!"); - CloseHandle(telemetry->stopEvent); + (void)CloseHandle(telemetry->stopEvent); telemetry->stopEvent = NULL; return ERROR_INTERNAL_ERROR; } @@ -353,8 +353,8 @@ static UINT telemetry_server_close(TelemetryServerContext* context) return error; } - CloseHandle(telemetry->thread); - CloseHandle(telemetry->stopEvent); + (void)CloseHandle(telemetry->thread); + (void)CloseHandle(telemetry->stopEvent); telemetry->thread = NULL; telemetry->stopEvent = NULL; } diff --git a/channels/tsmf/client/tsmf_media.c b/channels/tsmf/client/tsmf_media.c index 81717bc66..dcad0831f 100644 --- a/channels/tsmf/client/tsmf_media.c +++ b/channels/tsmf/client/tsmf_media.c @@ -1277,9 +1277,9 @@ error_play_thread: error_sample_ack_list: Queue_Free(stream->sample_list); error_sample_list: - CloseHandle(stream->ready); + (void)CloseHandle(stream->ready); error_ready: - CloseHandle(stream->stopEvent); + (void)CloseHandle(stream->stopEvent); error_stopEvent: free(stream); return NULL; @@ -1412,7 +1412,7 @@ void s_tsmf_stream_free(void* obj) return; } - CloseHandle(stream->play_thread); + (void)CloseHandle(stream->play_thread); stream->play_thread = NULL; } @@ -1424,7 +1424,7 @@ void s_tsmf_stream_free(void* obj) return; } - CloseHandle(stream->ack_thread); + (void)CloseHandle(stream->ack_thread); stream->ack_thread = NULL; } @@ -1437,8 +1437,8 @@ void s_tsmf_stream_free(void* obj) stream->decoder = NULL; } - CloseHandle(stream->stopEvent); - CloseHandle(stream->ready); + (void)CloseHandle(stream->stopEvent); + (void)CloseHandle(stream->ready); ZeroMemory(stream, sizeof(TSMF_STREAM)); free(stream); } diff --git a/channels/urbdrc/client/libusb/libusb_udevman.c b/channels/urbdrc/client/libusb/libusb_udevman.c index 541d0e366..1c5f45555 100644 --- a/channels/urbdrc/client/libusb/libusb_udevman.c +++ b/channels/urbdrc/client/libusb/libusb_udevman.c @@ -470,13 +470,13 @@ static void udevman_free(IUDEVMAN* idevman) if (udevman->thread) { WaitForSingleObject(udevman->thread, INFINITE); - CloseHandle(udevman->thread); + (void)CloseHandle(udevman->thread); } udevman_unregister_all_udevices(idevman); if (udevman->devman_loading) - CloseHandle(udevman->devman_loading); + (void)CloseHandle(udevman->devman_loading); libusb_exit(udevman->context); diff --git a/client/Android/Studio/freeRDPCore/src/main/cpp/android_cliprdr.c b/client/Android/Studio/freeRDPCore/src/main/cpp/android_cliprdr.c index b6601e95e..150ff64aa 100644 --- a/client/Android/Studio/freeRDPCore/src/main/cpp/android_cliprdr.c +++ b/client/Android/Studio/freeRDPCore/src/main/cpp/android_cliprdr.c @@ -475,7 +475,7 @@ BOOL android_cliprdr_init(androidContext* afc, CliprdrClientContext* cliprdr) if (!(clipboard = ClipboardCreate())) { - CloseHandle(hevent); + (void)CloseHandle(hevent); return FALSE; } @@ -504,6 +504,6 @@ BOOL android_cliprdr_uninit(androidContext* afc, CliprdrClientContext* cliprdr) cliprdr->custom = NULL; afc->cliprdr = NULL; ClipboardDestroy(afc->clipboard); - CloseHandle(afc->clipboardRequestEvent); + (void)CloseHandle(afc->clipboardRequestEvent); return TRUE; } diff --git a/client/Android/Studio/freeRDPCore/src/main/cpp/android_event.c b/client/Android/Studio/freeRDPCore/src/main/cpp/android_event.c index 1a132534a..da3d2aab2 100644 --- a/client/Android/Studio/freeRDPCore/src/main/cpp/android_event.c +++ b/client/Android/Studio/freeRDPCore/src/main/cpp/android_event.c @@ -325,7 +325,7 @@ BOOL android_event_queue_init(freerdp* inst) if (!queue->events) { WLog_ERR(TAG, "android_event_queue_init: memory allocation failed"); - CloseHandle(queue->isSet); + (void)CloseHandle(queue->isSet); free(queue); return FALSE; } @@ -349,7 +349,7 @@ void android_event_queue_uninit(freerdp* inst) { if (queue->isSet) { - CloseHandle(queue->isSet); + (void)CloseHandle(queue->isSet); queue->isSet = NULL; } diff --git a/client/Mac/Clipboard.m b/client/Mac/Clipboard.m index 02d7b39be..e95424878 100644 --- a/client/Mac/Clipboard.m +++ b/client/Mac/Clipboard.m @@ -428,5 +428,5 @@ void mac_cliprdr_uninit(mfContext *mfc, CliprdrClientContext *cliprdr) mfc->cliprdr = NULL; ClipboardDestroy(mfc->clipboard); - CloseHandle(mfc->clipboardRequestEvent); + (void)CloseHandle(mfc->clipboardRequestEvent); } diff --git a/client/Mac/mf_client.m b/client/Mac/mf_client.m index 76c89b377..1dcc1577c 100644 --- a/client/Mac/mf_client.m +++ b/client/Mac/mf_client.m @@ -111,7 +111,7 @@ static void mfreerdp_client_free(freerdp *instance, rdpContext *context) return; mfc = (mfContext *)instance->context; - CloseHandle(mfc->stopEvent); + (void)CloseHandle(mfc->stopEvent); } static void mf_scale_mouse_coordinates(mfContext *mfc, UINT16 *px, UINT16 *py) diff --git a/client/SDL/SDL2/sdl_utils.cpp b/client/SDL/SDL2/sdl_utils.cpp index a10bd1ed3..b7729f1fe 100644 --- a/client/SDL/SDL2/sdl_utils.cpp +++ b/client/SDL/SDL2/sdl_utils.cpp @@ -260,7 +260,7 @@ WinPREvent::WinPREvent(bool initial) WinPREvent::~WinPREvent() { - CloseHandle(_handle); + (void)CloseHandle(_handle); } void WinPREvent::set() diff --git a/client/SDL/SDL3/sdl_clip.cpp b/client/SDL/SDL3/sdl_clip.cpp index 7e19d15b2..aa5a7ea60 100644 --- a/client/SDL/SDL3/sdl_clip.cpp +++ b/client/SDL/SDL3/sdl_clip.cpp @@ -101,7 +101,7 @@ sdlClip::~sdlClip() { cliprdr_file_context_free(_file); ClipboardDestroy(_system); - CloseHandle(_event); + (void)CloseHandle(_event); } BOOL sdlClip::init(CliprdrClientContext* clip) diff --git a/client/SDL/SDL3/sdl_utils.cpp b/client/SDL/SDL3/sdl_utils.cpp index 6e59a2b73..e46edb634 100644 --- a/client/SDL/SDL3/sdl_utils.cpp +++ b/client/SDL/SDL3/sdl_utils.cpp @@ -306,7 +306,7 @@ WinPREvent::WinPREvent(bool initial) WinPREvent::~WinPREvent() { - CloseHandle(_handle); + (void)CloseHandle(_handle); } void WinPREvent::set() diff --git a/client/Wayland/wlfreerdp.c b/client/Wayland/wlfreerdp.c index 5b44d74e8..023883d44 100644 --- a/client/Wayland/wlfreerdp.c +++ b/client/Wayland/wlfreerdp.c @@ -575,7 +575,7 @@ static int wlfreerdp_run(freerdp* instance) disconnect: if (timer) - CloseHandle(timer); + (void)CloseHandle(timer); freerdp_disconnect(instance); return status; } @@ -619,7 +619,7 @@ static void wlf_client_free(freerdp* instance, rdpContext* context) UwacCloseDisplay(&wlf->display); if (wlf->displayHandle) - CloseHandle(wlf->displayHandle); + (void)CloseHandle(wlf->displayHandle); ArrayList_Free(wlf->events); DeleteCriticalSection(&wlf->critical); } diff --git a/client/Windows/wf_client.c b/client/Windows/wf_client.c index 59f924f24..647090265 100644 --- a/client/Windows/wf_client.c +++ b/client/Windows/wf_client.c @@ -1467,7 +1467,7 @@ static int wfreerdp_client_stop(rdpContext* context) { PostThreadMessage(wfc->keyboardThreadId, WM_QUIT, 0, 0); WaitForSingleObject(wfc->keyboardThread, INFINITE); - CloseHandle(wfc->keyboardThread); + (void)CloseHandle(wfc->keyboardThread); wfc->keyboardThread = NULL; wfc->keyboardThreadId = 0; } diff --git a/client/Windows/wf_cliprdr.c b/client/Windows/wf_cliprdr.c index 97218ac1f..63f4b3fee 100644 --- a/client/Windows/wf_cliprdr.c +++ b/client/Windows/wf_cliprdr.c @@ -1672,7 +1672,7 @@ static FILEDESCRIPTORW* wf_cliprdr_get_file_descriptor(WCHAR* file_name, size_t fd->nFileSizeLow = GetFileSize(hFile, &fd->nFileSizeHigh); wcscpy_s(fd->cFileName, sizeof(fd->cFileName) / 2, file_name + pathLen); - CloseHandle(hFile); + (void)CloseHandle(hFile); return fd; } @@ -2536,14 +2536,14 @@ BOOL wf_cliprdr_uninit(wfContext* wfc, CliprdrClientContext* cliprdr) if (clipboard->thread) { WaitForSingleObject(clipboard->thread, INFINITE); - CloseHandle(clipboard->thread); + (void)CloseHandle(clipboard->thread); } if (clipboard->response_data_event) - CloseHandle(clipboard->response_data_event); + (void)CloseHandle(clipboard->response_data_event); if (clipboard->req_fevent) - CloseHandle(clipboard->req_fevent); + (void)CloseHandle(clipboard->req_fevent); clear_file_array(clipboard); clear_format_map(clipboard); diff --git a/client/X11/xf_client.c b/client/X11/xf_client.c index d02134830..3cf227e42 100644 --- a/client/X11/xf_client.c +++ b/client/X11/xf_client.c @@ -1452,7 +1452,7 @@ static void xf_post_disconnect(freerdp* instance) if (xfc->pipethread) { WaitForSingleObject(xfc->pipethread, INFINITE); - CloseHandle(xfc->pipethread); + (void)CloseHandle(xfc->pipethread); xfc->pipethread = NULL; } if (xfc->clipboard) @@ -1681,7 +1681,7 @@ static DWORD WINAPI xf_client_thread(LPVOID param) disconnect: if (timer) - CloseHandle(timer); + (void)CloseHandle(timer); freerdp_disconnect(instance); end: @@ -1832,13 +1832,13 @@ void xf_teardown_x11(xfContext* xfc) if (xfc->x11event) { - CloseHandle(xfc->x11event); + (void)CloseHandle(xfc->x11event); xfc->x11event = NULL; } if (xfc->mutex) { - CloseHandle(xfc->mutex); + (void)CloseHandle(xfc->mutex); xfc->mutex = NULL; } diff --git a/client/common/client.c b/client/common/client.c index 632d7e197..78805a8f8 100644 --- a/client/common/client.c +++ b/client/common/client.c @@ -1340,7 +1340,7 @@ int freerdp_client_common_stop(rdpContext* context) if (cctx->thread) { WaitForSingleObject(cctx->thread, INFINITE); - CloseHandle(cctx->thread); + (void)CloseHandle(cctx->thread); cctx->thread = NULL; } diff --git a/client/common/client_cliprdr_file.c b/client/common/client_cliprdr_file.c index 34cdefef3..7f86187fb 100644 --- a/client/common/client_cliprdr_file.c +++ b/client/common/client_cliprdr_file.c @@ -2079,12 +2079,12 @@ void cliprdr_file_context_free(CliprdrFileContext* file) WLog_Print(file->log, WLOG_DEBUG, "Waiting on FUSE thread"); WaitForSingleObject(file->fuse_thread, INFINITE); - CloseHandle(file->fuse_thread); + (void)CloseHandle(file->fuse_thread); } if (file->fuse_stop_sync) - CloseHandle(file->fuse_stop_sync); + (void)CloseHandle(file->fuse_stop_sync); if (file->fuse_start_sync) - CloseHandle(file->fuse_start_sync); + (void)CloseHandle(file->fuse_start_sync); HashTable_Free(file->request_table); HashTable_Free(file->clip_data_table); @@ -2198,7 +2198,7 @@ static BOOL is_directory(const char* path) BY_HANDLE_FILE_INFORMATION fileInformation = { 0 }; const BOOL status = GetFileInformationByHandle(hFile, &fileInformation); - CloseHandle(hFile); + (void)CloseHandle(hFile); if (!status) return FALSE; diff --git a/client/iOS/FreeRDP/ios_cliprdr.m b/client/iOS/FreeRDP/ios_cliprdr.m index 92780129a..e71a1ec7e 100644 --- a/client/iOS/FreeRDP/ios_cliprdr.m +++ b/client/iOS/FreeRDP/ios_cliprdr.m @@ -465,7 +465,7 @@ BOOL ios_cliprdr_init(mfContext *afc, CliprdrClientContext *cliprdr) if (!(clipboard = ClipboardCreate())) { - CloseHandle(hevent); + (void)CloseHandle(hevent); return FALSE; } @@ -494,6 +494,6 @@ BOOL ios_cliprdr_uninit(mfContext *afc, CliprdrClientContext *cliprdr) cliprdr->custom = NULL; afc->cliprdr = NULL; ClipboardDestroy(afc->clipboard); - CloseHandle(afc->clipboardRequestEvent); + (void)CloseHandle(afc->clipboardRequestEvent); return TRUE; } diff --git a/client/iOS/FreeRDP/ios_freerdp_events.m b/client/iOS/FreeRDP/ios_freerdp_events.m index e010f7949..b18de85ff 100644 --- a/client/iOS/FreeRDP/ios_freerdp_events.m +++ b/client/iOS/FreeRDP/ios_freerdp_events.m @@ -170,5 +170,5 @@ void ios_events_free_pipe(mfInfo *mfi) mfi->event_pipe_consumer = mfi->event_pipe_producer = -1; close(producer_fd); close(consumer_fd); - CloseHandle(mfi->handle); + (void)CloseHandle(mfi->handle); } diff --git a/libfreerdp/core/childsession.c b/libfreerdp/core/childsession.c index 17a9e0b46..e3408a72b 100644 --- a/libfreerdp/core/childsession.c +++ b/libfreerdp/core/childsession.c @@ -348,13 +348,13 @@ static void BIO_NAMED_free(WINPR_BIO_NAMED* ptr) if (ptr->hFile) { - CloseHandle(ptr->hFile); + (void)CloseHandle(ptr->hFile); ptr->hFile = NULL; } if (ptr->readEvent) { - CloseHandle(ptr->readEvent); + (void)CloseHandle(ptr->readEvent); ptr->readEvent = NULL; } @@ -530,7 +530,7 @@ BIO* createChildSessionBio(void) BIO* lowLevelBio = BIO_new(BIO_s_namedpipe()); if (!lowLevelBio) { - CloseHandle(f); + (void)CloseHandle(f); return NULL; } diff --git a/libfreerdp/core/freerdp.c b/libfreerdp/core/freerdp.c index 140de6591..cd951ce37 100644 --- a/libfreerdp/core/freerdp.c +++ b/libfreerdp/core/freerdp.c @@ -895,7 +895,7 @@ void freerdp_context_free(freerdp* instance) ctx->metrics = NULL; if (ctx->channelErrorEvent) - CloseHandle(ctx->channelErrorEvent); + (void)CloseHandle(ctx->channelErrorEvent); ctx->channelErrorEvent = NULL; free(ctx->errorDescription); diff --git a/libfreerdp/core/gateway/rpc_client.c b/libfreerdp/core/gateway/rpc_client.c index 3083d4aa2..c796ec625 100644 --- a/libfreerdp/core/gateway/rpc_client.c +++ b/libfreerdp/core/gateway/rpc_client.c @@ -1214,7 +1214,7 @@ void rpc_client_free(RpcClient* client) Stream_Free(client->ReceiveFragment, TRUE); if (client->PipeEvent) - CloseHandle(client->PipeEvent); + (void)CloseHandle(client->PipeEvent); ringbuffer_destroy(&(client->ReceivePipe)); DeleteCriticalSection(&(client->PipeLock)); diff --git a/libfreerdp/core/listener.c b/libfreerdp/core/listener.c index 4726b19b6..677ae5a7f 100644 --- a/libfreerdp/core/listener.c +++ b/libfreerdp/core/listener.c @@ -342,7 +342,7 @@ static void freerdp_listener_close(freerdp_listener* instance) for (int i = 0; i < listener->num_sockfds; i++) { closesocket((SOCKET)listener->sockfds[i]); - CloseHandle(listener->events[i]); + (void)CloseHandle(listener->events[i]); } listener->num_sockfds = 0; diff --git a/libfreerdp/core/message.c b/libfreerdp/core/message.c index bc00d7b87..be9936bdd 100644 --- a/libfreerdp/core/message.c +++ b/libfreerdp/core/message.c @@ -2907,7 +2907,7 @@ void update_message_proxy_free(rdpUpdateProxy* message) if (MessageQueue_PostQuit(up->queue, 0)) WaitForSingleObject(message->thread, INFINITE); - CloseHandle(message->thread); + (void)CloseHandle(message->thread); free(message); } } diff --git a/libfreerdp/core/peer.c b/libfreerdp/core/peer.c index e5b30b7f1..4bb33d58c 100644 --- a/libfreerdp/core/peer.c +++ b/libfreerdp/core/peer.c @@ -1340,7 +1340,7 @@ void freerdp_peer_context_free(freerdp_peer* client) { rdpContext* ctx = client->context; - CloseHandle(ctx->channelErrorEvent); + (void)CloseHandle(ctx->channelErrorEvent); ctx->channelErrorEvent = NULL; free(ctx->errorDescription); ctx->errorDescription = NULL; diff --git a/libfreerdp/core/rdp.c b/libfreerdp/core/rdp.c index 689c738b4..922cb3346 100644 --- a/libfreerdp/core/rdp.c +++ b/libfreerdp/core/rdp.c @@ -2512,7 +2512,7 @@ void rdp_free(rdpRdp* rdp) free(rdp->io); PubSub_Free(rdp->pubSub); if (rdp->abortEvent) - CloseHandle(rdp->abortEvent); + (void)CloseHandle(rdp->abortEvent); aad_free(rdp->aad); free(rdp); } diff --git a/libfreerdp/core/tcp.c b/libfreerdp/core/tcp.c index 62240361d..cd4ce1022 100644 --- a/libfreerdp/core/tcp.c +++ b/libfreerdp/core/tcp.c @@ -389,7 +389,7 @@ static int transport_bio_simple_uninit(BIO* bio) if (ptr && ptr->hEvent) { - CloseHandle(ptr->hEvent); + (void)CloseHandle(ptr->hEvent); ptr->hEvent = NULL; } @@ -874,7 +874,7 @@ static BOOL freerdp_tcp_connect_timeout(rdpContext* context, int sockfd, struct rc = TRUE; fail: - CloseHandle(handles[0]); + (void)CloseHandle(handles[0]); return rc; } @@ -1422,7 +1422,7 @@ static BOOL freerdp_tcp_layer_close(void* userContext) if (tcpLayer->sockfd >= 0) closesocket(tcpLayer->sockfd); if (tcpLayer->hEvent) - CloseHandle(tcpLayer->hEvent); + (void)CloseHandle(tcpLayer->hEvent); return TRUE; } diff --git a/libfreerdp/core/test/TestConnect.c b/libfreerdp/core/test/TestConnect.c index 306c824c6..350031ffb 100644 --- a/libfreerdp/core/test/TestConnect.c +++ b/libfreerdp/core/test/TestConnect.c @@ -143,7 +143,7 @@ static int testAbort(int port) if (!thread) { - CloseHandle(s_sync); + (void)CloseHandle(s_sync); s_sync = NULL; return -1; } @@ -156,8 +156,8 @@ static int testAbort(int port) if (!freerdp_shall_disconnect_context(instance->context)) { - CloseHandle(s_sync); - CloseHandle(thread); + (void)CloseHandle(s_sync); + (void)CloseHandle(thread); s_sync = NULL; return -1; } @@ -165,8 +165,8 @@ static int testAbort(int port) status = WaitForSingleObject(thread, 20000); end = GetTickCount(); - CloseHandle(s_sync); - CloseHandle(thread); + (void)CloseHandle(s_sync); + (void)CloseHandle(thread); s_sync = NULL; diff = end - start; @@ -227,8 +227,8 @@ static BOOL prepare_certificates(const char* path) goto fail; rc = TRUE; fail: - CloseHandle(process.hProcess); - CloseHandle(process.hThread); + (void)CloseHandle(process.hProcess); + (void)CloseHandle(process.hThread); return rc; } @@ -294,8 +294,8 @@ static int testSuccess(int port) goto fail; WaitForSingleObject(process.hProcess, INFINITE); - CloseHandle(process.hProcess); - CloseHandle(process.hThread); + (void)CloseHandle(process.hProcess); + (void)CloseHandle(process.hThread); printf("%s: returned %d!\n", __func__, r); rc = r; diff --git a/libfreerdp/core/transport.c b/libfreerdp/core/transport.c index 814f3d656..f83c24a16 100644 --- a/libfreerdp/core/transport.c +++ b/libfreerdp/core/transport.c @@ -1702,9 +1702,9 @@ void transport_free(rdpTransport* transport) nla_free(transport->nla); StreamPool_Free(transport->ReceivePool); - CloseHandle(transport->connectedEvent); - CloseHandle(transport->rereadEvent); - CloseHandle(transport->ioEvent); + (void)CloseHandle(transport->connectedEvent); + (void)CloseHandle(transport->rereadEvent); + (void)CloseHandle(transport->ioEvent); DeleteCriticalSection(&(transport->ReadLock)); DeleteCriticalSection(&(transport->WriteLock)); free(transport); diff --git a/libfreerdp/utils/smartcard_call.c b/libfreerdp/utils/smartcard_call.c index a598b8a0a..a00ee43ef 100644 --- a/libfreerdp/utils/smartcard_call.c +++ b/libfreerdp/utils/smartcard_call.c @@ -1959,7 +1959,7 @@ void smartcard_call_context_free(scard_call_context* ctx) ctx->pWinSCardApi = NULL; HashTable_Free(ctx->rgSCardContextList); - CloseHandle(ctx->stopEvent); + (void)CloseHandle(ctx->stopEvent); free(ctx); } diff --git a/server/Sample/sfreerdp.c b/server/Sample/sfreerdp.c index e64fbcccc..608e9cfd9 100644 --- a/server/Sample/sfreerdp.c +++ b/server/Sample/sfreerdp.c @@ -84,7 +84,7 @@ static void test_peer_context_free(freerdp_peer* client, rdpContext* ctx) WINPR_ASSERT(context->stopEvent); (void)SetEvent(context->stopEvent); WaitForSingleObject(context->debug_channel_thread, INFINITE); - CloseHandle(context->debug_channel_thread); + (void)CloseHandle(context->debug_channel_thread); } Stream_Free(context->s, TRUE); @@ -761,7 +761,7 @@ static BOOL tf_peer_post_connect(freerdp_peer* client) CreateThread(NULL, 0, tf_debug_channel_thread_func, (void*)context, 0, NULL))) { WLog_ERR(TAG, "Failed to create debug channel thread"); - CloseHandle(context->stopEvent); + (void)CloseHandle(context->stopEvent); context->stopEvent = NULL; return FALSE; } @@ -1275,7 +1275,7 @@ static BOOL test_peer_accepted(freerdp_listener* instance, freerdp_peer* client) if (!(hThread = CreateThread(NULL, 0, test_peer_mainloop, (void*)client, 0, NULL))) return FALSE; - CloseHandle(hThread); + (void)CloseHandle(hThread); return TRUE; } diff --git a/server/Windows/wf_directsound.c b/server/Windows/wf_directsound.c index 441397a0c..e116f4089 100644 --- a/server/Windows/wf_directsound.c +++ b/server/Windows/wf_directsound.c @@ -82,7 +82,7 @@ int wf_directsound_activate(RdpsndServerContext* context) WLog_ERR(TAG, "Failed to create direct sound thread"); return 1; } - CloseHandle(hThread); + (void)CloseHandle(hThread); return 0; } diff --git a/server/Windows/wf_info.c b/server/Windows/wf_info.c index 7ec754bce..f0d053b04 100644 --- a/server/Windows/wf_info.c +++ b/server/Windows/wf_info.c @@ -120,7 +120,7 @@ wfInfo* wf_info_init() if (!wfi->updateSemaphore) { WLog_ERR(TAG, "CreateSemaphore error: %lu", GetLastError()); - CloseHandle(wfi->mutex); + (void)CloseHandle(wfi->mutex); free(wfi); return NULL; } @@ -130,8 +130,8 @@ wfInfo* wf_info_init() if (!wfi->updateThread) { WLog_ERR(TAG, "Failed to create update thread"); - CloseHandle(wfi->mutex); - CloseHandle(wfi->updateSemaphore); + (void)CloseHandle(wfi->mutex); + (void)CloseHandle(wfi->updateSemaphore); free(wfi); return NULL; } @@ -142,9 +142,9 @@ wfInfo* wf_info_init() if (!wfi->peers) { WLog_ERR(TAG, "Failed to allocate memory for peer"); - CloseHandle(wfi->mutex); - CloseHandle(wfi->updateSemaphore); - CloseHandle(wfi->updateThread); + (void)CloseHandle(wfi->mutex); + (void)CloseHandle(wfi->updateSemaphore); + (void)CloseHandle(wfi->updateThread); free(wfi); return NULL; } @@ -244,7 +244,7 @@ BOOL wf_info_peer_register(wfInfo* wfi, wfPeerContext* context) wfreerdp_server_peer_callback_event(peerId, FREERDP_SERVER_WIN_SRV_CALLBACK_EVENT_CONNECT); return TRUE; fail_driver_init: - CloseHandle(context->updateEvent); + (void)CloseHandle(context->updateEvent); context->updateEvent = NULL; fail_update_event: fail_peer_count: @@ -261,7 +261,7 @@ void wf_info_peer_unregister(wfInfo* wfi, wfPeerContext* context) peerId = ((rdpContext*)context)->peer->pId; wfi->peers[peerId] = NULL; wfi->peerCount--; - CloseHandle(context->updateEvent); + (void)CloseHandle(context->updateEvent); WLog_INFO(TAG, "Unregistering Peer: id=%d, #=%d", peerId, wfi->peerCount); #ifdef WITH_DXGI_1_2 diff --git a/server/Windows/wf_peer.c b/server/Windows/wf_peer.c index bea273b8e..cfadf6926 100644 --- a/server/Windows/wf_peer.c +++ b/server/Windows/wf_peer.c @@ -182,7 +182,7 @@ BOOL wf_peer_accepted(freerdp_listener* instance, freerdp_peer* client) if (!(hThread = CreateThread(NULL, 0, wf_peer_main_loop, client, 0, NULL))) return FALSE; - CloseHandle(hThread); + (void)CloseHandle(hThread); return TRUE; } @@ -399,10 +399,10 @@ DWORD WINAPI wf_peer_main_loop(LPVOID lpParam) wf_update_peer_deactivate(wfi, context); client->Disconnect(client); fail_socket_thread: - CloseHandle(context->socketSemaphore); + (void)CloseHandle(context->socketSemaphore); context->socketSemaphore = NULL; fail_socket_semaphore: - CloseHandle(context->socketEvent); + (void)CloseHandle(context->socketEvent); context->socketEvent = NULL; fail_socket_event: fail_socked_closed: diff --git a/server/Windows/wf_wasapi.c b/server/Windows/wf_wasapi.c index 3925f99b3..c7b4408f5 100644 --- a/server/Windows/wf_wasapi.c +++ b/server/Windows/wf_wasapi.c @@ -58,7 +58,7 @@ int wf_wasapi_activate(RdpsndServerContext* context) WLog_ERR(TAG, "CreateThread failed"); return 1; } - CloseHandle(hThread); + (void)CloseHandle(hThread); return 0; } diff --git a/server/proxy/pf_context.c b/server/proxy/pf_context.c index 7b7e63416..e5d5bbde1 100644 --- a/server/proxy/pf_context.c +++ b/server/proxy/pf_context.c @@ -198,7 +198,7 @@ void client_to_proxy_context_free(freerdp_peer* client, rdpContext* ctx) if (context->dynvcReady) { - CloseHandle(context->dynvcReady); + (void)CloseHandle(context->dynvcReady); context->dynvcReady = NULL; } @@ -388,13 +388,13 @@ void proxy_data_free(proxyData* pdata) return; if (pdata->abort_event) - CloseHandle(pdata->abort_event); + (void)CloseHandle(pdata->abort_event); if (pdata->client_thread) - CloseHandle(pdata->client_thread); + (void)CloseHandle(pdata->client_thread); if (pdata->gfx_server_ready) - CloseHandle(pdata->gfx_server_ready); + (void)CloseHandle(pdata->gfx_server_ready); if (pdata->modules_info) HashTable_Free(pdata->modules_info); diff --git a/server/proxy/pf_server.c b/server/proxy/pf_server.c index 8f026fbbc..0415438e7 100644 --- a/server/proxy/pf_server.c +++ b/server/proxy/pf_server.c @@ -762,7 +762,7 @@ static BOOL pf_server_start_peer(freerdp_peer* client) args->thread = hThread; if (!ArrayList_Append(server->peer_list, hThread)) { - CloseHandle(hThread); + (void)CloseHandle(hThread); return FALSE; } @@ -911,7 +911,7 @@ static BOOL are_all_required_modules_loaded(proxyModule* module, const proxyConf static void peer_free(void* obj) { HANDLE hdl = (HANDLE)obj; - CloseHandle(hdl); + (void)CloseHandle(hdl); } proxyServer* pf_server_new(const proxyConfig* config) @@ -1063,7 +1063,7 @@ void pf_server_free(proxyServer* server) freerdp_listener_free(server->listener); if (server->stopEvent) - CloseHandle(server->stopEvent); + (void)CloseHandle(server->stopEvent); pf_server_config_free(server->config); pf_modules_free(server->module); diff --git a/server/shadow/Win/win_rdp.c b/server/shadow/Win/win_rdp.c index fc112ed43..077a6787f 100644 --- a/server/shadow/Win/win_rdp.c +++ b/server/shadow/Win/win_rdp.c @@ -408,9 +408,9 @@ int win_shadow_rdp_init(winShadowSubsystem* subsystem) subsystem->shw->subsystem = subsystem; return 1; fail_context: - CloseHandle(subsystem->RdpUpdateLeaveEvent); + (void)CloseHandle(subsystem->RdpUpdateLeaveEvent); fail_leave_event: - CloseHandle(subsystem->RdpUpdateEnterEvent); + (void)CloseHandle(subsystem->RdpUpdateEnterEvent); fail_enter_event: return -1; } diff --git a/server/shadow/X11/x11_shadow.c b/server/shadow/X11/x11_shadow.c index 8c43e25e3..f11d9e038 100644 --- a/server/shadow/X11/x11_shadow.c +++ b/server/shadow/X11/x11_shadow.c @@ -1420,7 +1420,7 @@ static int x11_shadow_subsystem_uninit(rdpShadowSubsystem* sub) if (subsystem->common.event) { - CloseHandle(subsystem->common.event); + (void)CloseHandle(subsystem->common.event); subsystem->common.event = NULL; } @@ -1462,7 +1462,7 @@ static int x11_shadow_subsystem_stop(rdpShadowSubsystem* sub) if (MessageQueue_PostQuit(subsystem->common.MsgPipe->In, 0)) WaitForSingleObject(subsystem->thread, INFINITE); - CloseHandle(subsystem->thread); + (void)CloseHandle(subsystem->thread); subsystem->thread = NULL; } diff --git a/server/shadow/shadow_client.c b/server/shadow/shadow_client.c index 60f0e06e2..48d4fa148 100644 --- a/server/shadow/shadow_client.c +++ b/server/shadow/shadow_client.c @@ -2586,7 +2586,7 @@ BOOL shadow_client_accepted(freerdp_listener* listener, freerdp_peer* peer) else { /* Close the thread handle to make it detached. */ - CloseHandle(client->thread); + (void)CloseHandle(client->thread); client->thread = NULL; } diff --git a/server/shadow/shadow_mcevent.c b/server/shadow/shadow_mcevent.c index 0829f86dd..602062380 100644 --- a/server/shadow/shadow_mcevent.c +++ b/server/shadow/shadow_mcevent.c @@ -79,11 +79,11 @@ rdpShadowMultiClientEvent* shadow_multiclient_new(void) out_free_subscribers: ArrayList_Free(event->subscribers); out_free_doneEvent: - CloseHandle(event->doneEvent); + (void)CloseHandle(event->doneEvent); out_free_barrierEvent: - CloseHandle(event->barrierEvent); + (void)CloseHandle(event->barrierEvent); out_free_event: - CloseHandle(event->event); + (void)CloseHandle(event->event); out_free: free(event); out_error: @@ -98,9 +98,9 @@ void shadow_multiclient_free(rdpShadowMultiClientEvent* event) DeleteCriticalSection(&(event->lock)); ArrayList_Free(event->subscribers); - CloseHandle(event->doneEvent); - CloseHandle(event->barrierEvent); - CloseHandle(event->event); + (void)CloseHandle(event->doneEvent); + (void)CloseHandle(event->barrierEvent); + (void)CloseHandle(event->event); free(event); } diff --git a/server/shadow/shadow_server.c b/server/shadow/shadow_server.c index 3962a8c70..40d41bb63 100644 --- a/server/shadow/shadow_server.c +++ b/server/shadow/shadow_server.c @@ -744,7 +744,7 @@ int shadow_server_stop(rdpShadowServer* server) { (void)SetEvent(server->StopEvent); WaitForSingleObject(server->thread, INFINITE); - CloseHandle(server->thread); + (void)CloseHandle(server->thread); server->thread = NULL; if (server->listener && server->listener->Close) server->listener->Close(server->listener); @@ -978,7 +978,7 @@ int shadow_server_uninit(rdpShadowServer* server) free(server->ConfigPath); server->ConfigPath = NULL; DeleteCriticalSection(&(server->lock)); - CloseHandle(server->StopEvent); + (void)CloseHandle(server->StopEvent); server->StopEvent = NULL; ArrayList_Free(server->clients); server->clients = NULL; diff --git a/winpr/libwinpr/clipboard/synthetic_file.c b/winpr/libwinpr/clipboard/synthetic_file.c index b930cbaa9..bfecd4e80 100644 --- a/winpr/libwinpr/clipboard/synthetic_file.c +++ b/winpr/libwinpr/clipboard/synthetic_file.c @@ -1106,7 +1106,7 @@ static UINT file_get_range(struct synthetic_file* file, UINT64 offset, UINT32 si if (!GetFileInformationByHandle(file->fd, &FileInfo)) { - CloseHandle(file->fd); + (void)CloseHandle(file->fd); file->fd = INVALID_HANDLE_VALUE; error = GetLastError(); WLog_ERR(TAG, "Get file [%s] information fail: 0x%08" PRIx32, file->local_name, error); diff --git a/winpr/libwinpr/comm/comm.c b/winpr/libwinpr/comm/comm.c index f8e30e793..dc4b02eb4 100644 --- a/winpr/libwinpr/comm/comm.c +++ b/winpr/libwinpr/comm/comm.c @@ -1356,8 +1356,7 @@ HANDLE CommCreateFileA(LPCSTR lpDeviceName, DWORD dwDesiredAccess, DWORD dwShare return (HANDLE)pComm; error_handle: WINPR_PRAGMA_DIAG_PUSH - WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC - CloseHandle(pComm); + WINPR_PRAGMA_DIAG_IGNORED_MISMATCHED_DEALLOC(void) CloseHandle(pComm); WINPR_PRAGMA_DIAG_POP return INVALID_HANDLE_VALUE; } diff --git a/winpr/libwinpr/comm/test/TestCommConfig.c b/winpr/libwinpr/comm/test/TestCommConfig.c index ecb6ffc0f..7bc829d87 100644 --- a/winpr/libwinpr/comm/test/TestCommConfig.c +++ b/winpr/libwinpr/comm/test/TestCommConfig.c @@ -144,7 +144,7 @@ int TestCommConfig(int argc, char* argv[]) dcb.BaudRate, dcb.ByteSize, dcb.Parity, dcb.StopBits); } - CloseHandle(hComm); + (void)CloseHandle(hComm); return 0; } diff --git a/winpr/libwinpr/comm/test/TestCommMonitor.c b/winpr/libwinpr/comm/test/TestCommMonitor.c index 57d11a19c..33c722df9 100644 --- a/winpr/libwinpr/comm/test/TestCommMonitor.c +++ b/winpr/libwinpr/comm/test/TestCommMonitor.c @@ -64,7 +64,7 @@ int TestCommMonitor(int argc, char* argv[]) } } - CloseHandle(hComm); + (void)CloseHandle(hComm); return 0; } diff --git a/winpr/libwinpr/error/test/TestErrorSetLastError.c b/winpr/libwinpr/error/test/TestErrorSetLastError.c index cb1ad87c6..310757cb0 100644 --- a/winpr/libwinpr/error/test/TestErrorSetLastError.c +++ b/winpr/libwinpr/error/test/TestErrorSetLastError.c @@ -118,10 +118,10 @@ int TestErrorSetLastError(int argc, char* argv[]) WaitForSingleObject(threads[2], INFINITE); WaitForSingleObject(threads[3], INFINITE); - CloseHandle(threads[0]); - CloseHandle(threads[1]); - CloseHandle(threads[2]); - CloseHandle(threads[3]); + (void)CloseHandle(threads[0]); + (void)CloseHandle(threads[1]); + (void)CloseHandle(threads[2]); + (void)CloseHandle(threads[3]); error = GetLastError(); diff --git a/winpr/libwinpr/file/test/TestFileFindFirstFile.c b/winpr/libwinpr/file/test/TestFileFindFirstFile.c index b40254840..7a2826a2b 100644 --- a/winpr/libwinpr/file/test/TestFileFindFirstFile.c +++ b/winpr/libwinpr/file/test/TestFileFindFirstFile.c @@ -26,7 +26,7 @@ static BOOL create_layout_files(size_t level, const char* BasePath, wArrayList* if (hdl == INVALID_HANDLE_VALUE) return FALSE; ArrayList_Append(files, FilePath); - CloseHandle(hdl); + (void)CloseHandle(hdl); } return TRUE; } @@ -228,7 +228,7 @@ static int TestFileFindFirstFileA(const char* str) CreateFileA(FilePath, GENERIC_ALL, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hdl == INVALID_HANDLE_VALUE) goto fail; - CloseHandle(hdl); + (void)CloseHandle(hdl); if (!find_first_file_success(FilePath)) goto fail; diff --git a/winpr/libwinpr/file/test/TestFileGetStdHandle.c b/winpr/libwinpr/file/test/TestFileGetStdHandle.c index b61eb9d9d..7728f8418 100644 --- a/winpr/libwinpr/file/test/TestFileGetStdHandle.c +++ b/winpr/libwinpr/file/test/TestFileGetStdHandle.c @@ -43,7 +43,7 @@ int TestFileGetStdHandle(int argc, char* argv[]) (void)fprintf(stderr, "write failed\n"); return -1; } - CloseHandle(so); + (void)CloseHandle(so); return 0; } diff --git a/winpr/libwinpr/file/test/TestSetFileAttributes.c b/winpr/libwinpr/file/test/TestSetFileAttributes.c index f423ec296..b00c2ce1a 100644 --- a/winpr/libwinpr/file/test/TestSetFileAttributes.c +++ b/winpr/libwinpr/file/test/TestSetFileAttributes.c @@ -57,7 +57,7 @@ static BOOL test_SetFileAttributesA(void) FILE_ATTRIBUTE_NORMAL, NULL); if (handle == INVALID_HANDLE_VALUE) goto fail; - CloseHandle(handle); + (void)CloseHandle(handle); for (size_t x = 0; x < ARRAYSIZE(flags); x++) { @@ -113,7 +113,7 @@ static BOOL test_SetFileAttributesW(void) FILE_ATTRIBUTE_NORMAL, NULL); if (handle == INVALID_HANDLE_VALUE) goto fail; - CloseHandle(handle); + (void)CloseHandle(handle); for (size_t x = 0; x < ARRAYSIZE(flags); x++) { diff --git a/winpr/libwinpr/interlocked/interlocked.c b/winpr/libwinpr/interlocked/interlocked.c index c9a83de16..6f0151526 100644 --- a/winpr/libwinpr/interlocked/interlocked.c +++ b/winpr/libwinpr/interlocked/interlocked.c @@ -312,7 +312,7 @@ BOOL static_mutex_lock(volatile HANDLE* static_mutex) return FALSE; if (InterlockedCompareExchangePointer((PVOID*)static_mutex, (PVOID)handle, NULL) != NULL) - CloseHandle(handle); + (void)CloseHandle(handle); } return (WaitForSingleObject(*static_mutex, INFINITE) == WAIT_OBJECT_0); diff --git a/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipe.c b/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipe.c index b1849a8fd..f7b5da243 100644 --- a/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipe.c +++ b/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipe.c @@ -84,7 +84,7 @@ static DWORD WINAPI named_pipe_client_thread(LPVOID arg) out: free(lpReadBuffer); free(lpWriteBuffer); - CloseHandle(hNamedPipe); + (void)CloseHandle(hNamedPipe); if (!fSuccess) testFailed = TRUE; @@ -179,7 +179,7 @@ static DWORD WINAPI named_pipe_server_thread(LPVOID arg) out: free(lpReadBuffer); free(lpWriteBuffer); - CloseHandle(hNamedPipe); + (void)CloseHandle(hNamedPipe); if (!fSuccess) testFailed = TRUE; @@ -379,15 +379,15 @@ static DWORD WINAPI named_pipe_single_thread(LPVOID arg) goto out; } } - CloseHandle(servers[i]); - CloseHandle(clients[i]); + (void)CloseHandle(servers[i]); + (void)CloseHandle(clients[i]); numPipes--; /** * After CloseHandle (without calling DisconnectNamedPipe first) on server end * ReadFile/WriteFile must fail on client end */ i = numPipes - 1; - CloseHandle(servers[i]); + (void)CloseHandle(servers[i]); { char sndbuf[PIPE_BUFFER_SIZE] = { 0 }; @@ -409,14 +409,14 @@ static DWORD WINAPI named_pipe_single_thread(LPVOID arg) goto out; } } - CloseHandle(clients[i]); + (void)CloseHandle(clients[i]); numPipes--; /** * After CloseHandle on client end * ReadFile/WriteFile must fail on server end */ i = numPipes - 1; - CloseHandle(clients[i]); + (void)CloseHandle(clients[i]); { char sndbuf[PIPE_BUFFER_SIZE] = { 0 }; @@ -440,15 +440,15 @@ static DWORD WINAPI named_pipe_single_thread(LPVOID arg) } DisconnectNamedPipe(servers[i]); - CloseHandle(servers[i]); + (void)CloseHandle(servers[i]); numPipes--; /* Close all remaining pipes */ for (int i = 0; i < numPipes; i++) { DisconnectNamedPipe(servers[i]); - CloseHandle(servers[i]); - CloseHandle(clients[i]); + (void)CloseHandle(servers[i]); + (void)CloseHandle(clients[i]); } bSuccess = TRUE; @@ -503,8 +503,8 @@ int TestPipeCreateNamedPipe(int argc, char* argv[]) WaitForSingleObject(SingleThread, INFINITE); WaitForSingleObject(ClientThread, INFINITE); WaitForSingleObject(ServerThread, INFINITE); - CloseHandle(SingleThread); - CloseHandle(ClientThread); - CloseHandle(ServerThread); + (void)CloseHandle(SingleThread); + (void)CloseHandle(ClientThread); + (void)CloseHandle(ServerThread); return testFailed; } diff --git a/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipeOverlapped.c b/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipeOverlapped.c index a22b3ffdf..1fc2fdd0c 100644 --- a/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipeOverlapped.c +++ b/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipeOverlapped.c @@ -146,9 +146,9 @@ static DWORD WINAPI named_pipe_client_thread(LPVOID arg) finish: free(lpReadBuffer); if (hNamedPipe) - CloseHandle(hNamedPipe); + (void)CloseHandle(hNamedPipe); if (hEvent) - CloseHandle(hEvent); + (void)CloseHandle(hEvent); return 0; } @@ -324,8 +324,8 @@ static DWORD WINAPI named_pipe_server_thread(LPVOID arg) printf("server: finished successfully\n"); finish: - CloseHandle(hNamedPipe); - CloseHandle(hEvent); + (void)CloseHandle(hNamedPipe); + (void)CloseHandle(hEvent); free(lpReadBuffer); return 0; } @@ -373,11 +373,11 @@ int TestPipeCreateNamedPipeOverlapped(int argc, char* argv[]) out: if (ClientThread) - CloseHandle(ClientThread); + (void)CloseHandle(ClientThread); if (ServerThread) - CloseHandle(ServerThread); + (void)CloseHandle(ServerThread); if (serverReadyEvent) - CloseHandle(serverReadyEvent); + (void)CloseHandle(serverReadyEvent); #ifndef _WIN32 if (result == 0) diff --git a/winpr/libwinpr/pipe/test/TestPipeCreatePipe.c b/winpr/libwinpr/pipe/test/TestPipeCreatePipe.c index db346ef91..0537b8aed 100644 --- a/winpr/libwinpr/pipe/test/TestPipeCreatePipe.c +++ b/winpr/libwinpr/pipe/test/TestPipeCreatePipe.c @@ -65,8 +65,8 @@ int TestPipeCreatePipe(int argc, char* argv[]) return -1; } - CloseHandle(hReadPipe); - CloseHandle(hWritePipe); + (void)CloseHandle(hReadPipe); + (void)CloseHandle(hWritePipe); return 0; } diff --git a/winpr/libwinpr/pool/pool.c b/winpr/libwinpr/pool/pool.c index b3d2ce7a5..790f16189 100644 --- a/winpr/libwinpr/pool/pool.c +++ b/winpr/libwinpr/pool/pool.c @@ -101,7 +101,7 @@ static DWORD WINAPI thread_pool_work_func(LPVOID arg) static void threads_close(void* thread) { WaitForSingleObject(thread, INFINITE); - CloseHandle(thread); + (void)CloseHandle(thread); } static BOOL InitializeThreadpool(PTP_POOL pool) @@ -190,7 +190,7 @@ VOID winpr_CloseThreadpool(PTP_POOL ptpp) ArrayList_Free(ptpp->Threads); Queue_Free(ptpp->PendingQueue); CountdownEvent_Free(ptpp->WorkComplete); - CloseHandle(ptpp->TerminateEvent); + (void)CloseHandle(ptpp->TerminateEvent); { TP_POOL empty = { 0 }; @@ -220,7 +220,7 @@ BOOL winpr_SetThreadpoolThreadMinimum(PTP_POOL ptpp, DWORD cthrdMic) if (!ArrayList_Append(ptpp->Threads, thread)) { - CloseHandle(thread); + (void)CloseHandle(thread); goto fail; } } diff --git a/winpr/libwinpr/smartcard/smartcard_pcsc.c b/winpr/libwinpr/smartcard/smartcard_pcsc.c index a719d269d..95117d372 100644 --- a/winpr/libwinpr/smartcard/smartcard_pcsc.c +++ b/winpr/libwinpr/smartcard/smartcard_pcsc.c @@ -1461,7 +1461,7 @@ static HANDLE WINAPI PCSC_SCardAccessStartedEvent(void) if (!SetEvent(g_StartedEvent)) { - CloseHandle(g_StartedEvent); + (void)CloseHandle(g_StartedEvent); return NULL; } } @@ -1478,7 +1478,7 @@ static void WINAPI PCSC_SCardReleaseStartedEvent(void) { if (g_StartedEvent) { - CloseHandle(g_StartedEvent); + (void)CloseHandle(g_StartedEvent); g_StartedEvent = NULL; } } diff --git a/winpr/libwinpr/synch/barrier.c b/winpr/libwinpr/synch/barrier.c index ecee3b988..610adbb71 100644 --- a/winpr/libwinpr/synch/barrier.c +++ b/winpr/libwinpr/synch/barrier.c @@ -116,7 +116,7 @@ BOOL WINAPI winpr_InitializeSynchronizationBarrier(LPSYNCHRONIZATION_BARRIER lpB if (!(hEvent1 = CreateEvent(NULL, TRUE, FALSE, NULL))) { - CloseHandle(hEvent0); + (void)CloseHandle(hEvent0); return FALSE; } @@ -249,10 +249,10 @@ BOOL WINAPI winpr_DeleteSynchronizationBarrier(LPSYNCHRONIZATION_BARRIER lpBarri SwitchToThread(); if (lpBarrier->Reserved3[0]) - CloseHandle((HANDLE)lpBarrier->Reserved3[0]); + (void)CloseHandle((HANDLE)lpBarrier->Reserved3[0]); if (lpBarrier->Reserved3[1]) - CloseHandle((HANDLE)lpBarrier->Reserved3[1]); + (void)CloseHandle((HANDLE)lpBarrier->Reserved3[1]); ZeroMemory(lpBarrier, sizeof(SYNCHRONIZATION_BARRIER)); diff --git a/winpr/libwinpr/synch/test/TestSynchAPC.c b/winpr/libwinpr/synch/test/TestSynchAPC.c index d6239d818..edff1c0cf 100644 --- a/winpr/libwinpr/synch/test/TestSynchAPC.c +++ b/winpr/libwinpr/synch/test/TestSynchAPC.c @@ -66,7 +66,7 @@ static VOID CALLBACK Timer1APCProc(LPVOID lpArg, DWORD dwTimerLowValue, DWORD dw { UncleanCloseData* data = (UncleanCloseData*)lpArg; data->timer1Calls++; - CloseHandle(data->timer2); + (void)CloseHandle(data->timer2); data->endTest = TRUE; } @@ -128,7 +128,7 @@ int TestSynchAPC(int argc, char* argv[]) if (!thread) return 10; WaitForSingleObject(thread, INFINITE); - CloseHandle(thread); + (void)CloseHandle(thread); if (userApcArg.called || userApcArg.error) return 11; @@ -142,7 +142,7 @@ int TestSynchAPC(int argc, char* argv[]) return 21; WaitForSingleObject(thread, INFINITE); - CloseHandle(thread); + (void)CloseHandle(thread); if (!userApcArg.called) return 22; @@ -163,11 +163,11 @@ int TestSynchAPC(int argc, char* argv[]) return 33; WaitForSingleObject(thread, INFINITE); - CloseHandle(thread); +(void)CloseHandle(thread); if (uncleanCloseData.timer1Calls != 1 || uncleanCloseData.timer2Calls != 0) return 34; - CloseHandle(uncleanCloseData.timer1); +(void)CloseHandle(uncleanCloseData.timer1); #endif return 0; } diff --git a/winpr/libwinpr/synch/test/TestSynchCritical.c b/winpr/libwinpr/synch/test/TestSynchCritical.c index 800622ff5..0cdd6b847 100644 --- a/winpr/libwinpr/synch/test/TestSynchCritical.c +++ b/winpr/libwinpr/synch/test/TestSynchCritical.c @@ -263,7 +263,7 @@ static DWORD WINAPI TestSynchCritical_Main(LPVOID arg) dwThreadExitCode); goto fail; } - CloseHandle(hThreads[i]); + (void)CloseHandle(hThreads[i]); } if (gTestValueVulnerable != gTestValueSerialized) @@ -308,7 +308,7 @@ static DWORD WINAPI TestSynchCritical_Main(LPVOID arg) dwThreadExitCode); goto fail; } - CloseHandle(hThread); + (void)CloseHandle(hThread); *pbThreadTerminated = TRUE; /* requ. for winpr issue, see below */ return 0; @@ -362,7 +362,7 @@ int TestSynchCritical(int argc, char* argv[]) } GetExitCodeThread(hThread, &dwThreadExitCode); - CloseHandle(hThread); + (void)CloseHandle(hThread); if (dwThreadExitCode != 0) { diff --git a/winpr/libwinpr/synch/test/TestSynchEvent.c b/winpr/libwinpr/synch/test/TestSynchEvent.c index 083282ca4..1db566692 100644 --- a/winpr/libwinpr/synch/test/TestSynchEvent.c +++ b/winpr/libwinpr/synch/test/TestSynchEvent.c @@ -88,7 +88,7 @@ int TestSynchEvent(int argc, char* argv[]) return -1; } - CloseHandle(event); + (void)CloseHandle(event); return 0; } diff --git a/winpr/libwinpr/synch/test/TestSynchInit.c b/winpr/libwinpr/synch/test/TestSynchInit.c index 7e0ffd7c1..dcb64b468 100644 --- a/winpr/libwinpr/synch/test/TestSynchInit.c +++ b/winpr/libwinpr/synch/test/TestSynchInit.c @@ -155,11 +155,11 @@ out: winpr_aligned_free(pTestOnceFunctionCalls); winpr_aligned_free(pInitOnceExecuteOnceCalls); - CloseHandle(hStartEvent); + (void)CloseHandle(hStartEvent); for (DWORD i = 0; i < dwCreatedThreads; i++) { - CloseHandle(hThreads[i]); + (void)CloseHandle(hThreads[i]); } return (result ? 0 : 1); diff --git a/winpr/libwinpr/synch/test/TestSynchMutex.c b/winpr/libwinpr/synch/test/TestSynchMutex.c index 4744f054a..9088b1872 100644 --- a/winpr/libwinpr/synch/test/TestSynchMutex.c +++ b/winpr/libwinpr/synch/test/TestSynchMutex.c @@ -223,18 +223,18 @@ static BOOL test_mutex_threading(void) goto fail; } - CloseHandle(hThread); - CloseHandle(hStartEvent); - CloseHandle(thread1_mutex1); - CloseHandle(thread1_mutex2); + (void)CloseHandle(hThread); + (void)CloseHandle(hStartEvent); + (void)CloseHandle(thread1_mutex1); + (void)CloseHandle(thread1_mutex2); return TRUE; fail: (void)ReleaseMutex(thread1_mutex1); (void)ReleaseMutex(thread1_mutex2); - CloseHandle(thread1_mutex1); - CloseHandle(thread1_mutex2); - CloseHandle(hStartEvent); - CloseHandle(hThread); + (void)CloseHandle(thread1_mutex1); + (void)CloseHandle(thread1_mutex2); + (void)CloseHandle(hStartEvent); + (void)CloseHandle(hThread); return FALSE; } diff --git a/winpr/libwinpr/synch/test/TestSynchSemaphore.c b/winpr/libwinpr/synch/test/TestSynchSemaphore.c index d44446aac..aa29dd4a1 100644 --- a/winpr/libwinpr/synch/test/TestSynchSemaphore.c +++ b/winpr/libwinpr/synch/test/TestSynchSemaphore.c @@ -15,7 +15,7 @@ int TestSynchSemaphore(int argc, char* argv[]) return -1; } - CloseHandle(semaphore); + (void)CloseHandle(semaphore); return 0; } diff --git a/winpr/libwinpr/synch/test/TestSynchTimerQueue.c b/winpr/libwinpr/synch/test/TestSynchTimerQueue.c index 51d7fcd6c..55a88d92d 100644 --- a/winpr/libwinpr/synch/test/TestSynchTimerQueue.c +++ b/winpr/libwinpr/synch/test/TestSynchTimerQueue.c @@ -112,7 +112,7 @@ int TestSynchTimerQueue(int argc, char* argv[]) printf("DeleteTimerQueueTimer failed (%" PRIu32 ")\n", GetLastError()); return -1; } - CloseHandle(apcData[index].CompletionEvent); + (void)CloseHandle(apcData[index].CompletionEvent); } if (!DeleteTimerQueue(hTimerQueue)) diff --git a/winpr/libwinpr/synch/test/TestSynchWaitableTimer.c b/winpr/libwinpr/synch/test/TestSynchWaitableTimer.c index f61bbc141..1e7ebd6a9 100644 --- a/winpr/libwinpr/synch/test/TestSynchWaitableTimer.c +++ b/winpr/libwinpr/synch/test/TestSynchWaitableTimer.c @@ -78,6 +78,6 @@ int TestSynchWaitableTimer(int argc, char* argv[]) printf("Timer Signaled\n"); result = 0; out: - CloseHandle(timer); + (void)CloseHandle(timer); return result; } diff --git a/winpr/libwinpr/synch/test/TestSynchWaitableTimerAPC.c b/winpr/libwinpr/synch/test/TestSynchWaitableTimerAPC.c index bc289e97d..f28365b45 100644 --- a/winpr/libwinpr/synch/test/TestSynchWaitableTimerAPC.c +++ b/winpr/libwinpr/synch/test/TestSynchWaitableTimerAPC.c @@ -83,10 +83,10 @@ int TestSynchWaitableTimerAPC(int argc, char* argv[]) cleanup: if (hTimer) - CloseHandle(hTimer); + (void)CloseHandle(hTimer); if (g_Event) - CloseHandle(g_Event); + (void)CloseHandle(g_Event); return status; } diff --git a/winpr/libwinpr/thread/test/TestThreadCreateProcess.c b/winpr/libwinpr/thread/test/TestThreadCreateProcess.c index 1260c1b51..7fa458bab 100644 --- a/winpr/libwinpr/thread/test/TestThreadCreateProcess.c +++ b/winpr/libwinpr/thread/test/TestThreadCreateProcess.c @@ -79,8 +79,8 @@ int TestThreadCreateProcess(int argc, char* argv[]) printf("GetExitCodeProcess status: %" PRId32 "\n", status); printf("Process exited with code: 0x%08" PRIX32 "\n", exitCode); - CloseHandle(ProcessInformation.hProcess); - CloseHandle(ProcessInformation.hThread); + (void)CloseHandle(ProcessInformation.hProcess); + (void)CloseHandle(ProcessInformation.hThread); FreeEnvironmentStrings(lpszEnvironmentBlock); /* Test stdin,stdout,stderr redirection */ @@ -120,8 +120,8 @@ int TestThreadCreateProcess(int argc, char* argv[]) if (!status) { - CloseHandle(pipe_read); - CloseHandle(pipe_write); + (void)CloseHandle(pipe_read); + (void)CloseHandle(pipe_write); printf("CreateProcess failed. error=%" PRIu32 "\n", GetLastError()); return 1; } @@ -140,8 +140,8 @@ int TestThreadCreateProcess(int argc, char* argv[]) ret = 1; } - CloseHandle(pipe_read); - CloseHandle(pipe_write); + (void)CloseHandle(pipe_read); + (void)CloseHandle(pipe_write); exitCode = 0; status = GetExitCodeProcess(ProcessInformation.hProcess, &exitCode); @@ -149,8 +149,8 @@ int TestThreadCreateProcess(int argc, char* argv[]) printf("GetExitCodeProcess status: %" PRId32 "\n", status); printf("Process exited with code: 0x%08" PRIX32 "\n", exitCode); - CloseHandle(ProcessInformation.hProcess); - CloseHandle(ProcessInformation.hThread); + (void)CloseHandle(ProcessInformation.hProcess); + (void)CloseHandle(ProcessInformation.hThread); return ret; } diff --git a/winpr/libwinpr/thread/test/TestThreadExitThread.c b/winpr/libwinpr/thread/test/TestThreadExitThread.c index 46d81fa7f..ca7104f7e 100644 --- a/winpr/libwinpr/thread/test/TestThreadExitThread.c +++ b/winpr/libwinpr/thread/test/TestThreadExitThread.c @@ -47,7 +47,7 @@ int TestThreadExitThread(int argc, char* argv[]) return -1; } - CloseHandle(thread); + (void)CloseHandle(thread); } return 0; } diff --git a/winpr/libwinpr/utils/collections/CountdownEvent.c b/winpr/libwinpr/utils/collections/CountdownEvent.c index bbaa0fe09..487f21e35 100644 --- a/winpr/libwinpr/utils/collections/CountdownEvent.c +++ b/winpr/libwinpr/utils/collections/CountdownEvent.c @@ -204,7 +204,7 @@ void CountdownEvent_Free(wCountdownEvent* countdown) return; DeleteCriticalSection(&countdown->lock); - CloseHandle(countdown->event); + (void)CloseHandle(countdown->event); free(countdown); } diff --git a/winpr/libwinpr/utils/collections/MessageQueue.c b/winpr/libwinpr/utils/collections/MessageQueue.c index 0d1b6f312..f62e93c1c 100644 --- a/winpr/libwinpr/utils/collections/MessageQueue.c +++ b/winpr/libwinpr/utils/collections/MessageQueue.c @@ -273,7 +273,7 @@ void MessageQueue_Free(wMessageQueue* queue) if (queue->event) MessageQueue_Clear(queue); - CloseHandle(queue->event); + (void)CloseHandle(queue->event); DeleteCriticalSection(&queue->lock); free(queue->array); diff --git a/winpr/libwinpr/utils/collections/Queue.c b/winpr/libwinpr/utils/collections/Queue.c index 925d37632..8342bb0ad 100644 --- a/winpr/libwinpr/utils/collections/Queue.c +++ b/winpr/libwinpr/utils/collections/Queue.c @@ -343,7 +343,7 @@ void Queue_Free(wQueue* queue) Queue_Clear(queue); DeleteCriticalSection(&queue->lock); } - CloseHandle(queue->event); + (void)CloseHandle(queue->event); free(queue->array); free(queue); } diff --git a/winpr/libwinpr/utils/ssl.c b/winpr/libwinpr/utils/ssl.c index 08002dc1b..c4427808d 100644 --- a/winpr/libwinpr/utils/ssl.c +++ b/winpr/libwinpr/utils/ssl.c @@ -115,7 +115,7 @@ static void _winpr_openssl_dynlock_lock(int mode, struct CRYPTO_dynlock_value* d static void _winpr_openssl_dynlock_destroy(struct CRYPTO_dynlock_value* dynlock, const char* file, int line) { - CloseHandle(dynlock->mutex); + (void)CloseHandle(dynlock->mutex); free(dynlock); } @@ -150,7 +150,7 @@ static BOOL _winpr_openssl_initialize_locking(void) while (i--) { if (locks[i]) - CloseHandle(locks[i]); + (void)CloseHandle(locks[i]); } free(locks); @@ -203,7 +203,7 @@ static BOOL _winpr_openssl_cleanup_locking(void) for (int i = 0; i < g_winpr_openssl_num_locks; i++) { - CloseHandle(g_winpr_openssl_locks[i]); + (void)CloseHandle(g_winpr_openssl_locks[i]); } g_winpr_openssl_num_locks = 0; diff --git a/winpr/libwinpr/utils/test/TestMessagePipe.c b/winpr/libwinpr/utils/test/TestMessagePipe.c index c5a3ee2a6..c8b903978 100644 --- a/winpr/libwinpr/utils/test/TestMessagePipe.c +++ b/winpr/libwinpr/utils/test/TestMessagePipe.c @@ -97,9 +97,9 @@ out: if (EchoPipe) MessagePipe_Free(EchoPipe); if (ClientThread) - CloseHandle(ClientThread); + (void)CloseHandle(ClientThread); if (ServerThread) - CloseHandle(ServerThread); + (void)CloseHandle(ServerThread); return ret; } diff --git a/winpr/libwinpr/utils/test/TestMessageQueue.c b/winpr/libwinpr/utils/test/TestMessageQueue.c index b3245b1d3..0856f325f 100644 --- a/winpr/libwinpr/utils/test/TestMessageQueue.c +++ b/winpr/libwinpr/utils/test/TestMessageQueue.c @@ -50,7 +50,7 @@ int TestMessageQueue(int argc, char* argv[]) return -1; MessageQueue_Free(queue); - CloseHandle(thread); + (void)CloseHandle(thread); return 0; } diff --git a/winpr/libwinpr/winsock/winsock.c b/winpr/libwinpr/winsock/winsock.c index bb2b60c6c..1b053de4c 100644 --- a/winpr/libwinpr/winsock/winsock.c +++ b/winpr/libwinpr/winsock/winsock.c @@ -736,8 +736,7 @@ BOOL WSAResetEvent(HANDLE hEvent) BOOL WSACloseEvent(HANDLE hEvent) { - BOOL status = 0; - status = CloseHandle(hEvent); + BOOL status = CloseHandle(hEvent); if (!status) SetLastError(6); diff --git a/winpr/libwinpr/wtsapi/wtsapi_win32.c b/winpr/libwinpr/wtsapi/wtsapi_win32.c index b0cce7896..75d44a6e6 100644 --- a/winpr/libwinpr/wtsapi/wtsapi_win32.c +++ b/winpr/libwinpr/wtsapi/wtsapi_win32.c @@ -201,7 +201,7 @@ HANDLE WINAPI Win32_WTSVirtualChannelOpen_Internal(HANDLE hServer, DWORD Session if (!pChannel) { - CloseHandle(hFile); + (void)CloseHandle(hFile); SetLastError(ERROR_NOT_ENOUGH_MEMORY); return NULL; } @@ -214,7 +214,7 @@ HANDLE WINAPI Win32_WTSVirtualChannelOpen_Internal(HANDLE hServer, DWORD Session pChannel->VirtualName = _wts_calloc(1, virtualNameLen + 1); if (!pChannel->VirtualName) { - CloseHandle(hFile); + (void)CloseHandle(hFile); SetLastError(ERROR_NOT_ENOUGH_MEMORY); _wts_free(pChannel); return NULL; @@ -280,7 +280,7 @@ BOOL WINAPI Win32_WTSVirtualChannelClose(HANDLE hChannel) if (pChannel->hEvent) { - CloseHandle(pChannel->hEvent); + (void)CloseHandle(pChannel->hEvent); pChannel->hEvent = NULL; } From bb242b9a896cd85186e882057303c22de846a16d Mon Sep 17 00:00:00 2001 From: akallabeth Date: Mon, 16 Sep 2024 05:06:07 +0200 Subject: [PATCH 11/13] [return checks] fix use of WaitForSingleObject --- channels/rdpecam/client/v4l/camera_v4l.c | 3 ++- channels/rdpei/client/rdpei_main.c | 2 +- channels/rdpsnd/client/rdpsnd_main.c | 2 +- channels/rdpsnd/client/winmm/rdpsnd_winmm.c | 2 +- channels/serial/client/serial_main.c | 2 +- channels/urbdrc/client/libusb/libusb_udevman.c | 4 ++-- client/Windows/wf_client.c | 2 +- client/Windows/wf_cliprdr.c | 2 +- client/X11/cli/xfreerdp.c | 2 +- client/X11/xf_client.c | 4 ++-- client/common/client.c | 2 +- client/common/client_cliprdr_file.c | 2 +- libfreerdp/core/gateway/tsg.c | 2 +- libfreerdp/core/message.c | 2 +- libfreerdp/core/test/TestConnect.c | 4 ++-- server/Sample/sfreerdp.c | 2 +- server/Windows/cli/wfreerdp.c | 2 +- server/Windows/wf_peer.c | 2 +- server/Windows/wf_update.c | 2 +- server/proxy/pf_server.c | 2 +- server/shadow/Win/win_rdp.c | 2 +- server/shadow/X11/x11_shadow.c | 2 +- server/shadow/shadow.c | 2 +- server/shadow/shadow_mcevent.c | 4 ++-- server/shadow/shadow_server.c | 2 +- winpr/libwinpr/error/test/TestErrorSetLastError.c | 8 ++++---- winpr/libwinpr/pipe/test/TestPipeCreateNamedPipe.c | 10 +++++----- winpr/libwinpr/pool/pool.c | 2 +- winpr/libwinpr/sspi/test/TestSchannel.c | 2 +- winpr/libwinpr/synch/barrier.c | 2 +- winpr/libwinpr/synch/test/TestSynchAPC.c | 6 +++--- winpr/libwinpr/utils/ssl.c | 4 ++-- winpr/libwinpr/utils/test/TestMessagePipe.c | 4 ++-- 33 files changed, 49 insertions(+), 48 deletions(-) diff --git a/channels/rdpecam/client/v4l/camera_v4l.c b/channels/rdpecam/client/v4l/camera_v4l.c index 601ba083e..d1a76b287 100644 --- a/channels/rdpecam/client/v4l/camera_v4l.c +++ b/channels/rdpecam/client/v4l/camera_v4l.c @@ -27,6 +27,7 @@ #include #include "camera.h" +#include #define TAG CHANNELS_TAG("rdpecam-v4l.client") @@ -530,7 +531,7 @@ UINT cam_v4l_stream_stop(CamV4lStream* stream) if (stream->captureThread) { - WaitForSingleObject(stream->captureThread, INFINITE); + (void)WaitForSingleObject(stream->captureThread, INFINITE); (void)CloseHandle(stream->captureThread); stream->captureThread = NULL; } diff --git a/channels/rdpei/client/rdpei_main.c b/channels/rdpei/client/rdpei_main.c index 4adb700d5..802b737de 100644 --- a/channels/rdpei/client/rdpei_main.c +++ b/channels/rdpei/client/rdpei_main.c @@ -1446,7 +1446,7 @@ static void terminate_plugin_cb(GENERIC_DYNVC_PLUGIN* base) if (rdpei->thread) { - WaitForSingleObject(rdpei->thread, INFINITE); + (void)WaitForSingleObject(rdpei->thread, INFINITE); (void)CloseHandle(rdpei->thread); } diff --git a/channels/rdpsnd/client/rdpsnd_main.c b/channels/rdpsnd/client/rdpsnd_main.c index 6efefbeea..fe72e03cf 100644 --- a/channels/rdpsnd/client/rdpsnd_main.c +++ b/channels/rdpsnd/client/rdpsnd_main.c @@ -1461,7 +1461,7 @@ void rdpsnd_virtual_channel_event_terminated(rdpsndPlugin* rdpsnd) if (rdpsnd->thread) { - WaitForSingleObject(rdpsnd->thread, INFINITE); + (void)WaitForSingleObject(rdpsnd->thread, INFINITE); (void)CloseHandle(rdpsnd->thread); } MessageQueue_Free(rdpsnd->queue); diff --git a/channels/rdpsnd/client/winmm/rdpsnd_winmm.c b/channels/rdpsnd/client/winmm/rdpsnd_winmm.c index 6a39aebbb..fd4c471b2 100644 --- a/channels/rdpsnd/client/winmm/rdpsnd_winmm.c +++ b/channels/rdpsnd/client/winmm/rdpsnd_winmm.c @@ -180,7 +180,7 @@ static void rdpsnd_winmm_close(rdpsndDevicePlugin* device) if (winmm->hThread) { - WaitForSingleObject(winmm->hThread, INFINITE); + (void)WaitForSingleObject(winmm->hThread, INFINITE); (void)CloseHandle(winmm->hThread); winmm->hThread = NULL; } diff --git a/channels/serial/client/serial_main.c b/channels/serial/client/serial_main.c index fe363a46e..6ea2ec28e 100644 --- a/channels/serial/client/serial_main.c +++ b/channels/serial/client/serial_main.c @@ -826,7 +826,7 @@ static void irp_thread_close(void* arg) else { (void)TerminateThread(hdl, 0); - WaitForSingleObject(hdl, INFINITE); + (void)WaitForSingleObject(hdl, INFINITE); (void)CloseHandle(hdl); } } diff --git a/channels/urbdrc/client/libusb/libusb_udevman.c b/channels/urbdrc/client/libusb/libusb_udevman.c index 1c5f45555..fc9edc627 100644 --- a/channels/urbdrc/client/libusb/libusb_udevman.c +++ b/channels/urbdrc/client/libusb/libusb_udevman.c @@ -436,7 +436,7 @@ static IUDEVICE* udevman_get_udevice_by_ChannelID(IUDEVMAN* idevman, UINT32 chan static void udevman_loading_lock(IUDEVMAN* idevman) { UDEVMAN* udevman = (UDEVMAN*)idevman; - WaitForSingleObject(udevman->devman_loading, INFINITE); + (void)WaitForSingleObject(udevman->devman_loading, INFINITE); } static void udevman_loading_unlock(IUDEVMAN* idevman) @@ -469,7 +469,7 @@ static void udevman_free(IUDEVMAN* idevman) udevman->running = FALSE; if (udevman->thread) { - WaitForSingleObject(udevman->thread, INFINITE); + (void)WaitForSingleObject(udevman->thread, INFINITE); (void)CloseHandle(udevman->thread); } diff --git a/client/Windows/wf_client.c b/client/Windows/wf_client.c index 647090265..fc6d68f7a 100644 --- a/client/Windows/wf_client.c +++ b/client/Windows/wf_client.c @@ -1466,7 +1466,7 @@ static int wfreerdp_client_stop(rdpContext* context) if (wfc->keyboardThread) { PostThreadMessage(wfc->keyboardThreadId, WM_QUIT, 0, 0); - WaitForSingleObject(wfc->keyboardThread, INFINITE); + (void)WaitForSingleObject(wfc->keyboardThread, INFINITE); (void)CloseHandle(wfc->keyboardThread); wfc->keyboardThread = NULL; wfc->keyboardThreadId = 0; diff --git a/client/Windows/wf_cliprdr.c b/client/Windows/wf_cliprdr.c index 63f4b3fee..bda8ef3b8 100644 --- a/client/Windows/wf_cliprdr.c +++ b/client/Windows/wf_cliprdr.c @@ -2535,7 +2535,7 @@ BOOL wf_cliprdr_uninit(wfContext* wfc, CliprdrClientContext* cliprdr) if (clipboard->thread) { - WaitForSingleObject(clipboard->thread, INFINITE); + (void)WaitForSingleObject(clipboard->thread, INFINITE); (void)CloseHandle(clipboard->thread); } diff --git a/client/X11/cli/xfreerdp.c b/client/X11/cli/xfreerdp.c index ae17db532..97e31d5f2 100644 --- a/client/X11/cli/xfreerdp.c +++ b/client/X11/cli/xfreerdp.c @@ -96,7 +96,7 @@ int main(int argc, char* argv[]) thread = freerdp_client_get_thread(context); - WaitForSingleObject(thread, INFINITE); + (void)WaitForSingleObject(thread, INFINITE); GetExitCodeThread(thread, &dwExitCode); rc = xf_exit_code_from_disconnect_reason(dwExitCode); diff --git a/client/X11/xf_client.c b/client/X11/xf_client.c index 3cf227e42..f1c92ade5 100644 --- a/client/X11/xf_client.c +++ b/client/X11/xf_client.c @@ -805,7 +805,7 @@ void xf_lock_x11_(xfContext* xfc, const char* fkt) { if (!xfc->UseXThreads) - WaitForSingleObject(xfc->mutex, INFINITE); + (void)WaitForSingleObject(xfc->mutex, INFINITE); else XLockDisplay(xfc->display); @@ -1451,7 +1451,7 @@ static void xf_post_disconnect(freerdp* instance) if (xfc->pipethread) { - WaitForSingleObject(xfc->pipethread, INFINITE); + (void)WaitForSingleObject(xfc->pipethread, INFINITE); (void)CloseHandle(xfc->pipethread); xfc->pipethread = NULL; } diff --git a/client/common/client.c b/client/common/client.c index 78805a8f8..001ae7571 100644 --- a/client/common/client.c +++ b/client/common/client.c @@ -1339,7 +1339,7 @@ int freerdp_client_common_stop(rdpContext* context) if (cctx->thread) { - WaitForSingleObject(cctx->thread, INFINITE); + (void)WaitForSingleObject(cctx->thread, INFINITE); (void)CloseHandle(cctx->thread); cctx->thread = NULL; } diff --git a/client/common/client_cliprdr_file.c b/client/common/client_cliprdr_file.c index 7f86187fb..efba81713 100644 --- a/client/common/client_cliprdr_file.c +++ b/client/common/client_cliprdr_file.c @@ -2078,7 +2078,7 @@ void cliprdr_file_context_free(CliprdrFileContext* file) cliprdr_file_session_terminate(file, TRUE); WLog_Print(file->log, WLOG_DEBUG, "Waiting on FUSE thread"); - WaitForSingleObject(file->fuse_thread, INFINITE); + (void)WaitForSingleObject(file->fuse_thread, INFINITE); (void)CloseHandle(file->fuse_thread); } if (file->fuse_stop_sync) diff --git a/libfreerdp/core/gateway/tsg.c b/libfreerdp/core/gateway/tsg.c index abd219bbf..06592d5d0 100644 --- a/libfreerdp/core/gateway/tsg.c +++ b/libfreerdp/core/gateway/tsg.c @@ -2844,7 +2844,7 @@ static int tsg_read(rdpTsg* tsg, BYTE* data, size_t length) if (!tsg_check_event_handles(tsg)) return -1; - WaitForSingleObject(rpc->client->PipeEvent, 100); + (void)WaitForSingleObject(rpc->client->PipeEvent, 100); } } } while (transport_get_blocking(rpc->transport)); diff --git a/libfreerdp/core/message.c b/libfreerdp/core/message.c index be9936bdd..353e5ec4b 100644 --- a/libfreerdp/core/message.c +++ b/libfreerdp/core/message.c @@ -2905,7 +2905,7 @@ void update_message_proxy_free(rdpUpdateProxy* message) { rdp_update_internal* up = update_cast(message->update); if (MessageQueue_PostQuit(up->queue, 0)) - WaitForSingleObject(message->thread, INFINITE); + (void)WaitForSingleObject(message->thread, INFINITE); (void)CloseHandle(message->thread); free(message); diff --git a/libfreerdp/core/test/TestConnect.c b/libfreerdp/core/test/TestConnect.c index 350031ffb..31f6019ef 100644 --- a/libfreerdp/core/test/TestConnect.c +++ b/libfreerdp/core/test/TestConnect.c @@ -148,7 +148,7 @@ static int testAbort(int port) return -1; } - WaitForSingleObject(s_sync, INFINITE); + (void)WaitForSingleObject(s_sync, INFINITE); Sleep(100); /* Wait until freerdp_connect has been called */ if (instance) { @@ -293,7 +293,7 @@ static int testSuccess(int port) if (!TerminateProcess(process.hProcess, 0)) goto fail; - WaitForSingleObject(process.hProcess, INFINITE); + (void)WaitForSingleObject(process.hProcess, INFINITE); (void)CloseHandle(process.hProcess); (void)CloseHandle(process.hThread); printf("%s: returned %d!\n", __func__, r); diff --git a/server/Sample/sfreerdp.c b/server/Sample/sfreerdp.c index 608e9cfd9..d466c1241 100644 --- a/server/Sample/sfreerdp.c +++ b/server/Sample/sfreerdp.c @@ -83,7 +83,7 @@ static void test_peer_context_free(freerdp_peer* client, rdpContext* ctx) { WINPR_ASSERT(context->stopEvent); (void)SetEvent(context->stopEvent); - WaitForSingleObject(context->debug_channel_thread, INFINITE); + (void)WaitForSingleObject(context->debug_channel_thread, INFINITE); (void)CloseHandle(context->debug_channel_thread); } diff --git a/server/Windows/cli/wfreerdp.c b/server/Windows/cli/wfreerdp.c index efc1bf51b..110bce3a5 100644 --- a/server/Windows/cli/wfreerdp.c +++ b/server/Windows/cli/wfreerdp.c @@ -163,7 +163,7 @@ int main(int argc, char* argv[]) WLog_INFO(TAG, "Starting server"); wfreerdp_server_start(server); - WaitForSingleObject(server->thread, INFINITE); + (void)WaitForSingleObject(server->thread, INFINITE); WLog_INFO(TAG, "Stopping server"); wfreerdp_server_stop(server); wfreerdp_server_free(server); diff --git a/server/Windows/wf_peer.c b/server/Windows/wf_peer.c index cfadf6926..1fb60ffb7 100644 --- a/server/Windows/wf_peer.c +++ b/server/Windows/wf_peer.c @@ -218,7 +218,7 @@ static DWORD WINAPI wf_peer_socket_listener(LPVOID lpParam) } (void)SetEvent(context->socketEvent); - WaitForSingleObject(context->socketSemaphore, INFINITE); + (void)WaitForSingleObject(context->socketSemaphore, INFINITE); if (context->socketClose) break; diff --git a/server/Windows/wf_update.c b/server/Windows/wf_update.c index 1a6b02d5b..8867efb84 100644 --- a/server/Windows/wf_update.c +++ b/server/Windows/wf_update.c @@ -80,7 +80,7 @@ DWORD WINAPI wf_update_thread(LPVOID lpParam) { // WLog_DBG(TAG, "Waiting for %d of %d", index + 1, wfi->activePeerCount); // WaitForSingleObject(wfi->updateSemaphore, INFINITE); - WaitForSingleObject(wfi->updateSemaphore, 1000); + (void)WaitForSingleObject(wfi->updateSemaphore, 1000); } // WLog_DBG(TAG, "End of parallel sending"); diff --git a/server/proxy/pf_server.c b/server/proxy/pf_server.c index 0415438e7..6955e5229 100644 --- a/server/proxy/pf_server.c +++ b/server/proxy/pf_server.c @@ -719,7 +719,7 @@ out_free_peer: if (pdata && pdata->client_thread) { proxy_data_abort_connect(pdata); - WaitForSingleObject(pdata->client_thread, INFINITE); + (void)WaitForSingleObject(pdata->client_thread, INFINITE); } { diff --git a/server/shadow/Win/win_rdp.c b/server/shadow/Win/win_rdp.c index 077a6787f..3332f1e64 100644 --- a/server/shadow/Win/win_rdp.c +++ b/server/shadow/Win/win_rdp.c @@ -80,7 +80,7 @@ static BOOL shw_end_paint(rdpContext* context) } (void)SetEvent(subsystem->RdpUpdateEnterEvent); - WaitForSingleObject(subsystem->RdpUpdateLeaveEvent, INFINITE); + (void)WaitForSingleObject(subsystem->RdpUpdateLeaveEvent, INFINITE); (void)ResetEvent(subsystem->RdpUpdateLeaveEvent); return TRUE; } diff --git a/server/shadow/X11/x11_shadow.c b/server/shadow/X11/x11_shadow.c index f11d9e038..298c6db4e 100644 --- a/server/shadow/X11/x11_shadow.c +++ b/server/shadow/X11/x11_shadow.c @@ -1460,7 +1460,7 @@ static int x11_shadow_subsystem_stop(rdpShadowSubsystem* sub) if (subsystem->thread) { if (MessageQueue_PostQuit(subsystem->common.MsgPipe->In, 0)) - WaitForSingleObject(subsystem->thread, INFINITE); + (void)WaitForSingleObject(subsystem->thread, INFINITE); (void)CloseHandle(subsystem->thread); subsystem->thread = NULL; diff --git a/server/shadow/shadow.c b/server/shadow/shadow.c index 614305cc7..59c3b074f 100644 --- a/server/shadow/shadow.c +++ b/server/shadow/shadow.c @@ -172,7 +172,7 @@ int main(int argc, char** argv) } #endif - WaitForSingleObject(server->thread, INFINITE); + (void)WaitForSingleObject(server->thread, INFINITE); if (!GetExitCodeThread(server->thread, &dwExitCode)) status = -1; diff --git a/server/shadow/shadow_mcevent.c b/server/shadow/shadow_mcevent.c index 602062380..905f5aa74 100644 --- a/server/shadow/shadow_mcevent.c +++ b/server/shadow/shadow_mcevent.c @@ -140,7 +140,7 @@ static void WaitForSubscribers(rdpShadowMultiClientEvent* event) /* Wait for clients done */ WLog_VRB(TAG, "Server wait event %d. %d clients.\n", event->eventid, event->consuming); LeaveCriticalSection(&(event->lock)); - WaitForSingleObject(event->doneEvent, INFINITE); + (void)WaitForSingleObject(event->doneEvent, INFINITE); EnterCriticalSection(&(event->lock)); WLog_VRB(TAG, "Server quit event %d. %d clients.\n", event->eventid, event->consuming); } @@ -219,7 +219,7 @@ static BOOL Consume(struct rdp_shadow_multiclient_subscriber* subscriber, BOOL w */ event->waiting++; LeaveCriticalSection(&(event->lock)); - WaitForSingleObject(event->barrierEvent, INFINITE); + (void)WaitForSingleObject(event->barrierEvent, INFINITE); EnterCriticalSection(&(event->lock)); event->waiting--; if (event->waiting == 0) diff --git a/server/shadow/shadow_server.c b/server/shadow/shadow_server.c index 40d41bb63..bc72637fd 100644 --- a/server/shadow/shadow_server.c +++ b/server/shadow/shadow_server.c @@ -743,7 +743,7 @@ int shadow_server_stop(rdpShadowServer* server) if (server->thread) { (void)SetEvent(server->StopEvent); - WaitForSingleObject(server->thread, INFINITE); + (void)WaitForSingleObject(server->thread, INFINITE); (void)CloseHandle(server->thread); server->thread = NULL; if (server->listener && server->listener->Close) diff --git a/winpr/libwinpr/error/test/TestErrorSetLastError.c b/winpr/libwinpr/error/test/TestErrorSetLastError.c index 310757cb0..b274addc6 100644 --- a/winpr/libwinpr/error/test/TestErrorSetLastError.c +++ b/winpr/libwinpr/error/test/TestErrorSetLastError.c @@ -113,10 +113,10 @@ int TestErrorSetLastError(int argc, char* argv[]) Sleep(200); bStopTest = TRUE; - WaitForSingleObject(threads[0], INFINITE); - WaitForSingleObject(threads[1], INFINITE); - WaitForSingleObject(threads[2], INFINITE); - WaitForSingleObject(threads[3], INFINITE); + (void)WaitForSingleObject(threads[0], INFINITE); + (void)WaitForSingleObject(threads[1], INFINITE); + (void)WaitForSingleObject(threads[2], INFINITE); + (void)WaitForSingleObject(threads[3], INFINITE); (void)CloseHandle(threads[0]); (void)CloseHandle(threads[1]); diff --git a/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipe.c b/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipe.c index f7b5da243..314a9c4e2 100644 --- a/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipe.c +++ b/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipe.c @@ -33,7 +33,7 @@ static DWORD WINAPI named_pipe_client_thread(LPVOID arg) DWORD nNumberOfBytesToWrite = 0; DWORD lpNumberOfBytesRead = 0; DWORD lpNumberOfBytesWritten = 0; - WaitForSingleObject(ReadyEvent, INFINITE); + (void)WaitForSingleObject(ReadyEvent, INFINITE); hNamedPipe = CreateFile(lpszPipeNameMt, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); @@ -198,7 +198,7 @@ static DWORD WINAPI named_pipe_single_thread(LPVOID arg) int numPipes = 0; BOOL bSuccess = FALSE; numPipes = TESTNUMPIPESST; - WaitForSingleObject(ReadyEvent, INFINITE); + (void)WaitForSingleObject(ReadyEvent, INFINITE); for (int i = 0; i < numPipes; i++) { @@ -500,9 +500,9 @@ int TestPipeCreateNamedPipe(int argc, char* argv[]) printf("CreateThread (ServerThread) failure: (%" PRIu32 ")\n", GetLastError()); return -1; } - WaitForSingleObject(SingleThread, INFINITE); - WaitForSingleObject(ClientThread, INFINITE); - WaitForSingleObject(ServerThread, INFINITE); + (void)WaitForSingleObject(SingleThread, INFINITE); + (void)WaitForSingleObject(ClientThread, INFINITE); + (void)WaitForSingleObject(ServerThread, INFINITE); (void)CloseHandle(SingleThread); (void)CloseHandle(ClientThread); (void)CloseHandle(ServerThread); diff --git a/winpr/libwinpr/pool/pool.c b/winpr/libwinpr/pool/pool.c index 790f16189..39bbaaac9 100644 --- a/winpr/libwinpr/pool/pool.c +++ b/winpr/libwinpr/pool/pool.c @@ -100,7 +100,7 @@ static DWORD WINAPI thread_pool_work_func(LPVOID arg) static void threads_close(void* thread) { - WaitForSingleObject(thread, INFINITE); + (void)WaitForSingleObject(thread, INFINITE); (void)CloseHandle(thread); } diff --git a/winpr/libwinpr/sspi/test/TestSchannel.c b/winpr/libwinpr/sspi/test/TestSchannel.c index 3f9751a98..6e504376d 100644 --- a/winpr/libwinpr/sspi/test/TestSchannel.c +++ b/winpr/libwinpr/sspi/test/TestSchannel.c @@ -848,7 +848,7 @@ int TestSchannel(int argc, char* argv[]) schannel_send(table, g_ServerWritePipe, &context, test_LastDummyMessage, sizeof(test_LastDummyMessage)); - WaitForSingleObject(thread, INFINITE); + (void)WaitForSingleObject(thread, INFINITE); sspi_GlobalFinish(); return 0; } diff --git a/winpr/libwinpr/synch/barrier.c b/winpr/libwinpr/synch/barrier.c index 610adbb71..8d2680bc2 100644 --- a/winpr/libwinpr/synch/barrier.c +++ b/winpr/libwinpr/synch/barrier.c @@ -208,7 +208,7 @@ BOOL WINAPI winpr_EnterSynchronizationBarrier(LPSYNCHRONIZATION_BARRIER lpBarrie } if (block) - WaitForSingleObject(hCurrentEvent, INFINITE); + (void)WaitForSingleObject(hCurrentEvent, INFINITE); return FALSE; } diff --git a/winpr/libwinpr/synch/test/TestSynchAPC.c b/winpr/libwinpr/synch/test/TestSynchAPC.c index edff1c0cf..2cd7f897a 100644 --- a/winpr/libwinpr/synch/test/TestSynchAPC.c +++ b/winpr/libwinpr/synch/test/TestSynchAPC.c @@ -127,7 +127,7 @@ int TestSynchAPC(int argc, char* argv[]) thread = CreateThread(NULL, 0, uncleanThread, &userApcArg, 0, NULL); if (!thread) return 10; - WaitForSingleObject(thread, INFINITE); + (void)WaitForSingleObject(thread, INFINITE); (void)CloseHandle(thread); if (userApcArg.called || userApcArg.error) @@ -141,7 +141,7 @@ int TestSynchAPC(int argc, char* argv[]) if (!QueueUserAPC((PAPCFUNC)userApc, thread, (ULONG_PTR)&userApcArg)) return 21; - WaitForSingleObject(thread, INFINITE); + (void)WaitForSingleObject(thread, INFINITE); (void)CloseHandle(thread); if (!userApcArg.called) @@ -162,7 +162,7 @@ int TestSynchAPC(int argc, char* argv[]) if (!thread) return 33; - WaitForSingleObject(thread, INFINITE); + (void)WaitForSingleObject(thread, INFINITE); (void)CloseHandle(thread); if (uncleanCloseData.timer1Calls != 1 || uncleanCloseData.timer2Calls != 0) diff --git a/winpr/libwinpr/utils/ssl.c b/winpr/libwinpr/utils/ssl.c index c4427808d..fe498934f 100644 --- a/winpr/libwinpr/utils/ssl.c +++ b/winpr/libwinpr/utils/ssl.c @@ -75,7 +75,7 @@ static void _winpr_openssl_locking(int mode, int type, const char* file, int lin { if (mode & CRYPTO_LOCK) { - WaitForSingleObject(g_winpr_openssl_locks[type], INFINITE); + (void)WaitForSingleObject(g_winpr_openssl_locks[type], INFINITE); } else { @@ -104,7 +104,7 @@ static void _winpr_openssl_dynlock_lock(int mode, struct CRYPTO_dynlock_value* d { if (mode & CRYPTO_LOCK) { - WaitForSingleObject(dynlock->mutex, INFINITE); + (void)WaitForSingleObject(dynlock->mutex, INFINITE); } else { diff --git a/winpr/libwinpr/utils/test/TestMessagePipe.c b/winpr/libwinpr/utils/test/TestMessagePipe.c index c8b903978..bfa4ab6d5 100644 --- a/winpr/libwinpr/utils/test/TestMessagePipe.c +++ b/winpr/libwinpr/utils/test/TestMessagePipe.c @@ -88,8 +88,8 @@ int TestMessagePipe(int argc, char* argv[]) goto out; } - WaitForSingleObject(ClientThread, INFINITE); - WaitForSingleObject(ServerThread, INFINITE); + (void)WaitForSingleObject(ClientThread, INFINITE); + (void)WaitForSingleObject(ServerThread, INFINITE); ret = 0; From a19305569dad90e67dc7ac531ca65c813cc782d1 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Mon, 16 Sep 2024 06:45:05 +0200 Subject: [PATCH 12/13] [assert] fix ULONG_MAX use most of the time this was used to check ULONG limits. Replace with correct UINT32_MAX --- channels/ainput/server/ainput_main.c | 2 +- channels/audin/client/audin_main.c | 2 +- channels/audin/server/audin.c | 2 +- channels/rdpdr/server/rdpdr_main.c | 4 ++-- libfreerdp/core/nla.c | 2 +- server/proxy/channels/pf_channel_rdpdr.c | 2 +- winpr/libwinpr/sspi/NTLM/ntlm_av_pairs.c | 2 +- winpr/libwinpr/sspi/NTLM/ntlm_message.c | 10 +++++----- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/channels/ainput/server/ainput_main.c b/channels/ainput/server/ainput_main.c index 5659d5163..4da1655ed 100644 --- a/channels/ainput/server/ainput_main.c +++ b/channels/ainput/server/ainput_main.c @@ -176,7 +176,7 @@ static UINT ainput_server_send_version(ainput_server* ainput) Stream_Write_UINT32(s, AINPUT_VERSION_MAJOR); /* Version (4 bytes) */ Stream_Write_UINT32(s, AINPUT_VERSION_MINOR); /* Version (4 bytes) */ - WINPR_ASSERT(Stream_GetPosition(s) <= ULONG_MAX); + WINPR_ASSERT(Stream_GetPosition(s) <= UINT32_MAX); if (!WTSVirtualChannelWrite(ainput->ainput_channel, (PCHAR)Stream_Buffer(s), (ULONG)Stream_GetPosition(s), &written)) { diff --git a/channels/audin/client/audin_main.c b/channels/audin/client/audin_main.c index 01ea72182..66a35a3d4 100644 --- a/channels/audin/client/audin_main.c +++ b/channels/audin/client/audin_main.c @@ -113,7 +113,7 @@ static UINT audin_channel_write_and_free(AUDIN_CHANNEL_CALLBACK* callback, wStre return ERROR_INTERNAL_ERROR; Stream_SealLength(out); - WINPR_ASSERT(Stream_Length(out) <= ULONG_MAX); + WINPR_ASSERT(Stream_Length(out) <= UINT32_MAX); const UINT error = callback->channel->Write(callback->channel, (ULONG)Stream_Length(out), Stream_Buffer(out), NULL); diff --git a/channels/audin/server/audin.c b/channels/audin/server/audin.c index 0726632a8..d2da95abc 100644 --- a/channels/audin/server/audin.c +++ b/channels/audin/server/audin.c @@ -378,7 +378,7 @@ static DWORD WINAPI audin_server_thread_func(LPVOID arg) if (!Stream_EnsureRemainingCapacity(s, BytesReturned)) break; - WINPR_ASSERT(Stream_Capacity(s) <= ULONG_MAX); + WINPR_ASSERT(Stream_Capacity(s) <= UINT32_MAX); if (WTSVirtualChannelRead(audin->audin_channel, 0, (PCHAR)Stream_Buffer(s), (ULONG)Stream_Capacity(s), &BytesReturned) == FALSE) { diff --git a/channels/rdpdr/server/rdpdr_main.c b/channels/rdpdr/server/rdpdr_main.c index e0fde30a2..8742996f0 100644 --- a/channels/rdpdr/server/rdpdr_main.c +++ b/channels/rdpdr/server/rdpdr_main.c @@ -215,7 +215,7 @@ static UINT rdpdr_seal_send_free_request(RdpdrServerContext* context, wStream* s Stream_SealLength(s); length = Stream_Length(s); - WINPR_ASSERT(length <= ULONG_MAX); + WINPR_ASSERT(length <= UINT32_MAX); Stream_SetPosition(s, 0); if (length >= RDPDR_HEADER_LENGTH) @@ -2077,7 +2077,7 @@ static DWORD WINAPI rdpdr_server_thread(LPVOID arg) break; } - capacity = MIN(Stream_Capacity(s), ULONG_MAX); + capacity = MIN(Stream_Capacity(s), UINT32_MAX); if (!WTSVirtualChannelRead(context->priv->ChannelHandle, 0, (PCHAR)Stream_Buffer(s), (ULONG)capacity, &BytesReturned)) { diff --git a/libfreerdp/core/nla.c b/libfreerdp/core/nla.c index 4c471d36f..9235e80be 100644 --- a/libfreerdp/core/nla.c +++ b/libfreerdp/core/nla.c @@ -177,7 +177,7 @@ static BOOL nla_sec_buffer_alloc(SecBuffer* buffer, size_t size) { WINPR_ASSERT(buffer); sspi_SecBufferFree(buffer); - if (size > ULONG_MAX) + if (size > UINT32_MAX) return FALSE; if (!sspi_SecBufferAlloc(buffer, (ULONG)size)) return FALSE; diff --git a/server/proxy/channels/pf_channel_rdpdr.c b/server/proxy/channels/pf_channel_rdpdr.c index 61e5330e3..402b47481 100644 --- a/server/proxy/channels/pf_channel_rdpdr.c +++ b/server/proxy/channels/pf_channel_rdpdr.c @@ -259,7 +259,7 @@ static UINT rdpdr_seal_send_free_request(pf_channel_server_context* context, wSt Stream_SealLength(s); len = Stream_Length(s); - WINPR_ASSERT(len <= ULONG_MAX); + WINPR_ASSERT(len <= UINT32_MAX); rdpdr_dump_send_packet(context->log, WLOG_TRACE, s, proxy_client_tx); status = WTSVirtualChannelWrite(context->handle, (char*)Stream_Buffer(s), (ULONG)len, NULL); diff --git a/winpr/libwinpr/sspi/NTLM/ntlm_av_pairs.c b/winpr/libwinpr/sspi/NTLM/ntlm_av_pairs.c index b270947a5..9b0d00c66 100644 --- a/winpr/libwinpr/sspi/NTLM/ntlm_av_pairs.c +++ b/winpr/libwinpr/sspi/NTLM/ntlm_av_pairs.c @@ -135,7 +135,7 @@ ULONG ntlm_av_pair_list_length(NTLM_AV_PAIR* pAvPairList, size_t cbAvPairList) return 0; const size_t size = ((PBYTE)pAvPair - (PBYTE)pAvPairList) + sizeof(NTLM_AV_PAIR); - WINPR_ASSERT(size <= ULONG_MAX); + WINPR_ASSERT(size <= UINT32_MAX); WINPR_ASSERT(size >= 0); return (ULONG)size; } diff --git a/winpr/libwinpr/sspi/NTLM/ntlm_message.c b/winpr/libwinpr/sspi/NTLM/ntlm_message.c index 511ca4765..4a757fd0f 100644 --- a/winpr/libwinpr/sspi/NTLM/ntlm_message.c +++ b/winpr/libwinpr/sspi/NTLM/ntlm_message.c @@ -544,7 +544,7 @@ SECURITY_STATUS ntlm_read_NegotiateMessage(NTLM_CONTEXT* context, PSecBuffer buf return SEC_E_INVALID_TOKEN; length = Stream_GetPosition(s); - WINPR_ASSERT(length <= ULONG_MAX); + WINPR_ASSERT(length <= UINT32_MAX); buffer->cbBuffer = (ULONG)length; if (!sspi_SecBufferAlloc(&context->NegotiateMessage, (ULONG)length)) @@ -634,7 +634,7 @@ SECURITY_STATUS ntlm_write_NegotiateMessage(NTLM_CONTEXT* context, const PSecBuf } length = Stream_GetPosition(s); - WINPR_ASSERT(length <= ULONG_MAX); + WINPR_ASSERT(length <= UINT32_MAX); buffer->cbBuffer = (ULONG)length; if (!sspi_SecBufferAlloc(&context->NegotiateMessage, (ULONG)length)) @@ -895,7 +895,7 @@ SECURITY_STATUS ntlm_write_ChallengeMessage(NTLM_CONTEXT* context, const PSecBuf } length = Stream_GetPosition(s); - WINPR_ASSERT(length <= ULONG_MAX); + WINPR_ASSERT(length <= UINT32_MAX); buffer->cbBuffer = (ULONG)length; if (!sspi_SecBufferAlloc(&context->ChallengeMessage, (ULONG)length)) @@ -1043,7 +1043,7 @@ SECURITY_STATUS ntlm_read_AuthenticateMessage(NTLM_CONTEXT* context, PSecBuffer } length = Stream_GetPosition(s); - WINPR_ASSERT(length <= ULONG_MAX); + WINPR_ASSERT(length <= UINT32_MAX); if (!sspi_SecBufferAlloc(&context->AuthenticateMessage, (ULONG)length)) goto fail; @@ -1368,7 +1368,7 @@ SECURITY_STATUS ntlm_write_AuthenticateMessage(NTLM_CONTEXT* context, const PSec } length = Stream_GetPosition(s); - WINPR_ASSERT(length <= ULONG_MAX); + WINPR_ASSERT(length <= UINT32_MAX); if (!sspi_SecBufferAlloc(&context->AuthenticateMessage, (ULONG)length)) return SEC_E_INTERNAL_ERROR; From befa4233ad881c2c9f2a44ab9eb481f2a41ca6a1 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Mon, 16 Sep 2024 07:24:32 +0200 Subject: [PATCH 13/13] [warnings] fixed bugprone-not-null-terminated-result --- channels/rdpdr/client/rdpdr_main.c | 3 ++- client/common/test/TestClientRdpFile.c | 6 ++++-- libfreerdp/cache/persistent.c | 6 ++++-- winpr/libwinpr/sspi/Negotiate/negotiate.c | 3 ++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/channels/rdpdr/client/rdpdr_main.c b/channels/rdpdr/client/rdpdr_main.c index 9788736da..6203e33a0 100644 --- a/channels/rdpdr/client/rdpdr_main.c +++ b/channels/rdpdr/client/rdpdr_main.c @@ -1176,7 +1176,8 @@ static UINT rdpdr_process_connect(rdpdrPlugin* rdpdr) if (!drive->Path) continue; - BOOL hotplugAll = strncmp(drive->Path, "*", 2) == 0; + const char wildcard[] = "*"; + BOOL hotplugAll = strncmp(drive->Path, wildcard, sizeof(wildcard)) == 0; BOOL hotplugLater = strncmp(drive->Path, DynamicDrives, sizeof(DynamicDrives)) == 0; if (hotplugAll || hotplugLater) diff --git a/client/common/test/TestClientRdpFile.c b/client/common/test/TestClientRdpFile.c index e631bc8d4..e51123e72 100644 --- a/client/common/test/TestClientRdpFile.c +++ b/client/common/test/TestClientRdpFile.c @@ -539,13 +539,15 @@ int TestClientRdpFile(int argc, char* argv[]) if (iValue != 456) return -1; + const char microsoft[] = "microsoft"; sValue = freerdp_client_rdp_file_get_string_option(file, "vendor string"); - if (strncmp(sValue, "microsoft", 10) != 0) + if (strncmp(sValue, microsoft, sizeof(microsoft)) != 0) goto fail; + const char apple[] = "apple"; freerdp_client_rdp_file_set_string_option(file, "vendor string", "apple"); sValue = freerdp_client_rdp_file_get_string_option(file, "vendor string"); - if (strncmp(sValue, "apple", 6) != 0) + if (strncmp(sValue, apple, sizeof(apple)) != 0) goto fail; freerdp_client_rdp_file_set_string_option(file, "fruits", "banana,oranges"); diff --git a/libfreerdp/cache/persistent.c b/libfreerdp/cache/persistent.c index 36133fc98..2a85b5d7c 100644 --- a/libfreerdp/cache/persistent.c +++ b/libfreerdp/cache/persistent.c @@ -42,6 +42,8 @@ struct rdp_persistent_cache UINT32 bmpSize; }; +static const char sig_str[] = "RDP8bmp"; + int persistent_cache_get_version(rdpPersistentCache* persistent) { WINPR_ASSERT(persistent); @@ -258,7 +260,7 @@ static int persistent_cache_open_read(rdpPersistentCache* persistent) if (fread(sig, 8, 1, persistent->fp) != 1) return -1; - if (!strncmp((const char*)sig, "RDP8bmp", 8)) + if (memcmp(sig, sig_str, sizeof(sig_str)) == 0) persistent->version = 3; else persistent->version = 2; @@ -298,7 +300,7 @@ static int persistent_cache_open_write(rdpPersistentCache* persistent) if (persistent->version == 3) { PERSISTENT_CACHE_HEADER_V3 header = { 0 }; - strncpy((char*)header.sig, "RDP8bmp", 8); + memcpy(header.sig, sig_str, MIN(sizeof(header.sig), sizeof(sig_str))); header.flags = 0x00000006; if (fwrite(&header, sizeof(header), 1, persistent->fp) != 1) diff --git a/winpr/libwinpr/sspi/Negotiate/negotiate.c b/winpr/libwinpr/sspi/Negotiate/negotiate.c index 0d60f5d73..4ce7cf50e 100644 --- a/winpr/libwinpr/sspi/Negotiate/negotiate.c +++ b/winpr/libwinpr/sspi/Negotiate/negotiate.c @@ -922,11 +922,12 @@ static const Mech* guessMech(PSecBuffer input_buffer, BOOL* spNego, WinPrAsn1_OI WinPrAsn1Decoder decoder; WinPrAsn1Decoder appDecoder; WinPrAsn1_tagId tag = 0; + const char ssp[] = "NTLMSSP"; *spNego = FALSE; /* Check for NTLM token */ - if (input_buffer->cbBuffer >= 8 && strncmp(input_buffer->pvBuffer, "NTLMSSP", 8) == 0) + if (input_buffer->cbBuffer >= 8 && strncmp(input_buffer->pvBuffer, ssp, sizeof(ssp)) == 0) { *oid = ntlm_OID; return negotiate_GetMechByOID(&ntlm_OID);