From b8598728a6099b350f164def7bbb355238972885 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Wed, 24 Jan 2024 07:58:22 +0100 Subject: [PATCH] [clang-tidy] clang-analyzer-core.uninitialized.Assign --- channels/rdpgfx/client/rdpgfx_main.c | 14 ++++++-------- include/freerdp/client/rdpgfx.h | 2 +- libfreerdp/core/activation.c | 9 ++++----- libfreerdp/gdi/gfx.c | 2 +- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/channels/rdpgfx/client/rdpgfx_main.c b/channels/rdpgfx/client/rdpgfx_main.c index c16f88e02..f29430c71 100644 --- a/channels/rdpgfx/client/rdpgfx_main.c +++ b/channels/rdpgfx/client/rdpgfx_main.c @@ -934,13 +934,11 @@ fail: * * @return 0 on success, otherwise a Win32 error code */ -static UINT rdpgfx_load_cache_import_reply(RDPGFX_PLUGIN* gfx, RDPGFX_CACHE_IMPORT_REPLY_PDU* reply) +static UINT rdpgfx_load_cache_import_reply(RDPGFX_PLUGIN* gfx, + const RDPGFX_CACHE_IMPORT_REPLY_PDU* reply) { - int idx = 0; int count = 0; - UINT16 cacheSlot = 0; UINT error = CHANNEL_RC_OK; - PERSISTENT_CACHE_ENTRY entry; rdpPersistentCache* persistent = NULL; WINPR_ASSERT(gfx); WINPR_ASSERT(gfx->rdpcontext); @@ -980,16 +978,16 @@ static UINT rdpgfx_load_cache_import_reply(RDPGFX_PLUGIN* gfx, RDPGFX_CACHE_IMPO WLog_DBG(TAG, "Receiving Cache Import Reply: %d", count); - for (idx = 0; idx < count; idx++) + for (int idx = 0; idx < count; idx++) { + PERSISTENT_CACHE_ENTRY entry = { 0 }; if (persistent_cache_read_entry(persistent, &entry) < 1) { error = ERROR_INVALID_DATA; goto fail; } - cacheSlot = reply->cacheSlots[idx]; - + const UINT16 cacheSlot = reply->cacheSlots[idx]; if (context && context->ImportCacheEntry) context->ImportCacheEntry(context, cacheSlot, &entry); } @@ -1010,7 +1008,7 @@ fail: static UINT rdpgfx_recv_cache_import_reply_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { UINT16 idx = 0; - RDPGFX_CACHE_IMPORT_REPLY_PDU pdu; + RDPGFX_CACHE_IMPORT_REPLY_PDU pdu = { 0 }; WINPR_ASSERT(callback); RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin; WINPR_ASSERT(gfx); diff --git a/include/freerdp/client/rdpgfx.h b/include/freerdp/client/rdpgfx.h index 36be6b00c..df9e2a7a5 100644 --- a/include/freerdp/client/rdpgfx.h +++ b/include/freerdp/client/rdpgfx.h @@ -73,7 +73,7 @@ extern "C" typedef UINT (*pcRdpgfxEvictCacheEntry)(RdpgfxClientContext* context, const RDPGFX_EVICT_CACHE_ENTRY_PDU* evictCacheEntry); typedef UINT (*pcRdpgfxImportCacheEntry)(RdpgfxClientContext* context, UINT16 cacheSlot, - PERSISTENT_CACHE_ENTRY* importCacheEntry); + const PERSISTENT_CACHE_ENTRY* importCacheEntry); typedef UINT (*pcRdpgfxExportCacheEntry)(RdpgfxClientContext* context, UINT16 cacheSlot, PERSISTENT_CACHE_ENTRY* importCacheEntry); typedef UINT (*pcRdpgfxMapSurfaceToOutput)( diff --git a/libfreerdp/core/activation.c b/libfreerdp/core/activation.c index 64eff3ce8..1e3fc8e23 100644 --- a/libfreerdp/core/activation.c +++ b/libfreerdp/core/activation.c @@ -237,7 +237,8 @@ BOOL rdp_send_client_control_pdu(rdpRdp* rdp, UINT16 action) return rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_CONTROL, rdp->mcs->userId); } -static BOOL rdp_write_client_persistent_key_list_pdu(wStream* s, RDP_BITMAP_PERSISTENT_INFO* info) +static BOOL rdp_write_client_persistent_key_list_pdu(wStream* s, + const RDP_BITMAP_PERSISTENT_INFO* info) { WINPR_ASSERT(s); WINPR_ASSERT(info); @@ -332,13 +333,11 @@ error: BOOL rdp_send_client_persistent_key_list_pdu(rdpRdp* rdp) { - UINT32 keyCount = 0; UINT32 keyMaxFrag = 2042; UINT64* keyList = NULL; - RDP_BITMAP_PERSISTENT_INFO info; + RDP_BITMAP_PERSISTENT_INFO info = { 0 }; rdpSettings* settings = rdp->settings; - - keyCount = rdp_load_persistent_key_list(rdp, &keyList); + UINT32 keyCount = rdp_load_persistent_key_list(rdp, &keyList); WLog_DBG(TAG, "Persistent Key List: TotalKeyCount: %" PRIu32 " MaxKeyFrag: %" PRIu32, keyCount, keyMaxFrag); diff --git a/libfreerdp/gdi/gfx.c b/libfreerdp/gdi/gfx.c index 84230d157..ef9046660 100644 --- a/libfreerdp/gdi/gfx.c +++ b/libfreerdp/gdi/gfx.c @@ -1599,7 +1599,7 @@ static UINT gdi_CacheImportReply(RdpgfxClientContext* context, } static UINT gdi_ImportCacheEntry(RdpgfxClientContext* context, UINT16 cacheSlot, - PERSISTENT_CACHE_ENTRY* importCacheEntry) + const PERSISTENT_CACHE_ENTRY* importCacheEntry) { UINT error = ERROR_INTERNAL_ERROR; gdiGfxCacheEntry* cacheEntry = NULL;