diff --git a/client/common/cmdline.c b/client/common/cmdline.c index 8d24af722..4350c775a 100644 --- a/client/common/cmdline.c +++ b/client/common/cmdline.c @@ -2396,14 +2396,14 @@ static int parse_host_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT if (p) { - LONGLONG val = 0; + LONGLONG lval = 0; size_t length = 0; - if (!value_to_int(&p[1], &val, 1, UINT16_MAX)) + if (!value_to_int(&p[1], &lval, 1, UINT16_MAX)) return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; length = (size_t)(p - arg->Value); - if (!freerdp_settings_set_uint32(settings, FreeRDP_ServerPort, val)) + if (!freerdp_settings_set_uint32(settings, FreeRDP_ServerPort, lval)) return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; if (!freerdp_settings_set_string_len(settings, FreeRDP_ServerHostname, arg->Value, length)) diff --git a/libfreerdp/codec/ncrush.c b/libfreerdp/codec/ncrush.c index 28b98d905..44dc78f22 100644 --- a/libfreerdp/codec/ncrush.c +++ b/libfreerdp/codec/ncrush.c @@ -2936,12 +2936,12 @@ static int ncrush_generate_tables(NCRUSH_CONTEXT* context) WINPR_ASSERT(context); WINPR_ASSERT(28 < ARRAYSIZE(LOMBitsLUT)); - UINT32 k = 0; + UINT32 cnt = 0; for (int i = 0; i < 28; i++) { for (int j = 0; j < 1 << LOMBitsLUT[i]; j++) { - size_t l = (k++) + 2ull; + size_t l = (cnt++) + 2ull; context->HuffTableLOM[l] = (int)i; } } @@ -2961,8 +2961,7 @@ static int ncrush_generate_tables(NCRUSH_CONTEXT* context) return -1; } - k = 0; - + size_t k = 0; for (int i = 0; i < 16; i++) { for (int j = 0; j < 1 << CopyOffsetBitsLUT[i]; j++) diff --git a/libfreerdp/codec/nsc_encode.c b/libfreerdp/codec/nsc_encode.c index c7c26aced..b101a15cf 100644 --- a/libfreerdp/codec/nsc_encode.c +++ b/libfreerdp/codec/nsc_encode.c @@ -111,7 +111,6 @@ fail: static BOOL nsc_encode_argb_to_aycocg(NSC_CONTEXT* context, const BYTE* data, UINT32 scanline) { - UINT16 x = 0; UINT16 y = 0; UINT16 rw = 0; BYTE ccl = 0; @@ -138,7 +137,8 @@ static BOOL nsc_encode_argb_to_aycocg(NSC_CONTEXT* context, const BYTE* data, UI cgplane = context->priv->PlaneBuffers[2] + y * rw; aplane = context->priv->PlaneBuffers[3] + y * context->width; - for (UINT16 x = 0; x < context->width; x++) + UINT16 x = 0; + for (; x < context->width; x++) { switch (context->format) { diff --git a/libfreerdp/codec/planar.c b/libfreerdp/codec/planar.c index e894761c3..d63cf06f0 100644 --- a/libfreerdp/codec/planar.c +++ b/libfreerdp/codec/planar.c @@ -1675,10 +1675,12 @@ BOOL freerdp_bitmap_planar_context_reset(BITMAP_PLANAR_CONTEXT* context, UINT32 context->bgr = FALSE; context->maxWidth = PLANAR_ALIGN(width, 4); context->maxHeight = PLANAR_ALIGN(height, 4); - const UINT64 tmp = (UINT64)context->maxWidth * context->maxHeight; - if (tmp > UINT32_MAX) - return FALSE; - context->maxPlaneSize = tmp; + { + const UINT64 tmp = (UINT64)context->maxWidth * context->maxHeight; + if (tmp > UINT32_MAX) + return FALSE; + context->maxPlaneSize = tmp; + } if (context->maxWidth > UINT32_MAX / 4) return FALSE; diff --git a/libfreerdp/codec/progressive.c b/libfreerdp/codec/progressive.c index 3ab84eff6..563731e47 100644 --- a/libfreerdp/codec/progressive.c +++ b/libfreerdp/codec/progressive.c @@ -1673,7 +1673,6 @@ static INLINE SSIZE_T progressive_process_tiles(PROGRESSIVE_CONTEXT* progressive int status = 0; size_t end = 0; const size_t start = Stream_GetPosition(s); - UINT16 index = 0; UINT16 blockType = 0; UINT32 blockLen = 0; UINT32 count = 0; @@ -1779,10 +1778,10 @@ static INLINE SSIZE_T progressive_process_tiles(PROGRESSIVE_CONTEXT* progressive return -1; } - for (UINT32 index = 0; index < region->numTiles; index++) + for (UINT32 idx = 0; idx < region->numTiles; idx++) { - RFX_PROGRESSIVE_TILE* tile = region->tiles[index]; - PROGRESSIVE_TILE_PROCESS_WORK_PARAM* param = ¶ms[index]; + RFX_PROGRESSIVE_TILE* tile = region->tiles[idx]; + PROGRESSIVE_TILE_PROCESS_WORK_PARAM* param = ¶ms[idx]; param->progressive = progressive; param->region = region; param->context = context; @@ -1790,41 +1789,38 @@ static INLINE SSIZE_T progressive_process_tiles(PROGRESSIVE_CONTEXT* progressive if (progressive->rfx_context->priv->UseThreads) { - if (!(work_objects[index] = CreateThreadpoolWork( - progressive_process_tiles_tile_work_callback, (void*)¶ms[index], + if (!(work_objects[idx] = CreateThreadpoolWork( + progressive_process_tiles_tile_work_callback, (void*)¶ms[idx], &progressive->rfx_context->priv->ThreadPoolEnv))) { - WLog_ERR(TAG, "CreateThreadpoolWork failed."); + WLog_Print(progressive->log, WLOG_ERROR, + "Failed to create ThreadpoolWork for tile %" PRIu32, idx); status = -1; break; } - SubmitThreadpoolWork(work_objects[index]); - close_cnt = index + 1; + SubmitThreadpoolWork(work_objects[idx]); + close_cnt = idx + 1; } else { - progressive_process_tiles_tile_work_callback(0, ¶ms[index], 0); + progressive_process_tiles_tile_work_callback(0, ¶ms[idx], 0); } if (status < 0) { WLog_Print(progressive->log, WLOG_ERROR, "Failed to decompress %s at %" PRIu16, - rfx_get_progressive_block_type_string(tile->blockType), index); + rfx_get_progressive_block_type_string(tile->blockType), idx); goto fail; } } - if (status < 0) - WLog_Print(progressive->log, WLOG_ERROR, - "Failed to create ThreadpoolWork for tile %" PRIu16, index); - if (progressive->rfx_context->priv->UseThreads) { - for (UINT32 index = 0; index < close_cnt; index++) + for (UINT32 idx = 0; idx < close_cnt; idx++) { - WaitForThreadpoolWorkCallbacks(work_objects[index], FALSE); - CloseThreadpoolWork(work_objects[index]); + WaitForThreadpoolWorkCallbacks(work_objects[idx], FALSE); + CloseThreadpoolWork(work_objects[idx]); } } @@ -2525,10 +2521,10 @@ int progressive_compress(PROGRESSIVE_CONTEXT* progressive, const BYTE* pSrcData, if (invalidRegion) { const RECTANGLE_16* region_rects = region16_rects(invalidRegion, NULL); - for (UINT32 x = 0; x < numRects; x++) + for (UINT32 idx = 0; idx < numRects; idx++) { - const RECTANGLE_16* r = ®ion_rects[x]; - RFX_RECT* rect = &rects[x]; + const RECTANGLE_16* r = ®ion_rects[idx]; + RFX_RECT* rect = &rects[idx]; rect->x = r->left; rect->y = r->top; diff --git a/libfreerdp/common/assistance.c b/libfreerdp/common/assistance.c index dc76d6ab5..34e10f036 100644 --- a/libfreerdp/common/assistance.c +++ b/libfreerdp/common/assistance.c @@ -1351,8 +1351,8 @@ BOOL freerdp_assistance_populate_settings_from_assistance_file(rdpAssistanceFile for (size_t x = 0; x < ports; x++) { - const UINT32 port = (UINT32)ArrayList_GetItem(file->MachinePorts, x); - if (!freerdp_settings_set_pointer_array(settings, FreeRDP_TargetNetPorts, x, &port)) + const UINT32 mport = (UINT32)ArrayList_GetItem(file->MachinePorts, x); + if (!freerdp_settings_set_pointer_array(settings, FreeRDP_TargetNetPorts, x, &mport)) return FALSE; } for (size_t i = 0; i < addresses; i++) diff --git a/winpr/libwinpr/smartcard/smartcard_pcsc.c b/winpr/libwinpr/smartcard/smartcard_pcsc.c index 0745f40e4..72b789e47 100644 --- a/winpr/libwinpr/smartcard/smartcard_pcsc.c +++ b/winpr/libwinpr/smartcard/smartcard_pcsc.c @@ -1610,11 +1610,11 @@ static LONG WINAPI PCSC_SCardGetStatusChange_Internal(SCARDCONTEXT hContext, DWO if (map[i] < 0) continue; /* unmapped */ - PCSC_DWORD j = (PCSC_DWORD)map[i]; - rgReaderStates[i].dwCurrentState = (DWORD)states[j].dwCurrentState; - rgReaderStates[i].cbAtr = (DWORD)states[j].cbAtr; - CopyMemory(&(rgReaderStates[i].rgbAtr), &(states[j].rgbAtr), PCSC_MAX_ATR_SIZE); - rgReaderStates[i].dwEventState = (DWORD)states[j].dwEventState; + PCSC_DWORD k = (PCSC_DWORD)map[i]; + rgReaderStates[i].dwCurrentState = (DWORD)states[k].dwCurrentState; + rgReaderStates[i].cbAtr = (DWORD)states[k].cbAtr; + CopyMemory(&(rgReaderStates[i].rgbAtr), &(states[k].rgbAtr), PCSC_MAX_ATR_SIZE); + rgReaderStates[i].dwEventState = (DWORD)states[k].dwEventState; } free(map); diff --git a/winpr/libwinpr/synch/wait.c b/winpr/libwinpr/synch/wait.c index f9911757a..48b226b95 100644 --- a/winpr/libwinpr/synch/wait.c +++ b/winpr/libwinpr/synch/wait.c @@ -362,20 +362,20 @@ DWORD WaitForMultipleObjectsEx(DWORD nCount, const HANDLE* lpHandles, BOOL bWait polled = 0; /* first collect file descriptors to poll */ - DWORD index = 0; - for (; index < nCount; index++) + DWORD idx = 0; + for (; idx < nCount; idx++) { if (bWaitAll) { - if (signalled_handles[index]) + if (signalled_handles[idx]) continue; - poll_map[polled] = index; + poll_map[polled] = idx; } - if (!winpr_Handle_GetInfo(lpHandles[index], &Type, &Object)) + if (!winpr_Handle_GetInfo(lpHandles[idx], &Type, &Object)) { - WLog_ERR(TAG, "invalid event file descriptor at %" PRIu32, index); + WLog_ERR(TAG, "invalid event file descriptor at %" PRIu32, idx); winpr_log_backtrace(TAG, WLOG_ERROR, 20); SetLastError(ERROR_INVALID_HANDLE); goto out; @@ -384,7 +384,7 @@ DWORD WaitForMultipleObjectsEx(DWORD nCount, const HANDLE* lpHandles, BOOL bWait fd = winpr_Handle_getFd(Object); if (fd == -1) { - WLog_ERR(TAG, "invalid file descriptor at %" PRIu32, index); + WLog_ERR(TAG, "invalid file descriptor at %" PRIu32, idx); winpr_log_backtrace(TAG, WLOG_ERROR, 20); SetLastError(ERROR_INVALID_HANDLE); goto out; @@ -392,7 +392,7 @@ DWORD WaitForMultipleObjectsEx(DWORD nCount, const HANDLE* lpHandles, BOOL bWait if (!pollset_add(&pollset, fd, Object->Mode)) { - WLog_ERR(TAG, "unable to register fd in pollset at %" PRIu32, index); + WLog_ERR(TAG, "unable to register fd in pollset at %" PRIu32, idx); winpr_log_backtrace(TAG, WLOG_ERROR, 20); SetLastError(ERROR_INVALID_HANDLE); goto out; @@ -426,10 +426,10 @@ DWORD WaitForMultipleObjectsEx(DWORD nCount, const HANDLE* lpHandles, BOOL bWait { char ebuffer[256] = { 0 }; #ifdef WINPR_HAVE_POLL_H - WLog_ERR(TAG, "poll() handle %" PRIu32 " (%" PRIu32 ") failure [%d] %s", index, + WLog_ERR(TAG, "poll() handle %" PRIu32 " (%" PRIu32 ") failure [%d] %s", idx, nCount, errno, winpr_strerror(errno, ebuffer, sizeof(ebuffer))); #else - WLog_ERR(TAG, "select() handle %" PRIu32 " (%" PRIu32 ") failure [%d] %s", index, + WLog_ERR(TAG, "select() handle %" PRIu32 " (%" PRIu32 ") failure [%d] %s", idx, nCount, errno, winpr_strerror(errno, ebuffer, sizeof(ebuffer))); #endif winpr_log_backtrace(TAG, WLOG_ERROR, 20); diff --git a/winpr/libwinpr/utils/print.c b/winpr/libwinpr/utils/print.c index 5f0c4a65c..750398379 100644 --- a/winpr/libwinpr/utils/print.c +++ b/winpr/libwinpr/utils/print.c @@ -109,10 +109,10 @@ void winpr_HexLogDump(wLog* log, UINT32 lvl, const void* data, size_t length) pos += (size_t)rc; } - for (size_t i = 0; i < line; i++) + for (size_t j = 0; j < line; j++) { rc = _snprintf(&buffer[pos], blen - pos, "%c", - (p[i] >= 0x20 && p[i] < 0x7F) ? (char)p[i] : '.'); + (p[j] >= 0x20 && p[j] < 0x7F) ? (char)p[j] : '.'); if (rc < 0) goto fail; diff --git a/winpr/tools/hash-cli/hash.c b/winpr/tools/hash-cli/hash.c index b98f8e9c9..f1e9261fd 100644 --- a/winpr/tools/hash-cli/hash.c +++ b/winpr/tools/hash-cli/hash.c @@ -189,8 +189,8 @@ int main(int argc, char* argv[]) if (format == 0) { - for (int index = 0; index < 16; index++) - printf("%02" PRIx8 "", NtHash[index]); + for (int idx = 0; idx < 16; idx++) + printf("%02" PRIx8 "", NtHash[idx]); printf("\n"); } @@ -205,8 +205,8 @@ int main(int argc, char* argv[]) printf(":"); - for (int index = 0; index < 16; index++) - printf("%02" PRIx8 "", NtHash[index]); + for (int idx = 0; idx < 16; idx++) + printf("%02" PRIx8 "", NtHash[idx]); printf(":::"); printf("\n");