From c9b0c9ecd5713b02f63242300c2f2c303cdb3f47 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Thu, 12 Sep 2024 09:18:46 +0200 Subject: [PATCH] [warnings] remove unused variables --- channels/cliprdr/client/cliprdr_main.c | 15 ++++++--------- channels/printer/client/cups/printer_cups.c | 4 ---- client/SDL/SDL2/sdl_freerdp.cpp | 2 -- client/Sample/tf_channels.c | 4 ++-- client/X11/xf_client.c | 3 --- client/X11/xf_event.c | 3 --- client/X11/xf_input.c | 3 --- client/common/client.c | 3 +-- libfreerdp/common/assistance.c | 6 ++++++ libfreerdp/core/gateway/rts.c | 9 +++------ libfreerdp/core/peer.c | 3 --- libfreerdp/emu/scard/smartcard_emulate.c | 2 ++ 12 files changed, 20 insertions(+), 37 deletions(-) diff --git a/channels/cliprdr/client/cliprdr_main.c b/channels/cliprdr/client/cliprdr_main.c index c28eced33..ded92154e 100644 --- a/channels/cliprdr/client/cliprdr_main.c +++ b/channels/cliprdr/client/cliprdr_main.c @@ -828,21 +828,18 @@ static UINT cliprdr_client_format_data_response(CliprdrClientContext* context, const CLIPRDR_FORMAT_DATA_RESPONSE* formatDataResponse) { - wStream* s = NULL; - cliprdrPlugin* cliprdr = NULL; - WINPR_ASSERT(context); WINPR_ASSERT(formatDataResponse); - cliprdr = (cliprdrPlugin*)context->handle; + cliprdrPlugin* cliprdr = (cliprdrPlugin*)context->handle; WINPR_ASSERT(cliprdr); - const UINT32 mask = - freerdp_settings_get_uint32(context->rdpcontext->settings, FreeRDP_ClipboardFeatureMask); - WINPR_ASSERT((mask & (CLIPRDR_FLAG_LOCAL_TO_REMOTE | CLIPRDR_FLAG_LOCAL_TO_REMOTE_FILES)) != 0); + WINPR_ASSERT( + (freerdp_settings_get_uint32(context->rdpcontext->settings, FreeRDP_ClipboardFeatureMask) & + (CLIPRDR_FLAG_LOCAL_TO_REMOTE | CLIPRDR_FLAG_LOCAL_TO_REMOTE_FILES)) != 0); - s = cliprdr_packet_new(CB_FORMAT_DATA_RESPONSE, formatDataResponse->common.msgFlags, - formatDataResponse->common.dataLen); + wStream* s = cliprdr_packet_new(CB_FORMAT_DATA_RESPONSE, formatDataResponse->common.msgFlags, + formatDataResponse->common.dataLen); if (!s) { diff --git a/channels/printer/client/cups/printer_cups.c b/channels/printer/client/cups/printer_cups.c index 40464f1e2..6a80bdece 100644 --- a/channels/printer/client/cups/printer_cups.c +++ b/channels/printer/client/cups/printer_cups.c @@ -147,10 +147,6 @@ static UINT write_printjob(rdpPrintJob* printjob, const BYTE* data, size_t size) */ static UINT printer_cups_write_printjob(rdpPrintJob* printjob, const BYTE* data, size_t size) { - rdpCupsPrintJob* cups_printjob = (rdpCupsPrintJob*)printjob; - - WINPR_ASSERT(cups_printjob); - return write_printjob(printjob, data, size); } diff --git a/client/SDL/SDL2/sdl_freerdp.cpp b/client/SDL/SDL2/sdl_freerdp.cpp index 2cc7f8f8f..818cfcada 100644 --- a/client/SDL/SDL2/sdl_freerdp.cpp +++ b/client/SDL/SDL2/sdl_freerdp.cpp @@ -1166,8 +1166,6 @@ static void sdl_post_final_disconnect(freerdp* instance) if (!instance->context) return; - - auto context = get_context(instance->context); } /* RDP main loop. diff --git a/client/Sample/tf_channels.c b/client/Sample/tf_channels.c index d1bfdb8bb..8aaff8100 100644 --- a/client/Sample/tf_channels.c +++ b/client/Sample/tf_channels.c @@ -55,7 +55,7 @@ void tf_OnChannelConnectedEventHandler(void* context, const ChannelConnectedEven clip->custom = context; } else - freerdp_client_OnChannelConnectedEventHandler(context, e); + freerdp_client_OnChannelConnectedEventHandler(&tf->common, e); } void tf_OnChannelDisconnectedEventHandler(void* context, const ChannelDisconnectedEventArgs* e) @@ -75,5 +75,5 @@ void tf_OnChannelDisconnectedEventHandler(void* context, const ChannelDisconnect clip->custom = NULL; } else - freerdp_client_OnChannelDisconnectedEventHandler(context, e); + freerdp_client_OnChannelDisconnectedEventHandler(&tf->common, e); } diff --git a/client/X11/xf_client.c b/client/X11/xf_client.c index b7ca986ed..cb599e0f4 100644 --- a/client/X11/xf_client.c +++ b/client/X11/xf_client.c @@ -788,9 +788,6 @@ void xf_minimize(xfContext* xfc) rdpContext* context = (rdpContext*)xfc; WINPR_ASSERT(context); - rdpSettings* settings = context->settings; - WINPR_ASSERT(settings); - /* when debugging, ungrab keyboard when toggling fullscreen to allow keyboard usage on the debugger diff --git a/client/X11/xf_event.c b/client/X11/xf_event.c index 7d9d250ff..c8e4a1c80 100644 --- a/client/X11/xf_event.c +++ b/client/X11/xf_event.c @@ -433,9 +433,6 @@ BOOL xf_generic_MotionNotify(xfContext* xfc, int x, int y, int state, Window win WINPR_ASSERT(xfc); WINPR_ASSERT(xfc->common.context.settings); - rdpInput* input = xfc->common.context.input; - WINPR_ASSERT(input); - if (!freerdp_settings_get_bool(xfc->common.context.settings, FreeRDP_MouseMotion)) { if ((state & (Button1Mask | Button2Mask | Button3Mask)) == 0) diff --git a/client/X11/xf_input.c b/client/X11/xf_input.c index f0e649cf6..4127a4dc1 100644 --- a/client/X11/xf_input.c +++ b/client/X11/xf_input.c @@ -254,9 +254,6 @@ int xf_input_init(xfContext* xfc, Window window) WINPR_ASSERT(xfc); - rdpSettings* settings = xfc->common.context.settings; - WINPR_ASSERT(settings); - xfc->firstDist = -1.0; xfc->z_vector = 0; xfc->px_vector = 0; diff --git a/client/common/client.c b/client/common/client.c index 6697dee06..e920903b4 100644 --- a/client/common/client.c +++ b/client/common/client.c @@ -634,8 +634,7 @@ static DWORD client_cli_accept_certificate(freerdp* instance) const rdpSettings* settings = instance->context->settings; WINPR_ASSERT(settings); - const BOOL fromStdin = - freerdp_settings_get_bool(instance->context->settings, FreeRDP_CredentialsFromStdin); + const BOOL fromStdin = freerdp_settings_get_bool(settings, FreeRDP_CredentialsFromStdin); if (fromStdin) return 0; diff --git a/libfreerdp/common/assistance.c b/libfreerdp/common/assistance.c index d59ed56ba..d3907dc57 100644 --- a/libfreerdp/common/assistance.c +++ b/libfreerdp/common/assistance.c @@ -427,6 +427,8 @@ static BOOL freerdp_assistance_parse_attr(const char** opt, size_t* plength, con const int rc = _snprintf(bkey, sizeof(bkey), "%s=\"", key); WINPR_ASSERT(rc > 0); WINPR_ASSERT((size_t)rc < sizeof(bkey)); + if ((rc <= 0) || (rc >= sizeof(bkey))) + return FALSE; char* p = strstr(tag, bkey); if (!p) @@ -527,6 +529,8 @@ static char* freerdp_assistance_contains_element(char* input, size_t ilen, const const int rc = _snprintf(bkey, sizeof(bkey), "<%s", key); WINPR_ASSERT(rc > 0); WINPR_ASSERT((size_t)rc < sizeof(bkey)); + if ((rc < 0) || (rc >= sizeof(bkey))) + return NULL; char* tag = strstr(input, bkey); if (!tag || (tag > input + ilen)) @@ -566,6 +570,8 @@ static char* freerdp_assistance_contains_element(char* input, size_t ilen, const const int erc = _snprintf(ekey, sizeof(ekey), "", key); WINPR_ASSERT(erc > 0); WINPR_ASSERT((size_t)erc < sizeof(ekey)); + if ((erc <= 0) || (erc >= sizeof(ekey))) + return NULL; const size_t offset = start - tag; dend = end = strrstr(start, ilen - offset, ekey); if (end) diff --git a/libfreerdp/core/gateway/rts.c b/libfreerdp/core/gateway/rts.c index 4012743b1..df1189240 100644 --- a/libfreerdp/core/gateway/rts.c +++ b/libfreerdp/core/gateway/rts.c @@ -321,12 +321,9 @@ static BOOL rts_read_auth_verifier(wStream* s, auth_verifier_co_t* auth, if (!rts_read_auth_verifier_no_checks(s, auth, header, &pos, silent)) return FALSE; - { - const size_t expected = header->frag_length - header->auth_length - 8; - WINPR_ASSERT(pos + auth->auth_pad_length == expected); - } - - return TRUE; + const size_t expected = header->frag_length - header->auth_length - 8; + WINPR_ASSERT(pos + auth->auth_pad_length == expected); + return pos + auth->auth_pad_length == expected; } static BOOL rts_read_auth_verifier_with_stub(wStream* s, auth_verifier_co_t* auth, diff --git a/libfreerdp/core/peer.c b/libfreerdp/core/peer.c index 7e41b1809..7f84361cc 100644 --- a/libfreerdp/core/peer.c +++ b/libfreerdp/core/peer.c @@ -755,9 +755,6 @@ static state_run_t rdp_peer_handle_state_active(freerdp_peer* client) WINPR_ASSERT(client); WINPR_ASSERT(client->context); - rdpRdp* rdp = client->context->rdp; - WINPR_ASSERT(rdp); - if (!client->connected) { /** diff --git a/libfreerdp/emu/scard/smartcard_emulate.c b/libfreerdp/emu/scard/smartcard_emulate.c index 3f444598b..10b64e046 100644 --- a/libfreerdp/emu/scard/smartcard_emulate.c +++ b/libfreerdp/emu/scard/smartcard_emulate.c @@ -450,6 +450,8 @@ LONG WINAPI Emulate_SCardIsValidContext(SmartcardEmulationContext* smartcard, SC { SCardContext* value = HashTable_GetItemValue(smartcard->contexts, (const void*)hContext); WINPR_ASSERT(value); /* Must be valid after Emulate_SCardIsValidContext */ + if (!value) + return SCARD_F_INTERNAL_ERROR; } WLog_Print(smartcard->log, smartcard->log_default_level,