diff --git a/channels/drdynvc/client/drdynvc_main.c b/channels/drdynvc/client/drdynvc_main.c index c14d66dff..1b15ef2d7 100644 --- a/channels/drdynvc/client/drdynvc_main.c +++ b/channels/drdynvc/client/drdynvc_main.c @@ -514,9 +514,7 @@ static UINT dvcman_channel_close(DVCMAN_CHANNEL* channel, BOOL perRequest, BOOL IWTSVirtualChannelCallback* cb = channel->channel_callback; channel->channel_callback = NULL; if (cb) - { - IFCALL(cb->OnClose, cb); - } + error = IFCALLRESULT(CHANNEL_RC_OK, cb->OnClose, cb); } if (channel->dvcman && channel->dvcman->drdynvc) diff --git a/channels/drive/client/drive_main.c b/channels/drive/client/drive_main.c index 9d5079845..8a560f264 100644 --- a/channels/drive/client/drive_main.c +++ b/channels/drive/client/drive_main.c @@ -923,7 +923,7 @@ static void drive_message_free(void* obj) if (!irp) return; WINPR_ASSERT(irp->Discard); - (void)irp->Discard(irp); + irp->Discard(irp); } /** diff --git a/channels/rdpdr/client/devman.c b/channels/rdpdr/client/devman.c index 8c99c198c..b38554956 100644 --- a/channels/rdpdr/client/devman.c +++ b/channels/rdpdr/client/devman.c @@ -48,7 +48,8 @@ static void devman_device_free(void* obj) if (!device) return; - IFCALL(device->Free, device); + if (device->Free) + device->Free(device); } DEVMAN* devman_new(rdpdrPlugin* rdpdr) diff --git a/channels/rdpdr/client/rdpdr_main.c b/channels/rdpdr/client/rdpdr_main.c index f1c68feb8..ccbbfe4c9 100644 --- a/channels/rdpdr/client/rdpdr_main.c +++ b/channels/rdpdr/client/rdpdr_main.c @@ -1563,7 +1563,7 @@ static UINT rdpdr_process_irp(rdpdrPlugin* rdpdr, wStream* s) WLog_Print(rdpdr->log, WLOG_ERROR, "device->IRPRequest failed with error %" PRIu32 "", error); } - (void)irp->Discard(irp); + irp->Discard(irp); return error; } diff --git a/channels/rdpecam/client/camera_device_enum_main.c b/channels/rdpecam/client/camera_device_enum_main.c index d777c41a0..d153f12bb 100644 --- a/channels/rdpecam/client/camera_device_enum_main.c +++ b/channels/rdpecam/client/camera_device_enum_main.c @@ -401,11 +401,12 @@ static UINT ecam_plugin_terminated(IWTSPlugin* pPlugin) HashTable_Free(ecam->devices); + UINT rc = CHANNEL_RC_OK; if (ecam->ihal) - ecam->ihal->Free(ecam->ihal); + rc = ecam->ihal->Free(ecam->ihal); free(ecam); - return CHANNEL_RC_OK; + return rc; } /** diff --git a/channels/rdpgfx/client/rdpgfx_main.c b/channels/rdpgfx/client/rdpgfx_main.c index 74690e822..b51d82a4a 100644 --- a/channels/rdpgfx/client/rdpgfx_main.c +++ b/channels/rdpgfx/client/rdpgfx_main.c @@ -73,8 +73,10 @@ static void free_surfaces(RdpgfxClientContext* context, wHashTable* SurfaceTable HashTable_Foreach(SurfaceTable, delete_surface, context); } -static void evict_cache_slots(RdpgfxClientContext* context, UINT16 MaxCacheSlots, void** CacheSlots) +static UINT evict_cache_slots(RdpgfxClientContext* context, UINT16 MaxCacheSlots, void** CacheSlots) { + UINT error = CHANNEL_RC_OK; + WINPR_ASSERT(CacheSlots); for (UINT16 index = 0; index < MaxCacheSlots; index++) { @@ -85,12 +87,15 @@ static void evict_cache_slots(RdpgfxClientContext* context, UINT16 MaxCacheSlots if (context && context->EvictCacheEntry) { - context->EvictCacheEntry(context, &pdu); + const UINT rc = context->EvictCacheEntry(context, &pdu); + if (rc != CHANNEL_RC_OK) + error = rc; } CacheSlots[index] = NULL; } } + return error; } /** @@ -861,7 +866,6 @@ fail: static UINT rdpgfx_load_cache_import_reply(RDPGFX_PLUGIN* gfx, const RDPGFX_CACHE_IMPORT_REPLY_PDU* reply) { - int count = 0; UINT error = CHANNEL_RC_OK; rdpPersistentCache* persistent = NULL; WINPR_ASSERT(gfx); @@ -896,7 +900,7 @@ static UINT rdpgfx_load_cache_import_reply(RDPGFX_PLUGIN* gfx, goto fail; } - count = persistent_cache_get_count(persistent); + int count = persistent_cache_get_count(persistent); count = (count < reply->importedEntriesCount) ? count : reply->importedEntriesCount; @@ -913,7 +917,11 @@ static UINT rdpgfx_load_cache_import_reply(RDPGFX_PLUGIN* gfx, const UINT16 cacheSlot = reply->cacheSlots[idx]; if (context && context->ImportCacheEntry) - context->ImportCacheEntry(context, cacheSlot, &entry); + { + error = context->ImportCacheEntry(context, cacheSlot, &entry); + if (error != CHANNEL_RC_OK) + break; + } } persistent_cache_free(persistent); @@ -1011,7 +1019,10 @@ static UINT rdpgfx_recv_create_surface_pdu(GENERIC_CHANNEL_CALLBACK* callback, w * manually. */ RDPGFX_DELETE_SURFACE_PDU deletePdu = { pdu.surfaceId }; - IFCALL(context->DeleteSurface, context, &deletePdu); + const UINT drc = IFCALLRESULT(CHANNEL_RC_OK, context->DeleteSurface, context, &deletePdu); + if (drc != CHANNEL_RC_OK) + WLog_Print(gfx->log, WLOG_WARN, + "context->DeleteSurface failed with error %" PRIu32 ", ignoring", error); IFCALLRET(context->CreateSurface, error, context, &pdu); @@ -2116,7 +2127,13 @@ static UINT rdpgfx_on_close(IWTSVirtualChannelCallback* pChannelCallback) } free_surfaces(context, gfx->SurfaceTable); - evict_cache_slots(context, gfx->MaxCacheSlots, gfx->CacheSlots); + error = evict_cache_slots(context, gfx->MaxCacheSlots, gfx->CacheSlots); + if (error) + { + // print error, but don't consider this a hard failure + WLog_Print(gfx->log, WLOG_ERROR, "evict_cache_slots failed with error %" PRIu32 "", + error); + } free(callback); gfx->UnacknowledgedFrames = 0; @@ -2124,7 +2141,13 @@ static UINT rdpgfx_on_close(IWTSVirtualChannelCallback* pChannelCallback) if (context) { - IFCALL(context->OnClose, context); + error = IFCALLRESULT(CHANNEL_RC_OK, context->OnClose, context); + if (error) + { + // print error, but don't consider this a hard failure + WLog_Print(gfx->log, WLOG_ERROR, "context->OnClose failed with error %" PRIu32 "", + error); + } } } diff --git a/channels/serial/client/serial_main.c b/channels/serial/client/serial_main.c index cef571464..1110b2068 100644 --- a/channels/serial/client/serial_main.c +++ b/channels/serial/client/serial_main.c @@ -710,7 +710,9 @@ error_handle: (void)CloseHandle(irpThread); irp->IoStatus = STATUS_NO_MEMORY; WINPR_ASSERT(irp->Complete); - irp->Complete(irp); + const UINT rc = irp->Complete(irp); + if (rc != CHANNEL_RC_OK) + WLog_Print(serial->log, WLOG_WARN, "irp->Complete failed with %" PRIu32, rc); free(data); } diff --git a/channels/tsmf/client/alsa/tsmf_alsa.c b/channels/tsmf/client/alsa/tsmf_alsa.c index 125acc291..a2623f0ee 100644 --- a/channels/tsmf/client/alsa/tsmf_alsa.c +++ b/channels/tsmf/client/alsa/tsmf_alsa.c @@ -198,7 +198,7 @@ static UINT64 tsmf_alsa_get_latency(ITSMFAudioDevice* audio) return latency; } -static BOOL tsmf_alsa_flush(ITSMFAudioDevice* audio) +static BOOL tsmf_alsa_flush(WINPR_ATTR_UNUSED ITSMFAudioDevice* audio) { return TRUE; } diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c index ce7346778..12da2601b 100644 --- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c +++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c @@ -462,7 +462,7 @@ static BOOL tsmf_ffmpeg_decode_video(ITSMFDecoder* decoder, const BYTE* data, UI } static BOOL tsmf_ffmpeg_decode_audio(ITSMFDecoder* decoder, const BYTE* data, UINT32 data_size, - UINT32 extensions) + WINPR_ATTR_UNUSED UINT32 extensions) { TSMFFFmpegDecoder* mdecoder = (TSMFFFmpegDecoder*)decoder; int len = 0; @@ -686,7 +686,9 @@ static void tsmf_ffmpeg_free(ITSMFDecoder* decoder) } static INIT_ONCE g_Initialized = INIT_ONCE_STATIC_INIT; -static BOOL CALLBACK InitializeAvCodecs(PINIT_ONCE once, PVOID param, PVOID* context) +static BOOL CALLBACK InitializeAvCodecs(WINPR_ATTR_UNUSED PINIT_ONCE once, + WINPR_ATTR_UNUSED PVOID param, + WINPR_ATTR_UNUSED PVOID* context) { #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 10, 100) avcodec_register_all(); diff --git a/channels/tsmf/client/oss/tsmf_oss.c b/channels/tsmf/client/oss/tsmf_oss.c index 9cc2119d8..874a02fdf 100644 --- a/channels/tsmf/client/oss/tsmf_oss.c +++ b/channels/tsmf/client/oss/tsmf_oss.c @@ -194,7 +194,7 @@ static UINT64 tsmf_oss_get_latency(ITSMFAudioDevice* audio) return latency; } -static BOOL tsmf_oss_flush(ITSMFAudioDevice* audio) +static BOOL tsmf_oss_flush(WINPR_ATTR_UNUSED ITSMFAudioDevice* audio) { return TRUE; } diff --git a/channels/tsmf/client/pulse/tsmf_pulse.c b/channels/tsmf/client/pulse/tsmf_pulse.c index 787440299..6858d83ef 100644 --- a/channels/tsmf/client/pulse/tsmf_pulse.c +++ b/channels/tsmf/client/pulse/tsmf_pulse.c @@ -156,7 +156,8 @@ static BOOL tsmf_pulse_open(ITSMFAudioDevice* audio, const char* device) return TRUE; } -static void tsmf_pulse_stream_success_callback(pa_stream* stream, int success, void* userdata) +static void tsmf_pulse_stream_success_callback(WINPR_ATTR_UNUSED pa_stream* stream, + WINPR_ATTR_UNUSED int success, void* userdata) { TSMFPulseAudioDevice* pulse = (TSMFPulseAudioDevice*)userdata; pa_threaded_mainloop_signal(pulse->mainloop, 0); @@ -201,7 +202,8 @@ static void tsmf_pulse_stream_state_callback(pa_stream* stream, void* userdata) } } -static void tsmf_pulse_stream_request_callback(pa_stream* stream, size_t length, void* userdata) +static void tsmf_pulse_stream_request_callback(WINPR_ATTR_UNUSED pa_stream* stream, + WINPR_ATTR_UNUSED size_t length, void* userdata) { TSMFPulseAudioDevice* pulse = (TSMFPulseAudioDevice*)userdata; DEBUG_TSMF("%" PRIdz "", length); @@ -294,7 +296,7 @@ static BOOL tsmf_pulse_open_stream(TSMFPulseAudioDevice* pulse) } static BOOL tsmf_pulse_set_format(ITSMFAudioDevice* audio, UINT32 sample_rate, UINT32 channels, - UINT32 bits_per_sample) + WINPR_ATTR_UNUSED UINT32 bits_per_sample) { TSMFPulseAudioDevice* pulse = (TSMFPulseAudioDevice*)audio; DEBUG_TSMF("sample_rate %" PRIu32 " channels %" PRIu32 " bits_per_sample %" PRIu32 "", diff --git a/channels/tsmf/client/tsmf_main.c b/channels/tsmf/client/tsmf_main.c index dbfa404ca..033184556 100644 --- a/channels/tsmf/client/tsmf_main.c +++ b/channels/tsmf/client/tsmf_main.c @@ -432,7 +432,9 @@ static UINT tsmf_on_close(IWTSVirtualChannelCallback* pChannelCallback) * @return 0 on success, otherwise a Win32 error code */ static UINT tsmf_on_new_channel_connection(IWTSListenerCallback* pListenerCallback, - IWTSVirtualChannel* pChannel, BYTE* Data, BOOL* pbAccept, + IWTSVirtualChannel* pChannel, + WINPR_ATTR_UNUSED BYTE* Data, + WINPR_ATTR_UNUSED BOOL* pbAccept, IWTSVirtualChannelCallback** ppCallback) { TSMF_CHANNEL_CALLBACK* callback = NULL; diff --git a/channels/urbdrc/client/data_transfer.c b/channels/urbdrc/client/data_transfer.c index c4042107d..794d3d441 100644 --- a/channels/urbdrc/client/data_transfer.c +++ b/channels/urbdrc/client/data_transfer.c @@ -450,9 +450,13 @@ static UINT urbdrc_process_query_device_text(IUDEVICE* pdev, GENERIC_CHANNEL_CAL DeviceDescription, bufferSize); } -static void func_select_all_interface_for_msconfig(IUDEVICE* pdev, +static void func_select_all_interface_for_msconfig(URBDRC_PLUGIN* urbdrc, IUDEVICE* pdev, MSUSB_CONFIG_DESCRIPTOR* MsConfig) { + WINPR_ASSERT(urbdrc); + WINPR_ASSERT(pdev); + WINPR_ASSERT(MsConfig); + MSUSB_INTERFACE_DESCRIPTOR** MsInterfaces = MsConfig->MsInterfaces; UINT32 NumInterfaces = MsConfig->NumInterfaces; @@ -460,7 +464,12 @@ static void func_select_all_interface_for_msconfig(IUDEVICE* pdev, { const BYTE InterfaceNumber = MsInterfaces[inum]->InterfaceNumber; const BYTE AlternateSetting = MsInterfaces[inum]->AlternateSetting; - pdev->select_interface(pdev, InterfaceNumber, AlternateSetting); + const int rc = pdev->select_interface(pdev, InterfaceNumber, AlternateSetting); + if (rc < 0) + { + WLog_Print(urbdrc->log, WLOG_WARN, "select_interface %" PRIu8 " [%" PRIu8 "] failed", + InterfaceNumber, AlternateSetting); + } } } @@ -545,9 +554,16 @@ static UINT urb_select_configuration(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBACK* c return ERROR_INVALID_DATA; /* select config */ - pdev->select_configuration(pdev, MsConfig->bConfigurationValue); + const int lrc = pdev->select_configuration(pdev, MsConfig->bConfigurationValue); + if (lrc != 0) + { + msusb_msconfig_free(MsConfig); + MsConfig = NULL; + return ERROR_INTERNAL_ERROR; + } + /* select all interface */ - func_select_all_interface_for_msconfig(pdev, MsConfig); + func_select_all_interface_for_msconfig(urbdrc, pdev, MsConfig); /* complete configuration setup */ if (!pdev->complete_msconfig_setup(pdev, MsConfig)) { @@ -657,7 +673,14 @@ static UINT urb_select_interface(IUDEVICE* pdev, GENERIC_CHANNEL_CALLBACK* callb return ERROR_INVALID_DATA; } - pdev->select_interface(pdev, MsInterface->InterfaceNumber, MsInterface->AlternateSetting); + const int lerr = + pdev->select_interface(pdev, MsInterface->InterfaceNumber, MsInterface->AlternateSetting); + if (lerr != 0) + { + msusb_msinterface_free(MsInterface); + return ERROR_INTERNAL_ERROR; + } + /* replace device's MsInterface */ MSUSB_CONFIG_DESCRIPTOR* MsConfig = pdev->get_MsConfig(pdev); const uint8_t InterfaceNumber = MsInterface->InterfaceNumber; @@ -1982,7 +2005,11 @@ UINT urbdrc_process_udev_data_transfer(GENERIC_CHANNEL_CALLBACK* callback, URBDR } /* USB kernel driver detach!! */ - pdev->detach_kernel_driver(pdev); + if (!pdev->detach_kernel_driver(pdev)) + { + error = ERROR_SUCCESS; + goto fail; + } switch (FunctionId) { diff --git a/channels/urbdrc/client/libusb/libusb_udevice.c b/channels/urbdrc/client/libusb/libusb_udevice.c index 878438282..d465ff9be 100644 --- a/channels/urbdrc/client/libusb/libusb_udevice.c +++ b/channels/urbdrc/client/libusb/libusb_udevice.c @@ -1169,7 +1169,11 @@ static void libusb_udev_mark_channel_closed(IUDEVICE* idev) pdev->status |= URBDRC_DEVICE_CHANNEL_CLOSED; pdev->iface.cancel_all_transfer_request(&pdev->iface); - urbdrc->udevman->unregister_udevice(urbdrc->udevman, busNr, devNr); + if (!urbdrc->udevman->unregister_udevice(urbdrc->udevman, busNr, devNr)) + { + WLog_Print(pdev->urbdrc->log, WLOG_WARN, "unregister_udevice failed for %d, %d", busNr, + devNr); + } } } @@ -1192,9 +1196,15 @@ static void libusb_udev_channel_closed(IUDEVICE* idev) pdev->status |= URBDRC_DEVICE_CHANNEL_CLOSED; if (channel) - channel->Write(channel, 0, NULL, NULL); + { + const UINT rc = channel->Write(channel, 0, NULL, NULL); + if (rc != CHANNEL_RC_OK) + WLog_Print(urbdrc->log, WLOG_WARN, "channel->Write failed with %" PRIu32, rc); + } - urbdrc->udevman->unregister_udevice(urbdrc->udevman, busNr, devNr); + if (!urbdrc->udevman->unregister_udevice(urbdrc->udevman, busNr, devNr)) + WLog_Print(urbdrc->log, WLOG_WARN, "unregister_udevice failed for %d, %d", busNr, + devNr); } } @@ -1562,7 +1572,8 @@ static void udev_free(IUDEVICE* idev) Sleep(100); /* release all interface and attach kernel driver */ - udev->iface.attach_kernel_driver(idev); + if (!udev->iface.attach_kernel_driver(idev)) + WLog_Print(udev->urbdrc->log, WLOG_WARN, "attach_kernel_driver failed for device"); ArrayList_Free(udev->request_queue); /* free the config descriptor that send from windows */ msusb_msconfig_free(udev->MsConfig); diff --git a/channels/urbdrc/client/urbdrc_main.c b/channels/urbdrc/client/urbdrc_main.c index f10962b8f..4716fb19e 100644 --- a/channels/urbdrc/client/urbdrc_main.c +++ b/channels/urbdrc/client/urbdrc_main.c @@ -350,7 +350,9 @@ static UINT urdbrc_send_usb_device_add(GENERIC_CHANNEL_CALLBACK* callback, IUDEV size_t nrCompatIds = 3; /* USB kernel driver detach!! */ - pdev->detach_kernel_driver(pdev); + if (!pdev->detach_kernel_driver(pdev)) + return ERROR_INTERNAL_ERROR; + { const UINT16 idVendor = (UINT16)pdev->query_device_descriptor(pdev, ID_VENDOR); const UINT16 idProduct = (UINT16)pdev->query_device_descriptor(pdev, ID_PRODUCT); @@ -505,7 +507,8 @@ static UINT urbdrc_device_control_channel(GENERIC_CHANNEL_CALLBACK* callback, case INIT_CHANNEL_IN: /* Control channel was established */ error = ERROR_SUCCESS; - udevman->initialize(udevman, channelId); + if (!udevman->initialize(udevman, channelId)) + goto fail; if (!urbdrc_announce_devices(udevman)) goto fail; diff --git a/channels/video/client/video_main.c b/channels/video/client/video_main.c index 3612aa01c..7811f916d 100644 --- a/channels/video/client/video_main.c +++ b/channels/video/client/video_main.c @@ -716,8 +716,9 @@ static void video_timer(VideoClientContext* video, UINT64 now) memcpy(presentation->surface->data, frame->surfaceData, 1ull * frame->scanline * frame->h); WINPR_ASSERT(video->showSurface); - video->showSurface(video, presentation->surface, presentation->ScaledWidth, - presentation->ScaledHeight); + if (!video->showSurface(video, presentation->surface, presentation->ScaledWidth, + presentation->ScaledHeight)) + WLog_WARN(TAG, "showSurface failed"); VideoFrame_free(&frame); } @@ -872,8 +873,9 @@ static UINT video_VideoData(VideoClientContext* context, const TSMM_VIDEO_DATA* return CHANNEL_RC_OK; WINPR_ASSERT(context->showSurface); - context->showSurface(context, presentation->surface, presentation->ScaledWidth, - presentation->ScaledHeight); + if (!context->showSurface(context, presentation->surface, presentation->ScaledWidth, + presentation->ScaledHeight)) + return CHANNEL_RC_NOT_INITIALIZED; priv->publishedFrames++;