From d7ebec5a6524b1da9b90a327329fb5696bdab62c Mon Sep 17 00:00:00 2001 From: akallabeth Date: Tue, 30 Jan 2024 10:25:38 +0100 Subject: [PATCH] [tidy] move loop variable declaration to loop --- channels/audin/client/ios/audin_ios.m | 3 +- channels/audin/client/mac/audin_mac.m | 3 +- channels/audin/client/winmm/audin_winmm.c | 18 ++- channels/client/addin.c | 17 +-- channels/cliprdr/client/cliprdr_main.c | 3 +- channels/cliprdr/cliprdr_common.c | 11 +- channels/cliprdr/server/cliprdr_main.c | 6 +- channels/disp/client/disp_main.c | 3 +- channels/disp/server/disp_main.c | 3 +- channels/drdynvc/client/drdynvc_main.c | 17 +-- channels/drive/client/drive_file.c | 4 +- channels/drive/client/drive_main.c | 10 +- channels/geometry/client/geometry_main.c | 3 +- channels/parallel/client/parallel_main.c | 3 +- channels/printer/client/cups/printer_cups.c | 5 +- channels/printer/client/printer_main.c | 3 +- channels/printer/client/win/printer_win.c | 3 +- channels/rdp2tcp/client/rdp2tcp_main.c | 5 +- channels/rdpdr/client/rdpdr_capabilities.c | 3 +- channels/rdpdr/client/rdpdr_main.c | 44 +++---- channels/rdpdr/server/rdpdr_main.c | 12 +- .../server/camera_device_enumerator_main.c | 2 +- channels/rdpecam/server/camera_device_main.c | 10 +- channels/rdpei/client/rdpei_main.c | 22 ++-- channels/rdpei/rdpei_common.c | 8 +- channels/rdpei/server/rdpei_main.c | 12 +- channels/rdpgfx/client/rdpgfx_codec.c | 5 +- channels/rdpgfx/client/rdpgfx_main.c | 44 +++---- channels/rdpgfx/server/rdpgfx_main.c | 25 ++-- channels/rdpsnd/client/alsa/rdpsnd_alsa.c | 8 +- channels/rdpsnd/client/ios/rdpsnd_ios.c | 4 +- channels/rdpsnd/client/mac/rdpsnd_mac.m | 6 +- channels/rdpsnd/client/pulse/rdpsnd_pulse.c | 3 +- channels/rdpsnd/client/rdpsnd_main.c | 15 +-- channels/rdpsnd/server/rdpsnd_main.c | 3 +- channels/remdesk/client/remdesk_main.c | 3 +- channels/remdesk/server/remdesk_main.c | 3 +- channels/serial/client/serial_main.c | 3 +- channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c | 3 +- channels/tsmf/client/gstreamer/tsmf_X11.c | 3 +- channels/tsmf/client/tsmf_codec.c | 4 +- channels/tsmf/client/tsmf_ifman.c | 5 +- channels/tsmf/client/tsmf_media.c | 61 +++------ channels/urbdrc/client/data_transfer.c | 3 +- .../urbdrc/client/libusb/libusb_udevice.c | 67 ++++------ .../urbdrc/client/libusb/libusb_udevman.c | 13 +- channels/urbdrc/common/msusb.c | 31 ++--- .../src/main/cpp/android_cliprdr.c | 16 +-- .../freeRDPCore/src/main/cpp/android_event.c | 3 +- .../src/main/cpp/android_freerdp.c | 9 +- .../src/main/cpp/android_jni_utils.c | 3 +- client/Mac/Clipboard.m | 15 +-- client/Mac/MRDPView.m | 4 +- client/SDL/sdl_freerdp.cpp | 6 +- client/SDL/sdl_monitor.cpp | 3 +- client/Wayland/wlf_cliprdr.c | 12 +- client/Wayland/wlf_disp.c | 3 +- client/Wayland/wlf_input.c | 5 +- client/Wayland/wlfreerdp.c | 3 +- client/Windows/cli/wfreerdp.c | 6 +- client/Windows/wf_client.c | 3 +- client/Windows/wf_cliprdr.c | 87 +++++-------- client/Windows/wf_floatbar.c | 18 +-- client/Windows/wf_gdi.c | 32 ++--- client/Windows/wf_graphics.c | 3 +- client/Windows/wf_rail.c | 21 ++-- client/X11/xf_client.c | 19 ++- client/X11/xf_cliprdr.c | 32 ++--- client/X11/xf_disp.c | 3 +- client/X11/xf_event.c | 9 +- client/X11/xf_floatbar.c | 6 +- client/X11/xf_gfx.c | 9 +- client/X11/xf_graphics.c | 3 +- client/X11/xf_input.c | 12 +- client/X11/xf_monitor.c | 20 +-- client/X11/xf_rail.c | 7 +- client/X11/xf_tsmf.c | 19 ++- client/X11/xf_window.c | 18 +-- client/common/client.c | 3 +- client/common/client_cliprdr_file.c | 6 +- client/common/cmdline.c | 40 ++---- client/common/file.c | 15 +-- client/common/test/TestClientChannels.c | 22 ++-- client/common/test/TestClientCmdLine.c | 9 +- client/common/test/TestClientRdpFile.c | 6 +- client/iOS/Additions/OrderedDictionary.m | 4 +- client/iOS/Additions/TSXAdditions.m | 3 +- client/iOS/FreeRDP/ios_cliprdr.m | 16 +-- client/iOS/Models/RDPSession.m | 4 +- client/iOS/Views/TouchPointerView.m | 5 +- include/freerdp/utils/pod_arrays.h | 6 +- libfreerdp/cache/bitmap.c | 10 +- libfreerdp/cache/brush.c | 6 +- libfreerdp/cache/glyph.c | 34 ++--- libfreerdp/cache/nine_grid.c | 3 +- libfreerdp/cache/offscreen.c | 6 +- libfreerdp/cache/palette.c | 4 +- libfreerdp/cache/pointer.c | 7 +- libfreerdp/codec/audio.c | 11 +- libfreerdp/codec/bitmap.c | 6 +- libfreerdp/codec/clear.c | 13 +- libfreerdp/codec/color.c | 56 +++------ libfreerdp/codec/dsp.c | 25 ++-- libfreerdp/codec/dsp_ffmpeg.c | 12 +- libfreerdp/codec/h264.c | 28 ++--- libfreerdp/codec/h264_ffmpeg.c | 4 +- libfreerdp/codec/h264_mf.c | 3 +- libfreerdp/codec/h264_openh264.c | 15 +-- libfreerdp/codec/interleaved.c | 21 ++-- libfreerdp/codec/ncrush.c | 44 +++---- libfreerdp/codec/nsc.c | 6 +- libfreerdp/codec/nsc_encode.c | 18 ++- libfreerdp/codec/nsc_sse2.c | 16 +-- libfreerdp/codec/planar.c | 65 ++++------ libfreerdp/codec/progressive.c | 29 ++--- libfreerdp/codec/region.c | 3 +- libfreerdp/codec/rfx.c | 3 +- libfreerdp/codec/rfx_differential.h | 9 +- libfreerdp/codec/rfx_dwt.c | 2 +- libfreerdp/codec/rfx_encode.c | 26 ++-- libfreerdp/codec/rfx_neon.c | 7 +- libfreerdp/codec/rfx_quantization.c | 3 +- libfreerdp/codec/rfx_sse2.c | 34 ++--- .../codec/test/TestFreeRDPCodecInterleaved.c | 12 +- .../codec/test/TestFreeRDPCodecPlanar.c | 27 ++-- .../codec/test/TestFreeRDPCodecProgressive.c | 30 ++--- .../codec/test/TestFreeRDPCodecRemoteFX.c | 3 +- .../codec/test/TestFreeRDPCodecXCrush.c | 3 +- libfreerdp/codec/test/TestFreeRDPRegion.c | 13 +- libfreerdp/codec/xcrush.c | 17 +-- libfreerdp/codec/yuv.c | 24 ++-- libfreerdp/codec/zgfx.c | 2 +- libfreerdp/common/settings.c | 76 ++++-------- libfreerdp/common/test/TestAddinArgv.c | 19 ++- libfreerdp/core/activation.c | 8 +- libfreerdp/core/capabilities.c | 16 +-- libfreerdp/core/channels.c | 6 +- libfreerdp/core/client.c | 54 +++----- libfreerdp/core/connection.c | 10 +- libfreerdp/core/display.c | 7 +- libfreerdp/core/fastpath.c | 7 +- libfreerdp/core/gateway/http.c | 7 +- libfreerdp/core/gateway/rdg.c | 3 +- libfreerdp/core/gateway/rpc_client.c | 9 +- libfreerdp/core/gateway/rpc_fault.c | 15 +-- libfreerdp/core/gateway/rts.c | 26 ++-- libfreerdp/core/gateway/rts_signature.c | 10 +- libfreerdp/core/gateway/tsg.c | 4 +- libfreerdp/core/gcc.c | 24 ++-- libfreerdp/core/info.c | 3 +- libfreerdp/core/input.c | 3 +- libfreerdp/core/listener.c | 12 +- libfreerdp/core/mcs.c | 4 +- libfreerdp/core/nego.c | 5 +- libfreerdp/core/orders.c | 50 +++----- libfreerdp/core/peer.c | 2 +- libfreerdp/core/rdp.c | 5 +- libfreerdp/core/server.c | 21 ++-- libfreerdp/core/settings.c | 16 +-- libfreerdp/core/smartcardlogon.c | 5 +- libfreerdp/core/streamdump.c | 3 +- libfreerdp/core/tcp.c | 7 +- libfreerdp/core/test/TestConnect.c | 3 +- libfreerdp/core/test/TestSettings.c | 38 +++--- libfreerdp/core/test/TestStreamDump.c | 3 +- libfreerdp/core/transport.c | 3 +- libfreerdp/core/update.c | 12 +- libfreerdp/core/window.c | 18 +-- libfreerdp/crypto/base64.c | 6 +- libfreerdp/crypto/certificate.c | 43 ++++--- libfreerdp/crypto/certificate_data.c | 3 +- libfreerdp/crypto/crypto.c | 5 +- libfreerdp/crypto/per.c | 10 +- libfreerdp/crypto/test/TestBase64.c | 9 +- libfreerdp/crypto/test/TestKnownHosts.c | 3 +- libfreerdp/crypto/x509_utils.c | 6 +- libfreerdp/emu/scard/smartcard_emulate.c | 32 ++--- libfreerdp/emu/scard/smartcard_virtual_gids.c | 3 +- libfreerdp/gdi/bitmap.c | 18 ++- libfreerdp/gdi/gdi.c | 16 +-- libfreerdp/gdi/gfx.c | 32 ++--- libfreerdp/gdi/shape.c | 16 +-- libfreerdp/gdi/test/TestGdiBitBlt.c | 9 +- libfreerdp/gdi/test/TestGdiCreate.c | 18 +-- libfreerdp/gdi/test/TestGdiEllipse.c | 6 +- libfreerdp/gdi/test/TestGdiLine.c | 30 +++-- libfreerdp/gdi/test/TestGdiRect.c | 6 +- libfreerdp/gdi/test/TestGdiRop3.c | 6 +- libfreerdp/gdi/test/helpers.c | 20 ++- libfreerdp/locale/keyboard.c | 7 +- libfreerdp/locale/keyboard_apple.c | 3 +- libfreerdp/locale/keyboard_layout.c | 30 ++--- libfreerdp/locale/keyboard_sun.c | 3 +- libfreerdp/locale/keyboard_x11.c | 4 +- libfreerdp/locale/locale.c | 7 +- libfreerdp/primitives/prim_YCoCg.c | 6 +- libfreerdp/primitives/prim_YCoCg_opt.c | 15 +-- libfreerdp/primitives/prim_YUV.c | 75 ++++------- libfreerdp/primitives/prim_YUV_neon.c | 43 +++---- libfreerdp/primitives/prim_YUV_ssse3.c | 68 +++++----- libfreerdp/primitives/prim_alphaComp.c | 7 +- libfreerdp/primitives/prim_alphaComp_opt.c | 3 +- libfreerdp/primitives/prim_colors.c | 53 +++----- libfreerdp/primitives/prim_colors_opt.c | 117 ++++++------------ libfreerdp/primitives/primitives.c | 12 +- .../primitives/test/TestPrimitivesAlphaComp.c | 13 +- .../primitives/test/TestPrimitivesAndOr.c | 7 +- .../primitives/test/TestPrimitivesColors.c | 23 ++-- .../primitives/test/TestPrimitivesCopy.c | 14 +-- .../primitives/test/TestPrimitivesSet.c | 54 +++----- .../primitives/test/TestPrimitivesYCbCr.c | 13 +- .../primitives/test/TestPrimitivesYCoCg.c | 10 +- .../primitives/test/TestPrimitivesYUV.c | 54 +++----- libfreerdp/primitives/test/prim_test.c | 4 +- libfreerdp/utils/smartcard_call.c | 31 ++--- libfreerdp/utils/smartcard_operations.c | 6 +- libfreerdp/utils/smartcard_pack.c | 35 ++---- libfreerdp/utils/string.c | 3 +- libfreerdp/utils/test/TestPodArrays.c | 3 +- libfreerdp/utils/test/TestRingBuffer.c | 23 ++-- rdtk/sample/rdtk_x11.c | 3 +- scripts/LECHash.c | 12 +- scripts/LOMHash.c | 12 +- server/Mac/mf_info.c | 3 +- server/Mac/mf_mountain_lion.c | 7 +- server/Mac/mf_rdpsnd.c | 8 +- server/Sample/sfreerdp.c | 3 +- server/Windows/cli/wfreerdp.c | 9 +- server/Windows/wf_dxgi.c | 3 +- server/Windows/wf_info.c | 6 +- server/Windows/wf_rdpsnd.c | 6 +- server/Windows/wf_update.c | 8 +- server/Windows/wf_wasapi.c | 4 +- server/common/server.c | 8 +- server/proxy/channels/pf_channel_rdpdr.c | 9 +- server/proxy/pf_client.c | 4 +- server/proxy/pf_config.c | 10 +- server/proxy/pf_modules.c | 3 +- server/proxy/pf_server.c | 7 +- server/proxy/pf_utils.c | 5 +- server/shadow/Mac/mac_shadow.c | 8 +- server/shadow/Win/win_dxgi.c | 5 +- server/shadow/Win/win_rdp.c | 3 +- server/shadow/X11/x11_shadow.c | 30 ++--- server/shadow/shadow_capture.c | 19 ++- server/shadow/shadow_client.c | 23 ++-- server/shadow/shadow_encoder.c | 9 +- server/shadow/shadow_mcevent.c | 3 +- server/shadow/shadow_server.c | 6 +- server/shadow/shadow_subsystem.c | 6 +- uwac/libuwac/uwac-display.c | 4 +- uwac/libuwac/uwac-input.c | 4 +- uwac/libuwac/uwac-os.c | 3 +- uwac/libuwac/uwac-window.c | 41 +++--- winpr/libwinpr/clipboard/clipboard.c | 11 +- winpr/libwinpr/clipboard/synthetic_file.c | 15 +-- .../clipboard/test/TestClipboardFormats.c | 5 +- winpr/libwinpr/comm/comm.c | 7 +- winpr/libwinpr/comm/comm_ioctl.c | 4 +- winpr/libwinpr/comm/comm_serial_sys.c | 10 +- winpr/libwinpr/crt/string.c | 28 ++--- winpr/libwinpr/crypto/cipher.c | 4 +- winpr/libwinpr/environment/environment.c | 5 +- .../error/test/TestErrorSetLastError.c | 3 +- winpr/libwinpr/file/file.c | 4 +- winpr/libwinpr/file/generic.c | 4 +- .../file/test/TestSetFileAttributes.c | 10 +- winpr/libwinpr/input/keycode.c | 3 +- winpr/libwinpr/input/virtualkey.c | 8 +- .../interlocked/test/TestInterlockedAccess.c | 5 +- winpr/libwinpr/ncrypt/ncrypt_pkcs11.c | 14 +-- .../ncrypt/test/TestNCryptProviders.c | 3 +- .../ncrypt/test/TestNCryptSmartcard.c | 3 +- winpr/libwinpr/nt/ntstatus.c | 6 +- winpr/libwinpr/path/path.c | 20 ++- winpr/libwinpr/path/shell.c | 6 +- winpr/libwinpr/path/test/TestPathCchAppend.c | 3 +- .../path/test/TestPathCchStripPrefix.c | 5 +- winpr/libwinpr/path/test/TestPathMakePath.c | 3 +- winpr/libwinpr/path/test/TestPathShell.c | 3 +- winpr/libwinpr/pipe/pipe.c | 6 +- .../pipe/test/TestPipeCreateNamedPipe.c | 15 ++- winpr/libwinpr/pool/pool.c | 3 +- winpr/libwinpr/pool/test/TestPoolWork.c | 9 +- winpr/libwinpr/registry/registry_reg.c | 3 +- winpr/libwinpr/rpc/rpc.c | 6 +- winpr/libwinpr/smartcard/smartcard_pcsc.c | 21 ++-- winpr/libwinpr/sspi/NTLM/ntlm.c | 4 +- winpr/libwinpr/sspi/NTLM/ntlm_message.c | 4 +- winpr/libwinpr/sspi/sspi_winpr.c | 42 +++---- .../sspi/test/TestEnumerateSecurityPackages.c | 3 +- winpr/libwinpr/sspi/test/TestSchannel.c | 5 +- winpr/libwinpr/synch/event.c | 8 +- winpr/libwinpr/synch/mutex.c | 3 +- winpr/libwinpr/synch/test/TestSynchBarrier.c | 7 +- winpr/libwinpr/synch/test/TestSynchCritical.c | 22 ++-- winpr/libwinpr/synch/test/TestSynchEvent.c | 3 +- winpr/libwinpr/synch/test/TestSynchInit.c | 7 +- winpr/libwinpr/synch/test/TestSynchMutex.c | 5 +- winpr/libwinpr/synch/test/TestSynchThread.c | 3 +- .../libwinpr/synch/test/TestSynchTimerQueue.c | 7 +- winpr/libwinpr/synch/wait.c | 6 +- .../sysinfo/cpufeatures/cpu-features.c | 10 +- winpr/libwinpr/thread/apc.c | 7 +- winpr/libwinpr/thread/argv.c | 3 +- winpr/libwinpr/thread/process.c | 6 +- .../thread/test/TestThreadCommandLineToArgv.c | 3 +- .../thread/test/TestThreadExitThread.c | 3 +- winpr/libwinpr/thread/thread.c | 16 ++- winpr/libwinpr/timezone/timezone.c | 15 +-- winpr/libwinpr/utils/asn1/asn1.c | 9 +- winpr/libwinpr/utils/cmdline.c | 37 ++---- winpr/libwinpr/utils/collections/ArrayList.c | 25 ++-- winpr/libwinpr/utils/collections/BitStream.c | 4 +- winpr/libwinpr/utils/collections/BufferPool.c | 10 +- winpr/libwinpr/utils/collections/HashTable.c | 41 +++--- winpr/libwinpr/utils/collections/PubSub.c | 9 +- winpr/libwinpr/utils/collections/Queue.c | 7 +- winpr/libwinpr/utils/collections/Stack.c | 7 +- winpr/libwinpr/utils/collections/StreamPool.c | 20 +-- winpr/libwinpr/utils/corkscrew/debug.c | 5 +- winpr/libwinpr/utils/debug.c | 3 +- winpr/libwinpr/utils/image.c | 3 +- winpr/libwinpr/utils/print.c | 15 +-- winpr/libwinpr/utils/ssl.c | 7 +- winpr/libwinpr/utils/stream.c | 8 +- winpr/libwinpr/utils/strlst.c | 14 +-- winpr/libwinpr/utils/test/TestASN1.c | 5 +- winpr/libwinpr/utils/test/TestArrayList.c | 7 +- winpr/libwinpr/utils/test/TestBacktrace.c | 3 +- winpr/libwinpr/utils/test/TestBitStream.c | 8 +- winpr/libwinpr/utils/test/TestCmdLine.c | 8 +- winpr/libwinpr/utils/test/TestPrint.c | 2 +- winpr/libwinpr/utils/test/TestQueue.c | 5 +- winpr/libwinpr/utils/test/TestStream.c | 15 +-- winpr/libwinpr/utils/test/TestStreamPool.c | 7 +- winpr/libwinpr/utils/unwind/debug.c | 3 +- winpr/libwinpr/utils/windows/debug.c | 5 +- winpr/libwinpr/utils/wlog/wlog.c | 31 ++--- winpr/libwinpr/winsock/winsock.c | 3 +- .../test/TestWtsApiEnumerateProcesses.c | 3 +- .../wtsapi/test/TestWtsApiEnumerateSessions.c | 3 +- .../test/TestWtsApiQuerySessionInformation.c | 6 +- winpr/test/TestTypes.c | 3 +- winpr/tools/hash-cli/hash.c | 4 +- 345 files changed, 1568 insertions(+), 2828 deletions(-) diff --git a/channels/audin/client/ios/audin_ios.m b/channels/audin/client/ios/audin_ios.m index b5941c940..ae30aee71 100644 --- a/channels/audin/client/ios/audin_ios.m +++ b/channels/audin/client/ios/audin_ios.m @@ -222,7 +222,6 @@ static UINT audin_ios_open(IAudinDevice *device, AudinReceive receive, void *use DWORD errCode; char errString[1024]; OSStatus devStat; - size_t index; ios->receive = receive; ios->user_data = user_data; @@ -237,7 +236,7 @@ static UINT audin_ios_open(IAudinDevice *device, AudinReceive receive, void *use goto err_out; } - for (index = 0; index < IOS_AUDIO_QUEUE_NUM_BUFFERS; index++) + for (size_t index = 0; index < IOS_AUDIO_QUEUE_NUM_BUFFERS; index++) { devStat = AudioQueueAllocateBuffer(ios->audioQueue, ios->FramesPerPacket * 2 * ios->format.nChannels, diff --git a/channels/audin/client/mac/audin_mac.m b/channels/audin/client/mac/audin_mac.m index ae6ddac04..19749a966 100644 --- a/channels/audin/client/mac/audin_mac.m +++ b/channels/audin/client/mac/audin_mac.m @@ -247,7 +247,6 @@ static UINT audin_mac_open(IAudinDevice *device, AudinReceive receive, void *use DWORD errCode; char errString[1024]; OSStatus devStat; - size_t index; if (!mac->isAuthorized) return ERROR_INTERNAL_ERROR; @@ -265,7 +264,7 @@ static UINT audin_mac_open(IAudinDevice *device, AudinReceive receive, void *use goto err_out; } - for (index = 0; index < MAC_AUDIO_QUEUE_NUM_BUFFERS; index++) + for (size_t index = 0; index < MAC_AUDIO_QUEUE_NUM_BUFFERS; index++) { devStat = AudioQueueAllocateBuffer(mac->audioQueue, mac->FramesPerPacket * 2 * mac->format.nChannels, diff --git a/channels/audin/client/winmm/audin_winmm.c b/channels/audin/client/winmm/audin_winmm.c index abba9c8ed..b4172a516 100644 --- a/channels/audin/client/winmm/audin_winmm.c +++ b/channels/audin/client/winmm/audin_winmm.c @@ -168,11 +168,11 @@ static BOOL test_format_supported(const PWAVEFORMATEX pwfx) static DWORD WINAPI audin_winmm_thread_func(LPVOID arg) { AudinWinmmDevice* winmm = (AudinWinmmDevice*)arg; - char* buffer; - int size, i; + char* buffer = NULL; + int size = 0; WAVEHDR waveHdr[4] = { 0 }; - DWORD status; - MMRESULT rc; + DWORD status = 0; + MMRESULT rc = 0; if (!winmm->hWaveIn) { @@ -189,7 +189,7 @@ static DWORD WINAPI audin_winmm_thread_func(LPVOID arg) 7) / 8; - for (i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { buffer = (char*)malloc(size); @@ -235,7 +235,7 @@ static DWORD WINAPI audin_winmm_thread_func(LPVOID arg) { } - for (i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { rc = waveInUnprepareHeader(winmm->hWaveIn, &waveHdr[i], sizeof(waveHdr[i])); @@ -263,13 +263,12 @@ static DWORD WINAPI audin_winmm_thread_func(LPVOID arg) */ static UINT audin_winmm_free(IAudinDevice* device) { - UINT32 i; AudinWinmmDevice* winmm = (AudinWinmmDevice*)device; if (!winmm) return ERROR_INVALID_PARAMETER; - for (i = 0; i < winmm->cFormats; i++) + for (UINT32 i = 0; i < winmm->cFormats; i++) { free(winmm->ppwfx[i]); } @@ -322,7 +321,6 @@ static UINT audin_winmm_close(IAudinDevice* device) static UINT audin_winmm_set_format(IAudinDevice* device, const AUDIO_FORMAT* format, UINT32 FramesPerPacket) { - UINT32 i; AudinWinmmDevice* winmm = (AudinWinmmDevice*)device; if (!winmm || !format) @@ -330,7 +328,7 @@ static UINT audin_winmm_set_format(IAudinDevice* device, const AUDIO_FORMAT* for winmm->frames_per_packet = FramesPerPacket; - for (i = 0; i < winmm->cFormats; i++) + for (UINT32 i = 0; i < winmm->cFormats; i++) { const PWAVEFORMATEX ppwfx = winmm->ppwfx[i]; if ((ppwfx->wFormatTag == format->wFormatTag) && (ppwfx->nChannels == format->nChannels) && diff --git a/channels/client/addin.c b/channels/client/addin.c index 012964fc5..6d87f6c91 100644 --- a/channels/client/addin.c +++ b/channels/client/addin.c @@ -87,8 +87,6 @@ static FREERDP_ADDIN** freerdp_channels_list_client_static_addins(LPCSTR pszName LPCSTR pszSubsystem, LPCSTR pszType, DWORD dwFlags) { - size_t i = 0; - size_t j = 0; DWORD nAddins = 0; FREERDP_ADDIN** ppAddins = NULL; const STATIC_SUBSYSTEM_ENTRY* subsystems = NULL; @@ -103,7 +101,7 @@ static FREERDP_ADDIN** freerdp_channels_list_client_static_addins(LPCSTR pszName ppAddins[nAddins] = NULL; - for (i = 0; CLIENT_STATIC_ADDIN_TABLE[i].name != NULL; i++) + for (size_t i = 0; CLIENT_STATIC_ADDIN_TABLE[i].name != NULL; i++) { FREERDP_ADDIN* pAddin = (FREERDP_ADDIN*)calloc(1, sizeof(FREERDP_ADDIN)); @@ -120,7 +118,7 @@ static FREERDP_ADDIN** freerdp_channels_list_client_static_addins(LPCSTR pszName ppAddins[nAddins++] = pAddin; subsystems = (const STATIC_SUBSYSTEM_ENTRY*)CLIENT_STATIC_ADDIN_TABLE[i].table; - for (j = 0; subsystems[j].name != NULL; j++) + for (size_t j = 0; subsystems[j].name != NULL; j++) { pAddin = (FREERDP_ADDIN*)calloc(1, sizeof(FREERDP_ADDIN)); @@ -165,7 +163,6 @@ static HANDLE FindFirstFileUTF8(LPCSTR pszSearchPath, WIN32_FIND_DATAW* FindData static FREERDP_ADDIN** freerdp_channels_list_dynamic_addins(LPCSTR pszName, LPCSTR pszSubsystem, LPCSTR pszType, DWORD dwFlags) { - int index = 0; int nDashes = 0; HANDLE hFind = NULL; DWORD nAddins = 0; @@ -270,7 +267,7 @@ static FREERDP_ADDIN** freerdp_channels_list_dynamic_addins(LPCSTR pszName, LPCS goto skip; nDashes = 0; - for (index = 0; cFileName[index]; index++) + for (size_t index = 0; cFileName[index]; index++) nDashes += (cFileName[index] == '-') ? 1 : 0; if (nDashes == 1) @@ -428,12 +425,10 @@ FREERDP_ADDIN** freerdp_channels_list_addins(LPCSTR pszName, LPCSTR pszSubsystem void freerdp_channels_addin_list_free(FREERDP_ADDIN** ppAddins) { - size_t index = 0; - if (!ppAddins) return; - for (index = 0; ppAddins[index] != NULL; index++) + for (size_t index = 0; ppAddins[index] != NULL; index++) free(ppAddins[index]); free(ppAddins); @@ -443,9 +438,7 @@ extern const STATIC_ENTRY CLIENT_VirtualChannelEntryEx_TABLE[]; static BOOL freerdp_channels_is_virtual_channel_entry_ex(LPCSTR pszName) { - size_t i = 0; - - for (i = 0; CLIENT_VirtualChannelEntryEx_TABLE[i].name != NULL; i++) + for (size_t i = 0; CLIENT_VirtualChannelEntryEx_TABLE[i].name != NULL; i++) { const STATIC_ENTRY* entry = &CLIENT_VirtualChannelEntryEx_TABLE[i]; diff --git a/channels/cliprdr/client/cliprdr_main.c b/channels/cliprdr/client/cliprdr_main.c index c613b6312..60ae27d7c 100644 --- a/channels/cliprdr/client/cliprdr_main.c +++ b/channels/cliprdr/client/cliprdr_main.c @@ -223,7 +223,6 @@ static UINT cliprdr_process_general_capability(cliprdrPlugin* cliprdr, wStream* static UINT cliprdr_process_clip_caps(cliprdrPlugin* cliprdr, wStream* s, UINT32 length, UINT16 flags) { - UINT16 index = 0; UINT16 lengthCapability = 0; UINT16 cCapabilitiesSets = 0; UINT16 capabilitySetType = 0; @@ -239,7 +238,7 @@ static UINT cliprdr_process_clip_caps(cliprdrPlugin* cliprdr, wStream* s, UINT32 Stream_Seek_UINT16(s); /* pad1 (2 bytes) */ WLog_Print(cliprdr->log, WLOG_DEBUG, "ServerCapabilities"); - for (index = 0; index < cCapabilitiesSets; index++) + for (UINT16 index = 0; index < cCapabilitiesSets; index++) { if (!Stream_CheckAndLogRequiredLength(TAG, s, 4)) return ERROR_INVALID_DATA; diff --git a/channels/cliprdr/cliprdr_common.c b/channels/cliprdr/cliprdr_common.c index 9a98cb6e0..d346cb13d 100644 --- a/channels/cliprdr/cliprdr_common.c +++ b/channels/cliprdr/cliprdr_common.c @@ -184,7 +184,6 @@ wStream* cliprdr_packet_format_list_new(const CLIPRDR_FORMAT_LIST* formatList, BOOL useLongFormatNames) { wStream* s = NULL; - UINT32 index = 0; size_t formatNameSize = 0; char* szFormatName = NULL; WCHAR* wszFormatName = NULL; @@ -206,7 +205,7 @@ wStream* cliprdr_packet_format_list_new(const CLIPRDR_FORMAT_LIST* formatList, return NULL; } - for (index = 0; index < formatList->numFormats; index++) + for (UINT32 index = 0; index < formatList->numFormats; index++) { size_t formatNameLength = 0; format = (CLIPRDR_FORMAT*)&(formatList->formats[index]); @@ -259,7 +258,7 @@ wStream* cliprdr_packet_format_list_new(const CLIPRDR_FORMAT_LIST* formatList, else { length = 0; - for (index = 0; index < formatList->numFormats; index++) + for (UINT32 index = 0; index < formatList->numFormats; index++) { format = (CLIPRDR_FORMAT*)&(formatList->formats[index]); length += 4; @@ -284,7 +283,7 @@ wStream* cliprdr_packet_format_list_new(const CLIPRDR_FORMAT_LIST* formatList, return NULL; } - for (index = 0; index < formatList->numFormats; index++) + for (UINT32 index = 0; index < formatList->numFormats; index++) { format = (CLIPRDR_FORMAT*)&(formatList->formats[index]); Stream_Write_UINT32(s, format->formatId); /* formatId (4 bytes) */ @@ -550,14 +549,12 @@ error_out: void cliprdr_free_format_list(CLIPRDR_FORMAT_LIST* formatList) { - UINT index = 0; - if (formatList == NULL) return; if (formatList->formats) { - for (index = 0; index < formatList->numFormats; index++) + for (UINT32 index = 0; index < formatList->numFormats; index++) { free(formatList->formats[index].formatName); } diff --git a/channels/cliprdr/server/cliprdr_main.c b/channels/cliprdr/server/cliprdr_main.c index 6fee15470..9823f1719 100644 --- a/channels/cliprdr/server/cliprdr_main.c +++ b/channels/cliprdr/server/cliprdr_main.c @@ -119,14 +119,12 @@ static UINT cliprdr_server_capabilities(CliprdrServerContext* context, const CLIPRDR_CAPABILITIES* capabilities) { size_t offset = 0; - UINT32 x = 0; wStream* s = NULL; - CliprdrServerPrivate* cliprdr = NULL; WINPR_ASSERT(context); WINPR_ASSERT(capabilities); - cliprdr = (CliprdrServerPrivate*)context->handle; + CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle; if (capabilities->common.msgType != CB_CLIP_CAPS) WLog_WARN(TAG, "called with invalid type %08" PRIx32, capabilities->common.msgType); @@ -148,7 +146,7 @@ static UINT cliprdr_server_capabilities(CliprdrServerContext* context, Stream_Write_UINT16(s, (UINT16)capabilities->cCapabilitiesSets); /* cCapabilitiesSets (2 bytes) */ Stream_Write_UINT16(s, 0); /* pad1 (2 bytes) */ - for (x = 0; x < capabilities->cCapabilitiesSets; x++) + for (UINT32 x = 0; x < capabilities->cCapabilitiesSets; x++) { const CLIPRDR_CAPABILITY_SET* cap = (const CLIPRDR_CAPABILITY_SET*)(((const BYTE*)capabilities->capabilitySets) + offset); diff --git a/channels/disp/client/disp_main.c b/channels/disp/client/disp_main.c index e1c1e85d5..f01824013 100644 --- a/channels/disp/client/disp_main.c +++ b/channels/disp/client/disp_main.c @@ -63,7 +63,6 @@ disp_send_display_control_monitor_layout_pdu(GENERIC_CHANNEL_CALLBACK* callback, { UINT status = 0; wStream* s = NULL; - UINT32 index = 0; DISP_PLUGIN* disp = NULL; UINT32 MonitorLayoutSize = 0; DISPLAY_CONTROL_HEADER header = { 0 }; @@ -99,7 +98,7 @@ disp_send_display_control_monitor_layout_pdu(GENERIC_CHANNEL_CALLBACK* callback, Stream_Write_UINT32(s, NumMonitors); /* NumMonitors (4 bytes) */ WLog_DBG(TAG, "NumMonitors=%" PRIu32 "", NumMonitors); - for (index = 0; index < NumMonitors; index++) + for (UINT32 index = 0; index < NumMonitors; index++) { DISPLAY_CONTROL_MONITOR_LAYOUT current = Monitors[index]; current.Width -= (current.Width % 2); diff --git a/channels/disp/server/disp_main.c b/channels/disp/server/disp_main.c index 43e0c1af2..2bb6e7bc8 100644 --- a/channels/disp/server/disp_main.c +++ b/channels/disp/server/disp_main.c @@ -127,7 +127,6 @@ static BOOL disp_server_is_monitor_layout_valid(const DISPLAY_CONTROL_MONITOR_LA static UINT disp_recv_display_control_monitor_layout_pdu(wStream* s, DispServerContext* context) { UINT32 error = CHANNEL_RC_OK; - UINT32 index = 0; DISPLAY_CONTROL_MONITOR_LAYOUT_PDU pdu = { 0 }; WINPR_ASSERT(s); @@ -170,7 +169,7 @@ static UINT disp_recv_display_control_monitor_layout_pdu(wStream* s, DispServerC WLog_DBG(TAG, "disp_recv_display_control_monitor_layout_pdu: NumMonitors=%" PRIu32 "", pdu.NumMonitors); - for (index = 0; index < pdu.NumMonitors; index++) + for (UINT32 index = 0; index < pdu.NumMonitors; index++) { DISPLAY_CONTROL_MONITOR_LAYOUT* monitor = &(pdu.Monitors[index]); diff --git a/channels/drdynvc/client/drdynvc_main.c b/channels/drdynvc/client/drdynvc_main.c index 61b2b4197..0b85c0fe3 100644 --- a/channels/drdynvc/client/drdynvc_main.c +++ b/channels/drdynvc/client/drdynvc_main.c @@ -152,7 +152,6 @@ static UINT dvcman_register_plugin(IDRDYNVC_ENTRY_POINTS* pEntryPoints, const ch static IWTSPlugin* dvcman_get_plugin(IDRDYNVC_ENTRY_POINTS* pEntryPoints, const char* name) { IWTSPlugin* plugin = NULL; - size_t i = 0; size_t nc = 0; size_t pc = 0; WINPR_ASSERT(pEntryPoints); @@ -167,7 +166,7 @@ static IWTSPlugin* dvcman_get_plugin(IDRDYNVC_ENTRY_POINTS* pEntryPoints, const ArrayList_Lock(dvcman->plugin_names); ArrayList_Lock(dvcman->plugins); - for (i = 0; i < pc; i++) + for (size_t i = 0; i < pc; i++) { const char* cur = ArrayList_GetItem(dvcman->plugin_names, i); if (strcmp(cur, name) == 0) @@ -579,13 +578,12 @@ static void dvcman_free(drdynvcPlugin* drdynvc, IWTSVirtualChannelManager* pChan */ static UINT dvcman_init(drdynvcPlugin* drdynvc, IWTSVirtualChannelManager* pChannelMgr) { - size_t i = 0; DVCMAN* dvcman = (DVCMAN*)pChannelMgr; UINT error = CHANNEL_RC_OK; WINPR_ASSERT(dvcman); ArrayList_Lock(dvcman->plugins); - for (i = 0; i < ArrayList_Count(dvcman->plugins); i++) + for (size_t i = 0; i < ArrayList_Count(dvcman->plugins); i++) { IWTSPlugin* pPlugin = ArrayList_GetItem(dvcman->plugins, i); @@ -1672,7 +1670,6 @@ static UINT drdynvc_virtual_channel_event_connected(drdynvcPlugin* drdynvc, LPVO { UINT error = 0; UINT32 status = 0; - UINT32 index = 0; rdpSettings* settings = NULL; WINPR_ASSERT(drdynvc); @@ -1698,8 +1695,8 @@ static UINT drdynvc_virtual_channel_event_connected(drdynvcPlugin* drdynvc, LPVO settings = drdynvc->rdpcontext->settings; WINPR_ASSERT(settings); - for (index = 0; index < freerdp_settings_get_uint32(settings, FreeRDP_DynamicChannelCount); - index++) + for (UINT32 index = 0; + index < freerdp_settings_get_uint32(settings, FreeRDP_DynamicChannelCount); index++) { const ADDIN_ARGV* args = freerdp_settings_get_pointer_array(settings, FreeRDP_DynamicChannelArray, index); @@ -1834,7 +1831,6 @@ static UINT drdynvc_virtual_channel_event_terminated(drdynvcPlugin* drdynvc) static UINT drdynvc_virtual_channel_event_attached(drdynvcPlugin* drdynvc) { UINT error = CHANNEL_RC_OK; - size_t i = 0; DVCMAN* dvcman = NULL; if (!drdynvc) @@ -1846,7 +1842,7 @@ static UINT drdynvc_virtual_channel_event_attached(drdynvcPlugin* drdynvc) return CHANNEL_RC_BAD_CHANNEL_HANDLE; ArrayList_Lock(dvcman->plugins); - for (i = 0; i < ArrayList_Count(dvcman->plugins); i++) + for (size_t i = 0; i < ArrayList_Count(dvcman->plugins); i++) { IWTSPlugin* pPlugin = ArrayList_GetItem(dvcman->plugins, i); @@ -1866,7 +1862,6 @@ fail: static UINT drdynvc_virtual_channel_event_detached(drdynvcPlugin* drdynvc) { UINT error = CHANNEL_RC_OK; - size_t i = 0; DVCMAN* dvcman = NULL; if (!drdynvc) @@ -1878,7 +1873,7 @@ static UINT drdynvc_virtual_channel_event_detached(drdynvcPlugin* drdynvc) return CHANNEL_RC_BAD_CHANNEL_HANDLE; ArrayList_Lock(dvcman->plugins); - for (i = 0; i < ArrayList_Count(dvcman->plugins); i++) + for (size_t i = 0; i < ArrayList_Count(dvcman->plugins); i++) { IWTSPlugin* pPlugin = ArrayList_GetItem(dvcman->plugins, i); diff --git a/channels/drive/client/drive_file.c b/channels/drive/client/drive_file.c index 4aafa039f..31150ea14 100644 --- a/channels/drive/client/drive_file.c +++ b/channels/drive/client/drive_file.c @@ -61,14 +61,12 @@ static BOOL drive_file_fix_path(WCHAR* path, size_t length) { - size_t i = 0; - if ((length == 0) || (length > UINT32_MAX)) return FALSE; WINPR_ASSERT(path); - for (i = 0; i < length; i++) + for (size_t i = 0; i < length; i++) { if (path[i] == L'\\') path[i] = L'/'; diff --git a/channels/drive/client/drive_main.c b/channels/drive/client/drive_main.c index 7c4695983..0fdc2e08f 100644 --- a/channels/drive/client/drive_main.c +++ b/channels/drive/client/drive_main.c @@ -886,7 +886,6 @@ static void drive_message_free(void* obj) static UINT drive_register_drive_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, const char* name, const char* path, BOOL automount) { - size_t i = 0; size_t length = 0; DRIVE_DEVICE* drive = NULL; UINT error = ERROR_INTERNAL_ERROR; @@ -924,7 +923,7 @@ static UINT drive_register_drive_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, goto out_error; } - for (i = 0; i < length; i++) + for (size_t i = 0; i < length; i++) { /* Filter 2.2.1.3 Device Announce Header (DEVICE_ANNOUNCE) forbidden symbols */ switch (name[i]) @@ -1015,7 +1014,6 @@ FREERDP_ENTRY_POINT(UINT drive_DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS p RDPDR_DRIVE* drive = NULL; UINT error = 0; #ifdef WIN32 - char* dev; int len; char devlist[512], buf[512]; char* bufdup; @@ -1075,12 +1073,14 @@ FREERDP_ENTRY_POINT(UINT drive_DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS p } else if (strcmp(drive->Path, "*") == 0) { - int i; /* Enumerate all devices: */ GetLogicalDriveStringsA(sizeof(devlist) - 1, devlist); - for (dev = devlist, i = 0; *dev; dev += 4, i++) + for (size_t i = 0;; i++) { + char* dev = &devlist[i * 4]; + if (!*dev) + break; if (*dev > 'B') { /* Suppress disk drives A and B to avoid pesty messages */ diff --git a/channels/geometry/client/geometry_main.c b/channels/geometry/client/geometry_main.c index 04e3254c2..5465fc9fe 100644 --- a/channels/geometry/client/geometry_main.c +++ b/channels/geometry/client/geometry_main.c @@ -122,7 +122,6 @@ static UINT32 geometry_read_RGNDATA(wLog* logger, wStream* s, UINT32 len, FREERD if (rgndata->nRectCount) { - UINT32 i = 0; RDP_RECT* tmp = realloc(rgndata->rects, rgndata->nRectCount * sizeof(RDP_RECT)); if (!tmp) @@ -133,7 +132,7 @@ static UINT32 geometry_read_RGNDATA(wLog* logger, wStream* s, UINT32 len, FREERD } rgndata->rects = tmp; - for (i = 0; i < rgndata->nRectCount; i++) + for (UINT32 i = 0; i < rgndata->nRectCount; i++) { Stream_Read_INT32(s, x); Stream_Read_INT32(s, y); diff --git a/channels/parallel/client/parallel_main.c b/channels/parallel/client/parallel_main.c index 39057541f..f0801e1f4 100644 --- a/channels/parallel/client/parallel_main.c +++ b/channels/parallel/client/parallel_main.c @@ -418,7 +418,6 @@ FREERDP_ENTRY_POINT(UINT parallel_DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINT { char* name = NULL; char* path = NULL; - size_t i = 0; size_t length = 0; RDPDR_PARALLEL* device = NULL; PARALLEL_DEVICE* parallel = NULL; @@ -463,7 +462,7 @@ FREERDP_ENTRY_POINT(UINT parallel_DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINT goto error_out; } - for (i = 0; i <= length; i++) + for (size_t i = 0; i <= length; i++) Stream_Write_UINT8(parallel->device.data, name[i] < 0 ? '_' : name[i]); parallel->path = path; diff --git a/channels/printer/client/cups/printer_cups.c b/channels/printer/client/cups/printer_cups.c index f1d77589a..043b44e70 100644 --- a/channels/printer/client/cups/printer_cups.c +++ b/channels/printer/client/cups/printer_cups.c @@ -356,8 +356,6 @@ static rdpPrinter** printer_cups_enum_printers(rdpPrinterDriver* driver) rdpPrinter** printers = NULL; int num_printers = 0; cups_dest_t* dests = NULL; - cups_dest_t* dest = NULL; - int i = 0; BOOL haveDefault = FALSE; const int num_dests = cupsGetDests(&dests); @@ -367,8 +365,9 @@ static rdpPrinter** printer_cups_enum_printers(rdpPrinterDriver* driver) if (!printers) return NULL; - for (i = 0, dest = dests; i < num_dests; i++, dest++) + for (size_t i = 0; i < num_dests; i++) { + const cups_dest_t* dest = &dests[i]; if (dest->instance == NULL) { rdpPrinter* current = printer_cups_new_printer((rdpCupsPrinterDriver*)driver, diff --git a/channels/printer/client/printer_main.c b/channels/printer/client/printer_main.c index 46836cf0a..2aeb3f482 100644 --- a/channels/printer/client/printer_main.c +++ b/channels/printer/client/printer_main.c @@ -301,7 +301,6 @@ static BOOL printer_load_from_config(const rdpSettings* settings, rdpPrinter* pr void* CachedPrinterConfigData = NULL; UINT32 CachedFieldsLen = 0; UINT32 PrinterNameLen = 0; - WCHAR* wptr = NULL; if (!settings || !printer || !printer->name) return FALSE; @@ -372,7 +371,7 @@ static BOOL printer_load_from_config(const rdpSettings* settings, rdpPrinter* pr backslash.c[0] = '\\'; backslash.c[1] = '\0'; - for (wptr = wname; (wptr = _wcschr(wptr, backslash.w));) + for (WCHAR* wptr = wname; (wptr = _wcschr(wptr, backslash.w));) *wptr = L'_'; Stream_Write(printer_dev->device.data, wname, PrinterNameLen); diff --git a/channels/printer/client/win/printer_win.c b/channels/printer/client/win/printer_win.c index 5618ff2b2..9bd758931 100644 --- a/channels/printer/client/win/printer_win.c +++ b/channels/printer/client/win/printer_win.c @@ -313,7 +313,6 @@ static rdpPrinter** printer_win_enum_printers(rdpPrinterDriver* driver) { rdpPrinter** printers; int num_printers; - int i; PRINTER_INFO_2* prninfo = NULL; DWORD needed, returned; BOOL haveDefault = FALSE; @@ -359,7 +358,7 @@ static rdpPrinter** printer_win_enum_printers(rdpPrinterDriver* driver) num_printers = 0; - for (i = 0; i < (int)returned; i++) + for (int i = 0; i < (int)returned; i++) { rdpPrinter* current = printers[num_printers]; current = printer_win_new_printer((rdpWinPrinterDriver*)driver, prninfo[i].pPrinterName, diff --git a/channels/rdp2tcp/client/rdp2tcp_main.c b/channels/rdp2tcp/client/rdp2tcp_main.c index ef32196de..0b2c8f17d 100644 --- a/channels/rdp2tcp/client/rdp2tcp_main.c +++ b/channels/rdp2tcp/client/rdp2tcp_main.c @@ -113,9 +113,8 @@ static void dumpData(char* data, unsigned length) { unsigned const limit = 98; unsigned l = length > limit ? limit / 2 : length; - unsigned i = 0; - for (i = 0; i < l; ++i) + for (unsigned i = 0; i < l; ++i) { printf("%02hhx", data[i]); } @@ -124,7 +123,7 @@ static void dumpData(char* data, unsigned length) { printf("..."); - for (i = length - l; i < length; ++i) + for (unsigned i = length - l; i < length; ++i) printf("%02hhx", data[i]); } diff --git a/channels/rdpdr/client/rdpdr_capabilities.c b/channels/rdpdr/client/rdpdr_capabilities.c index fd222fabc..e094cc71b 100644 --- a/channels/rdpdr/client/rdpdr_capabilities.c +++ b/channels/rdpdr/client/rdpdr_capabilities.c @@ -173,7 +173,6 @@ static UINT rdpdr_process_smartcard_capset(rdpdrPlugin* rdpdr, wStream* s, UINT rdpdr_process_capability_request(rdpdrPlugin* rdpdr, wStream* s) { UINT status = CHANNEL_RC_OK; - UINT16 i = 0; UINT16 numCapabilities = 0; if (!rdpdr || !s) @@ -188,7 +187,7 @@ UINT rdpdr_process_capability_request(rdpdrPlugin* rdpdr, wStream* s) Stream_Read_UINT16(s, numCapabilities); Stream_Seek(s, 2); /* pad (2 bytes) */ - for (i = 0; i < numCapabilities; i++) + for (UINT16 i = 0; i < numCapabilities; i++) { RDPDR_CAPABILITY_HEADER header = { 0 }; UINT error = rdpdr_read_capset_header(rdpdr->log, s, &header); diff --git a/channels/rdpdr/client/rdpdr_main.c b/channels/rdpdr/client/rdpdr_main.c index bed7a2328..53f501191 100644 --- a/channels/rdpdr/client/rdpdr_main.c +++ b/channels/rdpdr/client/rdpdr_main.c @@ -233,7 +233,6 @@ fail: */ static UINT rdpdr_send_device_list_remove_request(rdpdrPlugin* rdpdr, UINT32 count, UINT32 ids[]) { - UINT32 i = 0; wStream* s = NULL; WINPR_ASSERT(rdpdr); @@ -257,7 +256,7 @@ static UINT rdpdr_send_device_list_remove_request(rdpdrPlugin* rdpdr, UINT32 cou Stream_Write_UINT16(s, PAKID_CORE_DEVICELIST_REMOVE); Stream_Write_UINT32(s, count); - for (i = 0; i < count; i++) + for (UINT32 i = 0; i < count; i++) Stream_Write_UINT32(s, ids[i]); Stream_SealLength(s); @@ -295,10 +294,9 @@ static BOOL check_path(const char* path) static void first_hotplug(rdpdrPlugin* rdpdr) { - size_t i; DWORD unitmask = GetLogicalDrives(); - for (i = 0; i < 26; i++) + for (size_t i = 0; i < 26; i++) { if (unitmask & 0x01) { @@ -334,9 +332,8 @@ static LRESULT CALLBACK hotplug_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM { PDEV_BROADCAST_VOLUME lpdbv = (PDEV_BROADCAST_VOLUME)lpdb; DWORD unitmask = lpdbv->dbcv_unitmask; - int i; - for (i = 0; i < 26; i++) + for (int i = 0; i < 26; i++) { if (unitmask & 0x01) { @@ -363,13 +360,13 @@ static LRESULT CALLBACK hotplug_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM { PDEV_BROADCAST_VOLUME lpdbv = (PDEV_BROADCAST_VOLUME)lpdb; DWORD unitmask = lpdbv->dbcv_unitmask; - int i, j, count; + int count; char drive_name_upper, drive_name_lower; ULONG_PTR* keys = NULL; DEVICE_DRIVE_EXT* device_ext; UINT32 ids[1]; - for (i = 0; i < 26; i++) + for (int i = 0; i < 26; i++) { if (unitmask & 0x01) { @@ -377,7 +374,7 @@ static LRESULT CALLBACK hotplug_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM drive_name_lower = 'a' + i; count = ListDictionary_GetKeys(rdpdr->devman->devices, &keys); - for (j = 0; j < count; j++) + for (int j = 0; j < count; j++) { device_ext = (DEVICE_DRIVE_EXT*)ListDictionary_GetItemValue( rdpdr->devman->devices, (void*)keys[j]); @@ -526,7 +523,6 @@ static UINT handle_hotplug(rdpdrPlugin* rdpdr) int count; DEVICE_DRIVE_EXT* device_ext; ULONG_PTR* keys = NULL; - int i, j; int size = 0; UINT error; UINT32 ids[1]; @@ -566,7 +562,7 @@ static UINT handle_hotplug(rdpdrPlugin* rdpdr) /* delete removed devices */ count = ListDictionary_GetKeys(rdpdr->devman->devices, &keys); - for (j = 0; j < count; j++) + for (size_t j = 0; j < count; j++) { char* path = NULL; BOOL dev_found = FALSE; @@ -593,7 +589,7 @@ static UINT handle_hotplug(rdpdrPlugin* rdpdr) continue; } - for (i = 0; i < size; i++) + for (size_t i = 0; i < size; i++) { if (strstr(path, dev_array[i].path) != NULL) { @@ -621,7 +617,7 @@ static UINT handle_hotplug(rdpdrPlugin* rdpdr) } /* add new devices */ - for (i = 0; i < size; i++) + for (size_t i = 0; i < size; i++) { const hotplug_dev* dev = &dev_array[i]; if (dev->to_add) @@ -637,7 +633,7 @@ static UINT handle_hotplug(rdpdrPlugin* rdpdr) cleanup: free(keys); - for (i = 0; i < size; i++) + for (size_t i = 0; i < size; i++) free(dev_array[i].path); return error; @@ -650,12 +646,11 @@ static void drive_hotplug_fsevent_callback(ConstFSEventStreamRef streamRef, const FSEventStreamEventId eventIds[]) { rdpdrPlugin* rdpdr; - size_t i; UINT error; char** paths = (char**)eventPaths; rdpdr = (rdpdrPlugin*)clientCallBackInfo; - for (i = 0; i < numEvents; i++) + for (size_t i = 0; i < numEvents; i++) { if (strcmp(paths[i], "/Volumes/") == 0) { @@ -726,7 +721,6 @@ static const char* automountLocations[] = { "/run/user/%lu/gvfs", "/run/media/%s static BOOL isAutomountLocation(const char* path) { const size_t nrLocations = sizeof(automountLocations) / sizeof(automountLocations[0]); - size_t x = 0; char buffer[MAX_PATH] = { 0 }; uid_t uid = getuid(); char uname[MAX_PATH] = { 0 }; @@ -738,7 +732,7 @@ static BOOL isAutomountLocation(const char* path) if (!path) return FALSE; - for (x = 0; x < nrLocations; x++) + for (size_t x = 0; x < nrLocations; x++) { const char* location = automountLocations[x]; size_t length = 0; @@ -820,7 +814,6 @@ static UINT handle_platform_mounts_sun(wLog* log, hotplug_dev* dev_array, size_t static UINT handle_platform_mounts_bsd(wLog* log, hotplug_dev* dev_array, size_t* size) { int mntsize; - size_t idx; struct statfs* mntbuf = NULL; mntsize = getmntinfo(&mntbuf, MNT_NOWAIT); @@ -830,7 +823,7 @@ static UINT handle_platform_mounts_bsd(wLog* log, hotplug_dev* dev_array, size_t WLog_Print(log, WLOG_ERROR, "getmntinfo failed!"); return ERROR_OPEN_FAILED; } - for (idx = 0; idx < (size_t)mntsize; idx++) + for (size_t idx = 0; idx < (size_t)mntsize; idx++) { handle_mountpoint(dev_array, size, mntbuf[idx].f_mntonname); } @@ -939,8 +932,7 @@ static BOOL hotplug_delete_foreach(ULONG_PTR key, void* element, void* data) /* not plugable device */ if (isAutomountLocation(path)) { - size_t i = 0; - for (i = 0; i < arg->dev_array_size; i++) + for (size_t i = 0; i < arg->dev_array_size; i++) { hotplug_dev* cur = &arg->dev_array[i]; if (cur->path && strstr(path, cur->path) != NULL) @@ -979,7 +971,6 @@ static BOOL hotplug_delete_foreach(ULONG_PTR key, void* element, void* data) static UINT handle_hotplug(rdpdrPlugin* rdpdr) { hotplug_dev dev_array[MAX_USB_DEVICES] = { 0 }; - size_t i = 0; size_t size = 0; UINT error = ERROR_SUCCESS; struct hotplug_delete_arg arg = { dev_array, ARRAYSIZE(dev_array), rdpdr }; @@ -993,7 +984,7 @@ static UINT handle_hotplug(rdpdrPlugin* rdpdr) /* Ignore result */ device_foreach(rdpdr, FALSE, hotplug_delete_foreach, &arg); /* add new devices */ - for (i = 0; i < size; i++) + for (size_t i = 0; i < size; i++) { hotplug_dev* cur = &dev_array[i]; if (!device_already_plugged(rdpdr, cur)) @@ -1006,7 +997,7 @@ static UINT handle_hotplug(rdpdrPlugin* rdpdr) } } - for (i = 0; i < size; i++) + for (size_t i = 0; i < size; i++) free(dev_array[i].path); return error; @@ -1374,7 +1365,6 @@ static BOOL device_announce(ULONG_PTR key, void* element, void* data) if ((rdpdr->clientVersionMinor == RDPDR_VERSION_MINOR_RDP51) || (device->type == RDPDR_DTYP_SMARTCARD) || arg->userLoggedOn) { - size_t i = 0; size_t data_len = (device->data == NULL ? 0 : Stream_GetPosition(device->data)); if (!Stream_EnsureRemainingCapacity(arg->s, 20 + data_len)) @@ -1388,7 +1378,7 @@ static BOOL device_announce(ULONG_PTR key, void* element, void* data) Stream_Write_UINT32(arg->s, device->id); /* deviceID */ strncpy(Stream_Pointer(arg->s), device->name, 8); - for (i = 0; i < 8; i++) + for (size_t i = 0; i < 8; i++) { BYTE c = 0; Stream_Peek_UINT8(arg->s, c); diff --git a/channels/rdpdr/server/rdpdr_main.c b/channels/rdpdr/server/rdpdr_main.c index 63bf184e8..bad6e2332 100644 --- a/channels/rdpdr/server/rdpdr_main.c +++ b/channels/rdpdr/server/rdpdr_main.c @@ -797,7 +797,6 @@ out: static UINT rdpdr_server_receive_core_capability_response(RdpdrServerContext* context, wStream* s, const RDPDR_HEADER* header) { - UINT16 i = 0; UINT status = 0; UINT16 numCapabilities = 0; @@ -813,7 +812,7 @@ static UINT rdpdr_server_receive_core_capability_response(RdpdrServerContext* co Stream_Seek_UINT16(s); /* Padding (2 bytes) */ UINT16 caps = 0; - for (i = 0; i < numCapabilities; i++) + for (UINT16 i = 0; i < numCapabilities; i++) { RDPDR_CAPABILITY_HEADER capabilityHeader = { 0 }; const size_t start = Stream_GetPosition(s); @@ -964,7 +963,6 @@ static UINT rdpdr_server_receive_device_list_announce_request(RdpdrServerContext wStream* s, const RDPDR_HEADER* header) { - UINT32 i = 0; UINT32 DeviceCount = 0; WINPR_ASSERT(context); @@ -978,7 +976,7 @@ static UINT rdpdr_server_receive_device_list_announce_request(RdpdrServerContext Stream_Read_UINT32(s, DeviceCount); /* DeviceCount (4 bytes) */ WLog_Print(context->priv->log, WLOG_DEBUG, "DeviceCount: %" PRIu32 "", DeviceCount); - for (i = 0; i < DeviceCount; i++) + for (UINT32 i = 0; i < DeviceCount; i++) { UINT error = 0; RdpdrDevice device = { 0 }; @@ -1080,7 +1078,6 @@ static UINT rdpdr_server_receive_device_list_announce_request(RdpdrServerContext static UINT rdpdr_server_receive_device_list_remove_request(RdpdrServerContext* context, wStream* s, const RDPDR_HEADER* header) { - UINT32 i = 0; UINT32 DeviceCount = 0; UINT32 DeviceType = 0; UINT32 DeviceId = 0; @@ -1095,7 +1092,7 @@ static UINT rdpdr_server_receive_device_list_remove_request(RdpdrServerContext* Stream_Read_UINT32(s, DeviceCount); /* DeviceCount (4 bytes) */ WLog_Print(context->priv->log, WLOG_DEBUG, "DeviceCount: %" PRIu32 "", DeviceCount); - for (i = 0; i < DeviceCount; i++) + for (UINT32 i = 0; i < DeviceCount; i++) { UINT error = 0; const RdpdrDevice* device = NULL; @@ -2479,10 +2476,9 @@ static UINT rdpdr_server_send_device_file_rename_request(RdpdrServerContext* con static void rdpdr_server_convert_slashes(char* path, int size) { - int i = 0; WINPR_ASSERT(path || (size <= 0)); - for (i = 0; (i < size) && (path[i] != '\0'); i++) + for (int i = 0; (i < size) && (path[i] != '\0'); i++) { if (path[i] == '/') path[i] = '\\'; diff --git a/channels/rdpecam/server/camera_device_enumerator_main.c b/channels/rdpecam/server/camera_device_enumerator_main.c index 691a6640a..27523b0f1 100644 --- a/channels/rdpecam/server/camera_device_enumerator_main.c +++ b/channels/rdpecam/server/camera_device_enumerator_main.c @@ -171,7 +171,7 @@ static UINT enumerator_server_recv_device_added_notification(CamDevEnumServerCon /* Search for null terminator of DeviceName */ size_t i = 0; - for (i = 0; i < remaining_length; i += sizeof(WCHAR), ++channel_name_start) + for (; i < remaining_length; i += sizeof(WCHAR), ++channel_name_start) { if (*channel_name_start == L'\0') break; diff --git a/channels/rdpecam/server/camera_device_main.c b/channels/rdpecam/server/camera_device_main.c index 7819d5e42..ce0774c51 100644 --- a/channels/rdpecam/server/camera_device_main.c +++ b/channels/rdpecam/server/camera_device_main.c @@ -167,7 +167,6 @@ static UINT device_server_recv_stream_list_response(CameraDeviceServerContext* c { CAM_STREAM_LIST_RESPONSE pdu = { 0 }; UINT error = CHANNEL_RC_OK; - BYTE i = 0; WINPR_ASSERT(context); WINPR_ASSERT(header); @@ -179,7 +178,7 @@ static UINT device_server_recv_stream_list_response(CameraDeviceServerContext* c pdu.N_Descriptions = MIN(Stream_GetRemainingLength(s) / 5, 255); - for (i = 0; i < pdu.N_Descriptions; ++i) + for (BYTE i = 0; i < pdu.N_Descriptions; ++i) { CAM_STREAM_DESCRIPTION* StreamDescription = &pdu.StreamDescriptions[i]; @@ -341,8 +340,6 @@ static UINT device_server_recv_property_list_response(CameraDeviceServerContext* if (pdu.N_Properties > 0) { - size_t i = 0; - pdu.Properties = calloc(pdu.N_Properties, sizeof(CAM_PROPERTY_DESCRIPTION)); if (!pdu.Properties) { @@ -351,7 +348,7 @@ static UINT device_server_recv_property_list_response(CameraDeviceServerContext* return ERROR_NOT_ENOUGH_MEMORY; } - for (i = 0; i < pdu.N_Properties; ++i) + for (size_t i = 0; i < pdu.N_Properties; ++i) { Stream_Read_UINT8(s, pdu.Properties[i].PropertySet); Stream_Read_UINT8(s, pdu.Properties[i].PropertyId); @@ -806,7 +803,6 @@ device_send_start_streams_request_pdu(CameraDeviceServerContext* context, const CAM_START_STREAMS_REQUEST* startStreamsRequest) { wStream* s = NULL; - size_t i = 0; WINPR_ASSERT(context); WINPR_ASSERT(startStreamsRequest); @@ -816,7 +812,7 @@ device_send_start_streams_request_pdu(CameraDeviceServerContext* context, if (!s) return ERROR_NOT_ENOUGH_MEMORY; - for (i = 0; i < startStreamsRequest->N_Infos; ++i) + for (size_t i = 0; i < startStreamsRequest->N_Infos; ++i) { const CAM_START_STREAM_INFO* info = &startStreamsRequest->StartStreamsInfo[i]; const CAM_MEDIA_TYPE_DESCRIPTION* description = &info->MediaTypeDescription; diff --git a/channels/rdpei/client/rdpei_main.c b/channels/rdpei/client/rdpei_main.c index 2b4942eb0..fbb255da5 100644 --- a/channels/rdpei/client/rdpei_main.c +++ b/channels/rdpei/client/rdpei_main.c @@ -123,9 +123,7 @@ static const char* rdpei_eventid_string(UINT16 event) static RDPINPUT_CONTACT_POINT* rdpei_contact(RDPEI_PLUGIN* rdpei, INT32 externalId, BOOL active) { - UINT16 i = 0; - - for (i = 0; i < rdpei->maxTouchContacts; i++) + for (UINT16 i = 0; i < rdpei->maxTouchContacts; i++) { RDPINPUT_CONTACT_POINT* contactPoint = &rdpei->contactPoints[i]; @@ -153,7 +151,6 @@ static RDPINPUT_CONTACT_POINT* rdpei_contact(RDPEI_PLUGIN* rdpei, INT32 external */ static UINT rdpei_add_frame(RdpeiClientContext* context) { - UINT16 i = 0; RDPEI_PLUGIN* rdpei = NULL; RDPINPUT_TOUCH_FRAME frame = { 0 }; RDPINPUT_CONTACT_DATA contacts[MAX_CONTACTS] = { 0 }; @@ -164,7 +161,7 @@ static UINT rdpei_add_frame(RdpeiClientContext* context) rdpei = (RDPEI_PLUGIN*)context->handle; frame.contacts = contacts; - for (i = 0; i < rdpei->maxTouchContacts; i++) + for (UINT16 i = 0; i < rdpei->maxTouchContacts; i++) { RDPINPUT_CONTACT_POINT* contactPoint = &rdpei->contactPoints[i]; RDPINPUT_CONTACT_DATA* contact = &contactPoint->data; @@ -236,7 +233,6 @@ static UINT rdpei_send_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s, UINT1 static UINT rdpei_write_pen_frame(wStream* s, const RDPINPUT_PEN_FRAME* frame) { - UINT16 x = 0; if (!s || !frame) return ERROR_INTERNAL_ERROR; @@ -244,7 +240,7 @@ static UINT rdpei_write_pen_frame(wStream* s, const RDPINPUT_PEN_FRAME* frame) return ERROR_OUTOFMEMORY; if (!rdpei_write_8byte_unsigned(s, frame->frameOffset)) return ERROR_OUTOFMEMORY; - for (x = 0; x < frame->contactCount; x++) + for (UINT16 x = 0; x < frame->contactCount; x++) { const RDPINPUT_PEN_CONTACT* contact = &frame->contacts[x]; @@ -293,7 +289,6 @@ static UINT rdpei_send_pen_event_pdu(GENERIC_CHANNEL_CALLBACK* callback, UINT32 { UINT status = 0; wStream* s = NULL; - UINT16 x = 0; if (!frames || (count == 0)) return ERROR_INTERNAL_ERROR; @@ -314,7 +309,7 @@ static UINT rdpei_send_pen_event_pdu(GENERIC_CHANNEL_CALLBACK* callback, UINT32 rdpei_write_4byte_unsigned(s, frameOffset); /* encodeTime (FOUR_BYTE_UNSIGNED_INTEGER) */ rdpei_write_2byte_unsigned(s, count); /* (frameCount) TWO_BYTE_UNSIGNED_INTEGER */ - for (x = 0; x < count; x++) + for (UINT16 x = 0; x < count; x++) { if ((status = rdpei_write_pen_frame(s, &frames[x]))) { @@ -372,7 +367,6 @@ static UINT rdpei_send_pen_frame(RdpeiClientContext* context, RDPINPUT_PEN_FRAME static UINT rdpei_add_pen_frame(RdpeiClientContext* context) { - UINT16 i = 0; RDPEI_PLUGIN* rdpei = NULL; RDPINPUT_PEN_FRAME penFrame = { 0 }; RDPINPUT_PEN_CONTACT penContacts[MAX_PEN_CONTACTS] = { 0 }; @@ -384,7 +378,7 @@ static UINT rdpei_add_pen_frame(RdpeiClientContext* context) penFrame.contacts = penContacts; - for (i = 0; i < rdpei->maxPenContacts; i++) + for (UINT16 i = 0; i < rdpei->maxPenContacts; i++) { RDPINPUT_PEN_CONTACT_POINT* contact = &(rdpei->penContactPoints[i]); @@ -557,7 +551,6 @@ static void rdpei_print_contact_flags(UINT32 contactFlags) */ static UINT rdpei_write_touch_frame(wStream* s, RDPINPUT_TOUCH_FRAME* frame) { - UINT32 index = 0; int rectSize = 2; RDPINPUT_CONTACT_DATA* contact = NULL; if (!s || !frame) @@ -581,7 +574,7 @@ static UINT rdpei_write_touch_frame(wStream* s, RDPINPUT_TOUCH_FRAME* frame) return CHANNEL_RC_NO_MEMORY; } - for (index = 0; index < frame->contactCount; index++) + for (UINT32 index = 0; index < frame->contactCount; index++) { contact = &frame->contacts[index]; contact->fieldsPresent |= CONTACT_DATA_CONTACTRECT_PRESENT; @@ -1131,11 +1124,10 @@ static UINT rdpei_touch_raw_event_va(RdpeiClientContext* context, INT32 external static RDPINPUT_PEN_CONTACT_POINT* rdpei_pen_contact(RDPEI_PLUGIN* rdpei, INT32 externalId, BOOL active) { - UINT32 x = 0; if (!rdpei) return NULL; - for (x = 0; x < rdpei->maxPenContacts; x++) + for (UINT32 x = 0; x < rdpei->maxPenContacts; x++) { RDPINPUT_PEN_CONTACT_POINT* contact = &rdpei->penContactPoints[x]; if (active) diff --git a/channels/rdpei/rdpei_common.c b/channels/rdpei/rdpei_common.c index b1150fb52..75946723f 100644 --- a/channels/rdpei/rdpei_common.c +++ b/channels/rdpei/rdpei_common.c @@ -608,9 +608,7 @@ BOOL rdpei_write_8byte_unsigned(wStream* s, UINT64 value) void touch_event_reset(RDPINPUT_TOUCH_EVENT* event) { - UINT16 i = 0; - - for (i = 0; i < event->frameCount; i++) + for (UINT16 i = 0; i < event->frameCount; i++) touch_frame_reset(&event->frames[i]); free(event->frames); @@ -627,9 +625,7 @@ void touch_frame_reset(RDPINPUT_TOUCH_FRAME* frame) void pen_event_reset(RDPINPUT_PEN_EVENT* event) { - UINT16 i = 0; - - for (i = 0; i < event->frameCount; i++) + for (UINT16 i = 0; i < event->frameCount; i++) pen_frame_reset(&event->frames[i]); free(event->frames); diff --git a/channels/rdpei/server/rdpei_main.c b/channels/rdpei/server/rdpei_main.c index 601c21ced..c87a045db 100644 --- a/channels/rdpei/server/rdpei_main.c +++ b/channels/rdpei/server/rdpei_main.c @@ -311,7 +311,6 @@ static UINT read_pen_contact(RdpeiServerContext* context, wStream* s, */ static UINT read_touch_frame(RdpeiServerContext* context, wStream* s, RDPINPUT_TOUCH_FRAME* frame) { - UINT32 i = 0; RDPINPUT_CONTACT_DATA* contact = NULL; UINT error = 0; @@ -329,7 +328,7 @@ static UINT read_touch_frame(RdpeiServerContext* context, wStream* s, RDPINPUT_T return CHANNEL_RC_NO_MEMORY; } - for (i = 0; i < frame->contactCount; i++, contact++) + for (UINT32 i = 0; i < frame->contactCount; i++, contact++) { if ((error = read_touch_contact_data(context, s, contact))) { @@ -344,7 +343,6 @@ static UINT read_touch_frame(RdpeiServerContext* context, wStream* s, RDPINPUT_T static UINT read_pen_frame(RdpeiServerContext* context, wStream* s, RDPINPUT_PEN_FRAME* frame) { - UINT32 i = 0; RDPINPUT_PEN_CONTACT* contact = NULL; UINT error = 0; @@ -362,7 +360,7 @@ static UINT read_pen_frame(RdpeiServerContext* context, wStream* s, RDPINPUT_PEN return CHANNEL_RC_NO_MEMORY; } - for (i = 0; i < frame->contactCount; i++, contact++) + for (UINT32 i = 0; i < frame->contactCount; i++, contact++) { if ((error = read_pen_contact(context, s, contact))) { @@ -383,7 +381,6 @@ static UINT read_pen_frame(RdpeiServerContext* context, wStream* s, RDPINPUT_PEN static UINT read_touch_event(RdpeiServerContext* context, wStream* s) { UINT16 frameCount = 0; - UINT32 i = 0; RDPINPUT_TOUCH_EVENT* event = &context->priv->touchEvent; RDPINPUT_TOUCH_FRAME* frame = NULL; UINT error = CHANNEL_RC_OK; @@ -403,7 +400,7 @@ static UINT read_touch_event(RdpeiServerContext* context, wStream* s) return CHANNEL_RC_NO_MEMORY; } - for (i = 0; i < frameCount; i++, frame++) + for (UINT32 i = 0; i < frameCount; i++, frame++) { if ((error = read_touch_frame(context, s, frame))) { @@ -425,7 +422,6 @@ out_cleanup: static UINT read_pen_event(RdpeiServerContext* context, wStream* s) { UINT16 frameCount = 0; - UINT32 i = 0; RDPINPUT_PEN_EVENT* event = &context->priv->penEvent; RDPINPUT_PEN_FRAME* frame = NULL; UINT error = CHANNEL_RC_OK; @@ -445,7 +441,7 @@ static UINT read_pen_event(RdpeiServerContext* context, wStream* s) return CHANNEL_RC_NO_MEMORY; } - for (i = 0; i < frameCount; i++, frame++) + for (UINT32 i = 0; i < frameCount; i++, frame++) { if ((error = read_pen_frame(context, s, frame))) { diff --git a/channels/rdpgfx/client/rdpgfx_codec.c b/channels/rdpgfx/client/rdpgfx_codec.c index c9e6f39ab..488e357a5 100644 --- a/channels/rdpgfx/client/rdpgfx_codec.c +++ b/channels/rdpgfx/client/rdpgfx_codec.c @@ -39,7 +39,6 @@ */ static UINT rdpgfx_read_h264_metablock(RDPGFX_PLUGIN* gfx, wStream* s, RDPGFX_H264_METABLOCK* meta) { - UINT32 index = 0; RECTANGLE_16* regionRect = NULL; RDPGFX_H264_QUANT_QUALITY* quantQualityVal = NULL; UINT error = ERROR_INVALID_DATA; @@ -75,7 +74,7 @@ static UINT rdpgfx_read_h264_metablock(RDPGFX_PLUGIN* gfx, wStream* s, RDPGFX_H2 WLog_DBG(TAG, "H264_METABLOCK: numRegionRects: %" PRIu32 "", meta->numRegionRects); - for (index = 0; index < meta->numRegionRects; index++) + for (UINT32 index = 0; index < meta->numRegionRects; index++) { regionRect = &(meta->regionRects[index]); @@ -97,7 +96,7 @@ static UINT rdpgfx_read_h264_metablock(RDPGFX_PLUGIN* gfx, wStream* s, RDPGFX_H2 goto error_out; } - for (index = 0; index < meta->numRegionRects; index++) + for (UINT32 index = 0; index < meta->numRegionRects; index++) { quantQualityVal = &(meta->quantQualityVals[index]); Stream_Read_UINT8(s, quantQualityVal->qpVal); /* qpVal (1 byte) */ diff --git a/channels/rdpgfx/client/rdpgfx_main.c b/channels/rdpgfx/client/rdpgfx_main.c index f29430c71..dd59c8b23 100644 --- a/channels/rdpgfx/client/rdpgfx_main.c +++ b/channels/rdpgfx/client/rdpgfx_main.c @@ -74,10 +74,8 @@ static void free_surfaces(RdpgfxClientContext* context, wHashTable* SurfaceTable static void evict_cache_slots(RdpgfxClientContext* context, UINT16 MaxCacheSlots, void** CacheSlots) { - UINT16 index = 0; - WINPR_ASSERT(CacheSlots); - for (index = 0; index < MaxCacheSlots; index++) + for (UINT16 index = 0; index < MaxCacheSlots; index++) { if (CacheSlots[index]) { @@ -103,7 +101,6 @@ static UINT rdpgfx_send_caps_advertise_pdu(RdpgfxClientContext* context, const RDPGFX_CAPS_ADVERTISE_PDU* pdu) { UINT error = CHANNEL_RC_OK; - UINT16 index = 0; RDPGFX_HEADER header = { 0 }; RDPGFX_PLUGIN* gfx = NULL; GENERIC_CHANNEL_CALLBACK* callback = NULL; @@ -123,7 +120,7 @@ static UINT rdpgfx_send_caps_advertise_pdu(RdpgfxClientContext* context, header.cmdId = RDPGFX_CMDID_CAPSADVERTISE; header.pduLength = RDPGFX_HEADER_SIZE + 2; - for (index = 0; index < pdu->capsSetCount; index++) + for (UINT16 index = 0; index < pdu->capsSetCount; index++) { const RDPGFX_CAPSET* capsSet = &(pdu->capsSets[index]); header.pduLength += RDPGFX_CAPSET_BASE_SIZE + capsSet->length; @@ -144,7 +141,7 @@ static UINT rdpgfx_send_caps_advertise_pdu(RdpgfxClientContext* context, /* RDPGFX_CAPS_ADVERTISE_PDU */ Stream_Write_UINT16(s, pdu->capsSetCount); /* capsSetCount (2 bytes) */ - for (index = 0; index < pdu->capsSetCount; index++) + for (UINT16 index = 0; index < pdu->capsSetCount; index++) { const RDPGFX_CAPSET* capsSet = &(pdu->capsSets[index]); Stream_Write_UINT32(s, capsSet->version); /* version (4 bytes) */ @@ -172,9 +169,8 @@ static BOOL rdpgfx_is_capability_filtered(RDPGFX_PLUGIN* gfx, UINT32 caps) RDPGFX_CAPVERSION_104, RDPGFX_CAPVERSION_105, RDPGFX_CAPVERSION_106, RDPGFX_CAPVERSION_106_ERR, RDPGFX_CAPVERSION_107 }; - UINT32 x = 0; - for (x = 0; x < ARRAYSIZE(capList); x++) + for (size_t x = 0; x < ARRAYSIZE(capList); x++) { if (caps == capList[x]) return (filter & (1 << x)) != 0; @@ -507,7 +503,6 @@ fail: static UINT rdpgfx_recv_reset_graphics_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { int pad = 0; - UINT32 index = 0; MONITOR_DEF* monitor = NULL; RDPGFX_RESET_GRAPHICS_PDU pdu = { 0 }; WINPR_ASSERT(callback); @@ -538,7 +533,7 @@ static UINT rdpgfx_recv_reset_graphics_pdu(GENERIC_CHANNEL_CALLBACK* callback, w return CHANNEL_RC_NO_MEMORY; } - for (index = 0; index < pdu.monitorCount; index++) + for (UINT32 index = 0; index < pdu.monitorCount; index++) { monitor = &(pdu.monitorDefArray[index]); Stream_Read_INT32(s, monitor->left); /* left (4 bytes) */ @@ -562,7 +557,7 @@ static UINT rdpgfx_recv_reset_graphics_pdu(GENERIC_CHANNEL_CALLBACK* callback, w pdu.width, pdu.height, pdu.monitorCount); #if defined(WITH_DEBUG_RDPGFX) - for (index = 0; index < pdu.monitorCount; index++) + for (UINT32 index = 0; index < pdu.monitorCount; index++) { monitor = &(pdu.monitorDefArray[index]); DEBUG_RDPGFX(gfx->log, @@ -630,7 +625,6 @@ static UINT rdpgfx_recv_evict_cache_entry_pdu(GENERIC_CHANNEL_CALLBACK* callback */ static UINT rdpgfx_load_cache_import_offer(RDPGFX_PLUGIN* gfx, RDPGFX_CACHE_IMPORT_OFFER_PDU* offer) { - int idx = 0; int count = 0; UINT error = CHANNEL_RC_OK; PERSISTENT_CACHE_ENTRY entry; @@ -685,7 +679,7 @@ static UINT rdpgfx_load_cache_import_offer(RDPGFX_PLUGIN* gfx, RDPGFX_CACHE_IMPO offer->cacheEntriesCount = (UINT16)count; - for (idx = 0; idx < count; idx++) + for (int idx = 0; idx < count; idx++) { if (persistent_cache_read_entry(persistent, &entry) < 1) { @@ -712,7 +706,6 @@ fail: */ static UINT rdpgfx_save_persistent_cache(RDPGFX_PLUGIN* gfx) { - int idx = 0; UINT error = CHANNEL_RC_OK; PERSISTENT_CACHE_ENTRY cacheEntry; rdpPersistentCache* persistent = NULL; @@ -746,7 +739,7 @@ static UINT rdpgfx_save_persistent_cache(RDPGFX_PLUGIN* gfx) goto fail; } - for (idx = 0; idx < gfx->MaxCacheSlots; idx++) + for (UINT16 idx = 0; idx < gfx->MaxCacheSlots; idx++) { if (gfx->CacheSlots[idx]) { @@ -775,7 +768,6 @@ fail: static UINT rdpgfx_send_cache_import_offer_pdu(RdpgfxClientContext* context, const RDPGFX_CACHE_IMPORT_OFFER_PDU* pdu) { - UINT16 index = 0; UINT error = CHANNEL_RC_OK; wStream* s = NULL; RDPGFX_HEADER header; @@ -822,7 +814,7 @@ static UINT rdpgfx_send_cache_import_offer_pdu(RdpgfxClientContext* context, /* cacheEntriesCount (2 bytes) */ Stream_Write_UINT16(s, pdu->cacheEntriesCount); - for (index = 0; index < pdu->cacheEntriesCount; index++) + for (UINT16 index = 0; index < pdu->cacheEntriesCount; index++) { const RDPGFX_CACHE_ENTRY_METADATA* cacheEntry = &(pdu->cacheEntries[index]); Stream_Write_UINT64(s, cacheEntry->cacheKey); /* cacheKey (8 bytes) */ @@ -844,7 +836,6 @@ fail: */ static UINT rdpgfx_send_cache_offer(RDPGFX_PLUGIN* gfx) { - int idx = 0; int count = 0; UINT error = CHANNEL_RC_OK; PERSISTENT_CACHE_ENTRY entry; @@ -901,7 +892,7 @@ static UINT rdpgfx_send_cache_offer(RDPGFX_PLUGIN* gfx) WLog_DBG(TAG, "Sending Cache Import Offer: %d", count); - for (idx = 0; idx < count; idx++) + for (int idx = 0; idx < count; idx++) { if (persistent_cache_read_entry(persistent, &entry) < 1) { @@ -1007,7 +998,6 @@ fail: */ static UINT rdpgfx_recv_cache_import_reply_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { - UINT16 idx = 0; RDPGFX_CACHE_IMPORT_REPLY_PDU pdu = { 0 }; WINPR_ASSERT(callback); RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*)callback->plugin; @@ -1026,7 +1016,7 @@ static UINT rdpgfx_recv_cache_import_reply_pdu(GENERIC_CHANNEL_CALLBACK* callbac if (pdu.importedEntriesCount > RDPGFX_CACHE_ENTRY_MAX_COUNT) return ERROR_INVALID_DATA; - for (idx = 0; idx < pdu.importedEntriesCount; idx++) + for (UINT16 idx = 0; idx < pdu.importedEntriesCount; idx++) { Stream_Read_UINT16(s, pdu.cacheSlots[idx]); /* cacheSlot (2 bytes) */ } @@ -1473,7 +1463,6 @@ static UINT rdpgfx_recv_delete_encoding_context_pdu(GENERIC_CHANNEL_CALLBACK* ca */ static UINT rdpgfx_recv_solid_fill_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { - UINT16 index = 0; RECTANGLE_16* fillRect = NULL; RDPGFX_SOLID_FILL_PDU pdu = { 0 }; WINPR_ASSERT(callback); @@ -1507,7 +1496,7 @@ static UINT rdpgfx_recv_solid_fill_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStre return CHANNEL_RC_NO_MEMORY; } - for (index = 0; index < pdu.fillRectCount; index++) + for (UINT16 index = 0; index < pdu.fillRectCount; index++) { fillRect = &(pdu.fillRects[index]); @@ -1542,7 +1531,6 @@ static UINT rdpgfx_recv_solid_fill_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStre */ static UINT rdpgfx_recv_surface_to_surface_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { - UINT16 index = 0; RDPGFX_POINT16* destPt = NULL; RDPGFX_SURFACE_TO_SURFACE_PDU pdu = { 0 }; WINPR_ASSERT(callback); @@ -1577,7 +1565,7 @@ static UINT rdpgfx_recv_surface_to_surface_pdu(GENERIC_CHANNEL_CALLBACK* callbac return CHANNEL_RC_NO_MEMORY; } - for (index = 0; index < pdu.destPtsCount; index++) + for (UINT16 index = 0; index < pdu.destPtsCount; index++) { destPt = &(pdu.destPts[index]); @@ -1665,7 +1653,6 @@ static UINT rdpgfx_recv_surface_to_cache_pdu(GENERIC_CHANNEL_CALLBACK* callback, */ static UINT rdpgfx_recv_cache_to_surface_pdu(GENERIC_CHANNEL_CALLBACK* callback, wStream* s) { - UINT16 index = 0; RDPGFX_POINT16* destPt = NULL; RDPGFX_CACHE_TO_SURFACE_PDU pdu = { 0 }; WINPR_ASSERT(callback); @@ -1693,7 +1680,7 @@ static UINT rdpgfx_recv_cache_to_surface_pdu(GENERIC_CHANNEL_CALLBACK* callback, return CHANNEL_RC_NO_MEMORY; } - for (index = 0; index < pdu.destPtsCount; index++) + for (UINT16 index = 0; index < pdu.destPtsCount; index++) { destPt = &(pdu.destPts[index]); @@ -2248,7 +2235,6 @@ static UINT rdpgfx_get_surface_ids(RdpgfxClientContext* context, UINT16** ppSurf UINT16* count_out) { size_t count = 0; - size_t index = 0; UINT16* pSurfaceIds = NULL; ULONG_PTR* pKeys = NULL; WINPR_ASSERT(context); @@ -2273,7 +2259,7 @@ static UINT rdpgfx_get_surface_ids(RdpgfxClientContext* context, UINT16** ppSurf return CHANNEL_RC_NO_MEMORY; } - for (index = 0; index < count; index++) + for (size_t index = 0; index < count; index++) { pSurfaceIds[index] = (UINT16)(pKeys[index] - 1); } diff --git a/channels/rdpgfx/server/rdpgfx_main.c b/channels/rdpgfx/server/rdpgfx_main.c index b8e93a7be..0a3fabc1b 100644 --- a/channels/rdpgfx/server/rdpgfx_main.c +++ b/channels/rdpgfx/server/rdpgfx_main.c @@ -265,7 +265,7 @@ static UINT rdpgfx_send_reset_graphics_pdu(RdpgfxServerContext* context, { if (!checkCapsAreExchanged(context)) return CHANNEL_RC_NOT_INITIALIZED; - UINT32 index = 0; + wStream* s = NULL; /* Check monitorCount. This ensures total size within 340 bytes) */ @@ -290,7 +290,7 @@ static UINT rdpgfx_send_reset_graphics_pdu(RdpgfxServerContext* context, Stream_Write_UINT32(s, pdu->height); /* height (4 bytes) */ Stream_Write_UINT32(s, pdu->monitorCount); /* monitorCount (4 bytes) */ - for (index = 0; index < pdu->monitorCount; index++) + for (UINT32 index = 0; index < pdu->monitorCount; index++) { const MONITOR_DEF* monitor = &(pdu->monitorDefArray[index]); Stream_Write_UINT32(s, monitor->left); /* left (4 bytes) */ @@ -576,7 +576,6 @@ static INLINE UINT16 rdpgfx_surface_command_cmdid(const RDPGFX_SURFACE_COMMAND* */ static UINT rdpgfx_write_h264_metablock(wLog* log, wStream* s, const RDPGFX_H264_METABLOCK* meta) { - UINT32 index = 0; RECTANGLE_16* regionRect = NULL; RDPGFX_H264_QUANT_QUALITY* quantQualityVal = NULL; UINT error = CHANNEL_RC_OK; @@ -586,7 +585,7 @@ static UINT rdpgfx_write_h264_metablock(wLog* log, wStream* s, const RDPGFX_H264 Stream_Write_UINT32(s, meta->numRegionRects); /* numRegionRects (4 bytes) */ - for (index = 0; index < meta->numRegionRects; index++) + for (UINT32 index = 0; index < meta->numRegionRects; index++) { regionRect = &(meta->regionRects[index]); @@ -598,7 +597,7 @@ static UINT rdpgfx_write_h264_metablock(wLog* log, wStream* s, const RDPGFX_H264 } } - for (index = 0; index < meta->numRegionRects; index++) + for (UINT32 index = 0; index < meta->numRegionRects; index++) { quantQualityVal = &(meta->quantQualityVals[index]); Stream_Write_UINT8(s, quantQualityVal->qp | (quantQualityVal->r << 6) | @@ -932,7 +931,6 @@ static UINT rdpgfx_send_solid_fill_pdu(RdpgfxServerContext* context, if (!checkCapsAreExchanged(context)) return CHANNEL_RC_NOT_INITIALIZED; UINT error = CHANNEL_RC_OK; - UINT16 index = 0; RECTANGLE_16* fillRect = NULL; wStream* s = rdpgfx_server_single_packet_new(context->priv->log, RDPGFX_CMDID_SOLIDFILL, 8 + 8 * pdu->fillRectCount); @@ -955,7 +953,7 @@ static UINT rdpgfx_send_solid_fill_pdu(RdpgfxServerContext* context, Stream_Write_UINT16(s, pdu->fillRectCount); /* fillRectCount (2 bytes) */ - for (index = 0; index < pdu->fillRectCount; index++) + for (UINT16 index = 0; index < pdu->fillRectCount; index++) { fillRect = &(pdu->fillRects[index]); @@ -984,7 +982,6 @@ static UINT rdpgfx_send_surface_to_surface_pdu(RdpgfxServerContext* context, if (!checkCapsAreExchanged(context)) return CHANNEL_RC_NOT_INITIALIZED; UINT error = CHANNEL_RC_OK; - UINT16 index = 0; RDPGFX_POINT16* destPt = NULL; wStream* s = rdpgfx_server_single_packet_new(context->priv->log, RDPGFX_CMDID_SURFACETOSURFACE, 14 + 4 * pdu->destPtsCount); @@ -1008,7 +1005,7 @@ static UINT rdpgfx_send_surface_to_surface_pdu(RdpgfxServerContext* context, Stream_Write_UINT16(s, pdu->destPtsCount); /* destPtsCount (2 bytes) */ - for (index = 0; index < pdu->destPtsCount; index++) + for (UINT16 index = 0; index < pdu->destPtsCount; index++) { destPt = &(pdu->destPts[index]); @@ -1075,7 +1072,6 @@ static UINT rdpgfx_send_cache_to_surface_pdu(RdpgfxServerContext* context, if (!checkCapsAreExchanged(context)) return CHANNEL_RC_NOT_INITIALIZED; UINT error = CHANNEL_RC_OK; - UINT16 index = 0; RDPGFX_POINT16* destPt = NULL; wStream* s = rdpgfx_server_single_packet_new(context->priv->log, RDPGFX_CMDID_CACHETOSURFACE, 6 + 4 * pdu->destPtsCount); @@ -1090,7 +1086,7 @@ static UINT rdpgfx_send_cache_to_surface_pdu(RdpgfxServerContext* context, Stream_Write_UINT16(s, pdu->surfaceId); /* surfaceId (2 bytes) */ Stream_Write_UINT16(s, pdu->destPtsCount); /* destPtsCount (2 bytes) */ - for (index = 0; index < pdu->destPtsCount; index++) + for (UINT16 index = 0; index < pdu->destPtsCount; index++) { destPt = &(pdu->destPts[index]); @@ -1224,7 +1220,7 @@ static UINT rdpgfx_recv_cache_import_offer_pdu(RdpgfxServerContext* context, wSt { if (!checkCapsAreExchanged(context)) return CHANNEL_RC_NOT_INITIALIZED; - UINT16 index = 0; + RDPGFX_CACHE_IMPORT_OFFER_PDU pdu = { 0 }; RDPGFX_CACHE_ENTRY_METADATA* cacheEntry = NULL; UINT error = CHANNEL_RC_OK; @@ -1246,7 +1242,7 @@ static UINT rdpgfx_recv_cache_import_offer_pdu(RdpgfxServerContext* context, wSt if (!Stream_CheckAndLogRequiredLengthOfSize(TAG, s, pdu.cacheEntriesCount, 12ull)) return ERROR_INVALID_DATA; - for (index = 0; index < pdu.cacheEntriesCount; index++) + for (UINT16 index = 0; index < pdu.cacheEntriesCount; index++) { cacheEntry = &(pdu.cacheEntries[index]); Stream_Read_UINT64(s, cacheEntry->cacheKey); /* cacheKey (8 bytes) */ @@ -1272,7 +1268,6 @@ static UINT rdpgfx_recv_cache_import_offer_pdu(RdpgfxServerContext* context, wSt */ static UINT rdpgfx_recv_caps_advertise_pdu(RdpgfxServerContext* context, wStream* s) { - UINT16 index = 0; RDPGFX_CAPSET* capsSets = NULL; RDPGFX_CAPS_ADVERTISE_PDU pdu = { 0 }; UINT error = ERROR_INVALID_DATA; @@ -1293,7 +1288,7 @@ static UINT rdpgfx_recv_caps_advertise_pdu(RdpgfxServerContext* context, wStream pdu.capsSets = capsSets; - for (index = 0; index < pdu.capsSetCount; index++) + for (UINT16 index = 0; index < pdu.capsSetCount; index++) { RDPGFX_CAPSET* capsSet = &(pdu.capsSets[index]); diff --git a/channels/rdpsnd/client/alsa/rdpsnd_alsa.c b/channels/rdpsnd/client/alsa/rdpsnd_alsa.c index da4dbf5ec..97f0ba06f 100644 --- a/channels/rdpsnd/client/alsa/rdpsnd_alsa.c +++ b/channels/rdpsnd/client/alsa/rdpsnd_alsa.c @@ -353,7 +353,6 @@ static UINT32 rdpsnd_alsa_get_volume(rdpsndDevicePlugin* device) UINT32 dwVolume = 0; UINT16 dwVolumeLeft = 0; UINT16 dwVolumeRight = 0; - snd_mixer_elem_t* elem = NULL; rdpsndAlsaPlugin* alsa = (rdpsndAlsaPlugin*)device; dwVolumeLeft = ((50 * 0xFFFF) / 100); /* 50% */ dwVolumeRight = ((50 * 0xFFFF) / 100); /* 50% */ @@ -361,7 +360,8 @@ static UINT32 rdpsnd_alsa_get_volume(rdpsndDevicePlugin* device) if (!rdpsnd_alsa_open_mixer(alsa)) return 0; - for (elem = snd_mixer_first_elem(alsa->mixer_handle); elem; elem = snd_mixer_elem_next(elem)) + for (snd_mixer_elem_t* elem = snd_mixer_first_elem(alsa->mixer_handle); elem; + elem = snd_mixer_elem_next(elem)) { if (snd_mixer_selem_has_playback_volume(elem)) { @@ -388,7 +388,6 @@ static BOOL rdpsnd_alsa_set_volume(rdpsndDevicePlugin* device, UINT32 value) long volume_max = 0; long volume_left = 0; long volume_right = 0; - snd_mixer_elem_t* elem = NULL; rdpsndAlsaPlugin* alsa = (rdpsndAlsaPlugin*)device; if (!rdpsnd_alsa_open_mixer(alsa)) @@ -397,7 +396,8 @@ static BOOL rdpsnd_alsa_set_volume(rdpsndDevicePlugin* device, UINT32 value) left = (value & 0xFFFF); right = ((value >> 16) & 0xFFFF); - for (elem = snd_mixer_first_elem(alsa->mixer_handle); elem; elem = snd_mixer_elem_next(elem)) + for (snd_mixer_elem_t* elem = snd_mixer_first_elem(alsa->mixer_handle); elem; + elem = snd_mixer_elem_next(elem)) { if (snd_mixer_selem_has_playback_volume(elem)) { diff --git a/channels/rdpsnd/client/ios/rdpsnd_ios.c b/channels/rdpsnd/client/ios/rdpsnd_ios.c index e50317f20..b8f004f93 100644 --- a/channels/rdpsnd/client/ios/rdpsnd_ios.c +++ b/channels/rdpsnd/client/ios/rdpsnd_ios.c @@ -50,8 +50,6 @@ static OSStatus rdpsnd_ios_render_cb(void* inRefCon, const AudioTimeStamp __unused* inTimeStamp, UInt32 inBusNumber, UInt32 __unused inNumberFrames, AudioBufferList* ioData) { - unsigned int i; - if (inBusNumber != 0) { return noErr; @@ -59,7 +57,7 @@ static OSStatus rdpsnd_ios_render_cb(void* inRefCon, rdpsndIOSPlugin* p = THIS(inRefCon); - for (i = 0; i < ioData->mNumberBuffers; i++) + for (unsigned int i = 0; i < ioData->mNumberBuffers; i++) { AudioBuffer* target_buffer = &ioData->mBuffers[i]; int32_t available_bytes = 0; diff --git a/channels/rdpsnd/client/mac/rdpsnd_mac.m b/channels/rdpsnd/client/mac/rdpsnd_mac.m index 902621c97..648ded4a9 100644 --- a/channels/rdpsnd/client/mac/rdpsnd_mac.m +++ b/channels/rdpsnd/client/mac/rdpsnd_mac.m @@ -316,7 +316,7 @@ static UINT rdpsnd_mac_play(rdpsndDevicePlugin *device, const BYTE *data, size_t AVAudioPCMBuffer *buffer; AVAudioFormat *format; float *const *db; - size_t pos, step, x; + size_t step; AVAudioFrameCount count; UINT64 start = GetTickCount64(); @@ -349,10 +349,10 @@ static UINT rdpsnd_mac_play(rdpsndDevicePlugin *device, const BYTE *data, size_t buffer.frameLength = buffer.frameCapacity; db = buffer.floatChannelData; - for (pos = 0; pos < count; pos++) + for (size_t pos = 0; pos < count; pos++) { const BYTE *d = &data[pos * step]; - for (x = 0; x < mac->format.nChannels; x++) + for (size_t x = 0; x < mac->format.nChannels; x++) { const float val = (int16_t)((uint16_t)d[0] | ((uint16_t)d[1] << 8)) / 32768.0f; db[x][pos] = val; diff --git a/channels/rdpsnd/client/pulse/rdpsnd_pulse.c b/channels/rdpsnd/client/pulse/rdpsnd_pulse.c index 725f7ed81..59b207677 100644 --- a/channels/rdpsnd/client/pulse/rdpsnd_pulse.c +++ b/channels/rdpsnd/client/pulse/rdpsnd_pulse.c @@ -89,7 +89,6 @@ static BOOL rdpsnd_pulse_format_supported(rdpsndDevicePlugin* device, const AUDI static void rdpsnd_pulse_get_sink_info(pa_context* c, const pa_sink_info* i, int eol, void* userdata) { - uint8_t x = 0; UINT16 dwVolumeLeft = ((50 * 0xFFFF) / 100); /* 50% */ UINT16 dwVolumeRight = ((50 * 0xFFFF) / 100); /* 50% */ rdpsndPulsePlugin* pulse = (rdpsndPulsePlugin*)userdata; @@ -98,7 +97,7 @@ static void rdpsnd_pulse_get_sink_info(pa_context* c, const pa_sink_info* i, int if (!rdpsnd_check_pulse(pulse, FALSE) || !i) return; - for (x = 0; x < i->volume.channels; x++) + for (uint8_t x = 0; x < i->volume.channels; x++) { pa_volume_t volume = i->volume.values[x]; diff --git a/channels/rdpsnd/client/rdpsnd_main.c b/channels/rdpsnd/client/rdpsnd_main.c index 04f1f5c6f..6c66d33ec 100644 --- a/channels/rdpsnd/client/rdpsnd_main.c +++ b/channels/rdpsnd/client/rdpsnd_main.c @@ -162,7 +162,6 @@ static UINT rdpsnd_send_quality_mode_pdu(rdpsndPlugin* rdpsnd) static void rdpsnd_select_supported_audio_formats(rdpsndPlugin* rdpsnd) { - UINT16 index = 0; WINPR_ASSERT(rdpsnd); audio_formats_free(rdpsnd->ClientFormats, rdpsnd->NumberOfClientFormats); rdpsnd->NumberOfClientFormats = 0; @@ -176,7 +175,7 @@ static void rdpsnd_select_supported_audio_formats(rdpsndPlugin* rdpsnd) if (!rdpsnd->ClientFormats || !rdpsnd->device) return; - for (index = 0; index < rdpsnd->NumberOfServerFormats; index++) + for (UINT16 index = 0; index < rdpsnd->NumberOfServerFormats; index++) { const AUDIO_FORMAT* serverFormat = &rdpsnd->ServerFormats[index]; @@ -200,7 +199,6 @@ static void rdpsnd_select_supported_audio_formats(rdpsndPlugin* rdpsnd) */ static UINT rdpsnd_send_client_audio_formats(rdpsndPlugin* rdpsnd) { - UINT16 index = 0; wStream* pdu = NULL; UINT16 length = 0; UINT32 dwVolume = 0; @@ -214,7 +212,7 @@ static UINT rdpsnd_send_client_audio_formats(rdpsndPlugin* rdpsnd) wNumberOfFormats = rdpsnd->NumberOfClientFormats; length = 4 + 20; - for (index = 0; index < wNumberOfFormats; index++) + for (UINT16 index = 0; index < wNumberOfFormats; index++) length += (18 + rdpsnd->ClientFormats[index].cbSize); pdu = Stream_New(NULL, length); @@ -237,7 +235,7 @@ static UINT rdpsnd_send_client_audio_formats(rdpsndPlugin* rdpsnd) Stream_Write_UINT16(pdu, CHANNEL_VERSION_WIN_MAX); /* wVersion */ Stream_Write_UINT8(pdu, 0); /* bPad */ - for (index = 0; index < wNumberOfFormats; index++) + for (UINT16 index = 0; index < wNumberOfFormats; index++) { const AUDIO_FORMAT* clientFormat = &rdpsnd->ClientFormats[index]; @@ -260,7 +258,6 @@ static UINT rdpsnd_send_client_audio_formats(rdpsndPlugin* rdpsnd) */ static UINT rdpsnd_recv_server_audio_formats_pdu(rdpsndPlugin* rdpsnd, wStream* s) { - UINT16 index = 0; UINT16 wNumberOfFormats = 0; UINT ret = ERROR_BAD_LENGTH; @@ -293,7 +290,7 @@ static UINT rdpsnd_recv_server_audio_formats_pdu(rdpsndPlugin* rdpsnd, wStream* if (!rdpsnd->ServerFormats) return CHANNEL_RC_NO_MEMORY; - for (index = 0; index < wNumberOfFormats; index++) + for (UINT16 index = 0; index < wNumberOfFormats; index++) { AUDIO_FORMAT* format = &rdpsnd->ServerFormats[index]; @@ -1070,9 +1067,7 @@ static UINT rdpsnd_process_connect(rdpsndPlugin* rdpsnd) } else { - size_t x = 0; - - for (x = 0; x < ARRAYSIZE(backends); x++) + for (size_t x = 0; x < ARRAYSIZE(backends); x++) { const char* subsystem_name = backends[x].subsystem; const char* device_name = backends[x].device; diff --git a/channels/rdpsnd/server/rdpsnd_main.c b/channels/rdpsnd/server/rdpsnd_main.c index 2959d6ef1..73f970c42 100644 --- a/channels/rdpsnd/server/rdpsnd_main.c +++ b/channels/rdpsnd/server/rdpsnd_main.c @@ -177,7 +177,6 @@ static UINT rdpsnd_server_recv_quality_mode(RdpsndServerContext* context, wStrea */ static UINT rdpsnd_server_recv_formats(RdpsndServerContext* context, wStream* s) { - UINT16 i = 0; UINT16 num_known_format = 0; UINT16 udpPort = 0; BYTE lastblock = 0; @@ -215,7 +214,7 @@ static UINT rdpsnd_server_recv_formats(RdpsndServerContext* context, wStream* s) return CHANNEL_RC_NO_MEMORY; } - for (i = 0; i < context->num_client_formats; i++) + for (UINT16 i = 0; i < context->num_client_formats; i++) { AUDIO_FORMAT* format = &context->client_formats[i]; diff --git a/channels/remdesk/client/remdesk_main.c b/channels/remdesk/client/remdesk_main.c index c1a146d68..1d39ed116 100644 --- a/channels/remdesk/client/remdesk_main.c +++ b/channels/remdesk/client/remdesk_main.c @@ -174,14 +174,13 @@ static UINT remdesk_read_channel_header(wStream* s, REMDESK_CHANNEL_HEADER* head */ static UINT remdesk_write_channel_header(wStream* s, REMDESK_CHANNEL_HEADER* header) { - int index = 0; UINT32 ChannelNameLen = 0; WCHAR ChannelNameW[32] = { 0 }; WINPR_ASSERT(s); WINPR_ASSERT(header); - for (index = 0; index < 32; index++) + for (size_t index = 0; index < 32; index++) { ChannelNameW[index] = (WCHAR)header->ChannelName[index]; } diff --git a/channels/remdesk/server/remdesk_main.c b/channels/remdesk/server/remdesk_main.c index e95fb742b..4c823aab9 100644 --- a/channels/remdesk/server/remdesk_main.c +++ b/channels/remdesk/server/remdesk_main.c @@ -85,11 +85,10 @@ static UINT remdesk_read_channel_header(wStream* s, REMDESK_CHANNEL_HEADER* head */ static UINT remdesk_write_channel_header(wStream* s, REMDESK_CHANNEL_HEADER* header) { - int index = 0; UINT32 ChannelNameLen = 0; WCHAR ChannelNameW[32] = { 0 }; - for (index = 0; index < 32; index++) + for (size_t index = 0; index < 32; index++) { ChannelNameW[index] = (WCHAR)header->ChannelName[index]; } diff --git a/channels/serial/client/serial_main.c b/channels/serial/client/serial_main.c index 58f61b90a..22f799a16 100644 --- a/channels/serial/client/serial_main.c +++ b/channels/serial/client/serial_main.c @@ -820,7 +820,6 @@ FREERDP_ENTRY_POINT(UINT serial_DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS char* driver = NULL; RDPDR_SERIAL* device = NULL; #if defined __linux__ && !defined ANDROID - size_t i = 0; size_t len = 0; SERIAL_DEVICE* serial = NULL; #endif /* __linux__ */ @@ -883,7 +882,7 @@ FREERDP_ENTRY_POINT(UINT serial_DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS goto error_out; } - for (i = 0; i <= len; i++) + for (size_t i = 0; i <= len; i++) Stream_Write_UINT8(serial->device.data, name[i] < 0 ? '_' : name[i]); if (driver != NULL) diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c index dc0e848af..eb45a8e06 100644 --- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c +++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c @@ -451,9 +451,8 @@ static BOOL tsmf_ffmpeg_decode_audio(ITSMFDecoder* decoder, const BYTE* data, UI int dst_offset = 0; #if 0 WLog_DBG(TAG, ("tsmf_ffmpeg_decode_audio: data_size %"PRIu32"", data_size)); - int i; - for (i = 0; i < data_size; i++) + for (int i = 0; i < data_size; i++) { WLog_DBG(TAG, ("%02"PRIX8"", data[i])); diff --git a/channels/tsmf/client/gstreamer/tsmf_X11.c b/channels/tsmf/client/gstreamer/tsmf_X11.c index 4e7b10996..987e69b28 100644 --- a/channels/tsmf/client/gstreamer/tsmf_X11.c +++ b/channels/tsmf/client/gstreamer/tsmf_X11.c @@ -384,7 +384,6 @@ int tsmf_window_resize(TSMFGstreamerDecoder* decoder, int x, int y, int width, i #if defined(WITH_XEXT) if (hdl->has_shape) { - int i; XRectangle* xrects = NULL; if (nr_rects == 0) @@ -402,7 +401,7 @@ int tsmf_window_resize(TSMFGstreamerDecoder* decoder, int x, int y, int width, i if (xrects) { - for (i = 0; i < nr_rects; i++) + for (int i = 0; i < nr_rects; i++) { xrects[i].x = rects[i].x - x; xrects[i].y = rects[i].y - y; diff --git a/channels/tsmf/client/tsmf_codec.c b/channels/tsmf/client/tsmf_codec.c index 8143527b9..d3f67078d 100644 --- a/channels/tsmf/client/tsmf_codec.c +++ b/channels/tsmf/client/tsmf_codec.c @@ -488,7 +488,6 @@ BOOL tsmf_codec_parse_media_type(TS_AM_MEDIA_TYPE* mediatype, wStream* s) { UINT32 cbFormat = 0; BOOL ret = TRUE; - int i = 0; ZeroMemory(mediatype, sizeof(TS_AM_MEDIA_TYPE)); @@ -498,7 +497,8 @@ BOOL tsmf_codec_parse_media_type(TS_AM_MEDIA_TYPE* mediatype, wStream* s) return FALSE; tsmf_print_guid(Stream_Pointer(s)); - for (i = 0; tsmf_major_type_map[i].type != TSMF_MAJOR_TYPE_UNKNOWN; i++) + size_t i = 0; + for (; tsmf_major_type_map[i].type != TSMF_MAJOR_TYPE_UNKNOWN; i++) { if (memcmp(tsmf_major_type_map[i].guid, Stream_Pointer(s), 16) == 0) break; diff --git a/channels/tsmf/client/tsmf_ifman.c b/channels/tsmf/client/tsmf_ifman.c index 53af3b64f..223050571 100644 --- a/channels/tsmf/client/tsmf_ifman.c +++ b/channels/tsmf/client/tsmf_ifman.c @@ -68,7 +68,6 @@ UINT tsmf_ifman_rim_exchange_capability_request(TSMF_IFMAN* ifman) */ UINT tsmf_ifman_exchange_capability_request(TSMF_IFMAN* ifman) { - UINT32 i = 0; UINT32 v = 0; UINT32 pos = 0; UINT32 CapabilityType = 0; @@ -91,7 +90,7 @@ UINT tsmf_ifman_exchange_capability_request(TSMF_IFMAN* ifman) Stream_Read_UINT32(ifman->output, numHostCapabilities); - for (i = 0; i < numHostCapabilities; i++) + for (UINT32 i = 0; i < numHostCapabilities; i++) { if (!Stream_CheckAndLogRequiredLength(TAG, ifman->output, 8)) return ERROR_INVALID_DATA; @@ -516,7 +515,7 @@ UINT tsmf_ifman_update_geometry_info(TSMF_IFMAN* ifman) { rects = (RDP_RECT*)calloc(num_rects, sizeof(RDP_RECT)); - for (i = 0; i < num_rects; i++) + for (UINT32 i = 0; i < num_rects; i++) { Stream_Read_UINT16(ifman->input, rects[i].y); /* Top */ Stream_Seek_UINT16(ifman->input); diff --git a/channels/tsmf/client/tsmf_media.c b/channels/tsmf/client/tsmf_media.c index 2cbd49138..5f47090ae 100644 --- a/channels/tsmf/client/tsmf_media.c +++ b/channels/tsmf/client/tsmf_media.c @@ -166,7 +166,6 @@ static UINT64 get_current_time(void) static TSMF_SAMPLE* tsmf_stream_pop_sample(TSMF_STREAM* stream, int sync) { - UINT32 index = 0; UINT32 count = 0; TSMF_STREAM* s = NULL; TSMF_SAMPLE* sample = NULL; @@ -199,7 +198,7 @@ static TSMF_SAMPLE* tsmf_stream_pop_sample(TSMF_STREAM* stream, int sync) ArrayList_Lock(presentation->stream_list); count = ArrayList_Count(presentation->stream_list); - for (index = 0; index < count; index++) + for (UINT32 index = 0; index < count; index++) { s = (TSMF_STREAM*)ArrayList_GetItem(presentation->stream_list, index); @@ -381,12 +380,10 @@ error_stream_list: static char* guid_to_string(const BYTE* guid, char* str, size_t len) { - size_t i = 0; - if (!guid || !str) return NULL; - for (i = 0; i < GUID_SIZE && (len > 2 * i); i++) + for (size_t i = 0; i < GUID_SIZE && (len > 2 * i); i++) sprintf_s(str + (2 * i), len - 2 * i, "%02" PRIX8 "", guid[i]); return str; @@ -394,7 +391,6 @@ static char* guid_to_string(const BYTE* guid, char* str, size_t len) TSMF_PRESENTATION* tsmf_presentation_find_by_id(const BYTE* guid) { - UINT32 index = 0; UINT32 count = 0; BOOL found = FALSE; char guid_str[GUID_SIZE * 2 + 1] = { 0 }; @@ -402,7 +398,7 @@ TSMF_PRESENTATION* tsmf_presentation_find_by_id(const BYTE* guid) ArrayList_Lock(presentation_list); count = ArrayList_Count(presentation_list); - for (index = 0; index < count; index++) + for (size_t index = 0; index < count; index++) { presentation = (TSMF_PRESENTATION*)ArrayList_GetItem(presentation_list, index); @@ -579,9 +575,8 @@ static BOOL tsmf_sample_playback(TSMF_SAMPLE* sample) TSMF_PRESENTATION* presentation = stream->presentation; ArrayList_Lock(presentation->stream_list); int count = ArrayList_Count(presentation->stream_list); - int index = 0; - for (index = 0; index < count; index++) + for (size_t index = 0; index < count; index++) { UINT64 time_diff = 0; temp_stream = (TSMF_STREAM*)ArrayList_GetItem(presentation->stream_list, index); @@ -971,16 +966,14 @@ static BOOL tsmf_stream_change_volume(TSMF_STREAM* stream, UINT32 newVolume, UIN BOOL tsmf_presentation_volume_changed(TSMF_PRESENTATION* presentation, UINT32 newVolume, UINT32 muted) { - UINT32 index = 0; - UINT32 count = 0; TSMF_STREAM* stream = NULL; BOOL ret = TRUE; presentation->volume = newVolume; presentation->muted = muted; ArrayList_Lock(presentation->stream_list); - count = ArrayList_Count(presentation->stream_list); + size_t count = ArrayList_Count(presentation->stream_list); - for (index = 0; index < count; index++) + for (size_t index = 0; index < count; index++) { stream = (TSMF_STREAM*)ArrayList_GetItem(presentation->stream_list, index); ret &= tsmf_stream_change_volume(stream, newVolume, muted); @@ -992,14 +985,12 @@ BOOL tsmf_presentation_volume_changed(TSMF_PRESENTATION* presentation, UINT32 ne BOOL tsmf_presentation_paused(TSMF_PRESENTATION* presentation) { - UINT32 index = 0; - UINT32 count = 0; TSMF_STREAM* stream = NULL; BOOL ret = TRUE; ArrayList_Lock(presentation->stream_list); - count = ArrayList_Count(presentation->stream_list); + size_t count = ArrayList_Count(presentation->stream_list); - for (index = 0; index < count; index++) + for (size_t index = 0; index < count; index++) { stream = (TSMF_STREAM*)ArrayList_GetItem(presentation->stream_list, index); ret &= tsmf_stream_pause(stream); @@ -1011,14 +1002,12 @@ BOOL tsmf_presentation_paused(TSMF_PRESENTATION* presentation) BOOL tsmf_presentation_restarted(TSMF_PRESENTATION* presentation) { - UINT32 index = 0; - UINT32 count = 0; TSMF_STREAM* stream = NULL; BOOL ret = TRUE; ArrayList_Lock(presentation->stream_list); - count = ArrayList_Count(presentation->stream_list); + size_t count = ArrayList_Count(presentation->stream_list); - for (index = 0; index < count; index++) + for (size_t index = 0; index < count; index++) { stream = (TSMF_STREAM*)ArrayList_GetItem(presentation->stream_list, index); ret &= tsmf_stream_restart(stream); @@ -1030,14 +1019,12 @@ BOOL tsmf_presentation_restarted(TSMF_PRESENTATION* presentation) BOOL tsmf_presentation_start(TSMF_PRESENTATION* presentation) { - UINT32 index = 0; - UINT32 count = 0; TSMF_STREAM* stream = NULL; BOOL ret = TRUE; ArrayList_Lock(presentation->stream_list); - count = ArrayList_Count(presentation->stream_list); + size_t count = ArrayList_Count(presentation->stream_list); - for (index = 0; index < count; index++) + for (size_t index = 0; index < count; index++) { stream = (TSMF_STREAM*)ArrayList_GetItem(presentation->stream_list, index); ret &= tsmf_stream_start(stream); @@ -1054,13 +1041,11 @@ BOOL tsmf_presentation_start(TSMF_PRESENTATION* presentation) */ UINT tsmf_presentation_sync(TSMF_PRESENTATION* presentation) { - UINT32 index = 0; - UINT32 count = 0; UINT error = 0; ArrayList_Lock(presentation->stream_list); - count = ArrayList_Count(presentation->stream_list); + size_t count = ArrayList_Count(presentation->stream_list); - for (index = 0; index < count; index++) + for (size_t index = 0; index < count; index++) { TSMF_STREAM* stream = (TSMF_STREAM*)ArrayList_GetItem(presentation->stream_list, index); @@ -1078,14 +1063,12 @@ UINT tsmf_presentation_sync(TSMF_PRESENTATION* presentation) BOOL tsmf_presentation_stop(TSMF_PRESENTATION* presentation) { - UINT32 index = 0; - UINT32 count = 0; TSMF_STREAM* stream = NULL; BOOL ret = TRUE; ArrayList_Lock(presentation->stream_list); - count = ArrayList_Count(presentation->stream_list); + size_t count = ArrayList_Count(presentation->stream_list); - for (index = 0; index < count; index++) + for (size_t index = 0; index < count; index++) { stream = (TSMF_STREAM*)ArrayList_GetItem(presentation->stream_list, index); ret &= tsmf_stream_stop(stream); @@ -1101,8 +1084,6 @@ BOOL tsmf_presentation_set_geometry_info(TSMF_PRESENTATION* presentation, UINT32 UINT32 width, UINT32 height, int num_rects, RDP_RECT* rects) { - UINT32 index = 0; - UINT32 count = 0; TSMF_STREAM* stream = NULL; void* tmp_rects = NULL; BOOL ret = TRUE; @@ -1131,9 +1112,9 @@ BOOL tsmf_presentation_set_geometry_info(TSMF_PRESENTATION* presentation, UINT32 if (presentation->rects) CopyMemory(presentation->rects, rects, sizeof(RDP_RECT) * num_rects); ArrayList_Lock(presentation->stream_list); - count = ArrayList_Count(presentation->stream_list); + size_t count = ArrayList_Count(presentation->stream_list); - for (index = 0; index < count; index++) + for (size_t index = 0; index < count; index++) { stream = (TSMF_STREAM*)ArrayList_GetItem(presentation->stream_list, index); @@ -1313,14 +1294,12 @@ void tsmf_stream_start_threads(TSMF_STREAM* stream) TSMF_STREAM* tsmf_stream_find_by_id(TSMF_PRESENTATION* presentation, UINT32 stream_id) { - UINT32 index = 0; - UINT32 count = 0; BOOL found = FALSE; TSMF_STREAM* stream = NULL; ArrayList_Lock(presentation->stream_list); - count = ArrayList_Count(presentation->stream_list); + size_t count = ArrayList_Count(presentation->stream_list); - for (index = 0; index < count; index++) + for (size_t index = 0; index < count; index++) { stream = (TSMF_STREAM*)ArrayList_GetItem(presentation->stream_list, index); diff --git a/channels/urbdrc/client/data_transfer.c b/channels/urbdrc/client/data_transfer.c index ed7056833..7a7e5a2b4 100644 --- a/channels/urbdrc/client/data_transfer.c +++ b/channels/urbdrc/client/data_transfer.c @@ -399,13 +399,12 @@ static UINT urbdrc_process_query_device_text(IUDEVICE* pdev, GENERIC_CHANNEL_CAL static void func_select_all_interface_for_msconfig(IUDEVICE* pdev, MSUSB_CONFIG_DESCRIPTOR* MsConfig) { - UINT32 inum = 0; MSUSB_INTERFACE_DESCRIPTOR** MsInterfaces = MsConfig->MsInterfaces; BYTE InterfaceNumber = 0; BYTE AlternateSetting = 0; UINT32 NumInterfaces = MsConfig->NumInterfaces; - for (inum = 0; inum < NumInterfaces; inum++) + for (UINT32 inum = 0; inum < NumInterfaces; inum++) { InterfaceNumber = MsInterfaces[inum]->InterfaceNumber; AlternateSetting = MsInterfaces[inum]->AlternateSetting; diff --git a/channels/urbdrc/client/libusb/libusb_udevice.c b/channels/urbdrc/client/libusb/libusb_udevice.c index 861e4e2a0..c226eb806 100644 --- a/channels/urbdrc/client/libusb/libusb_udevice.c +++ b/channels/urbdrc/client/libusb/libusb_udevice.c @@ -84,12 +84,11 @@ static void request_free(void* value); static struct libusb_transfer* list_contains(wArrayList* list, UINT32 streamID) { - size_t x = 0; size_t count = 0; if (!list) return NULL; count = ArrayList_Count(list); - for (x = 0; x < count; x++) + for (size_t x = 0; x < count; x++) { struct libusb_transfer* transfer = ArrayList_GetItem(list, x); @@ -261,13 +260,12 @@ static void LIBUSB_CALL func_iso_callback(struct libusb_transfer* transfer) { case LIBUSB_TRANSFER_COMPLETED: { - int i = 0; UINT32 index = 0; BYTE* dataStart = Stream_Pointer(user_data->data); Stream_SetPosition(user_data->data, 40); /* TS_URB_ISOCH_TRANSFER_RESULT IsoPacket offset */ - for (i = 0; i < transfer->num_iso_packets; i++) + for (int i = 0; i < transfer->num_iso_packets; i++) { const UINT32 act_len = transfer->iso_packet_desc[i].actual_length; Stream_Write_UINT32(user_data->data, index); @@ -328,21 +326,15 @@ static const LIBUSB_ENDPOINT_DESCEIPTOR* func_get_ep_desc(LIBUSB_CONFIG_DESCRIPT MSUSB_CONFIG_DESCRIPTOR* MsConfig, UINT32 EndpointAddress) { - BYTE alt = 0; - UINT32 inum = 0; - UINT32 pnum = 0; - MSUSB_INTERFACE_DESCRIPTOR** MsInterfaces = NULL; - const LIBUSB_INTERFACE* interface = NULL; - const LIBUSB_ENDPOINT_DESCEIPTOR* endpoint = NULL; - MsInterfaces = MsConfig->MsInterfaces; - interface = LibusbConfig->interface; + MSUSB_INTERFACE_DESCRIPTOR** MsInterfaces = MsConfig->MsInterfaces; + const LIBUSB_INTERFACE* interface = LibusbConfig->interface; - for (inum = 0; inum < MsConfig->NumInterfaces; inum++) + for (UINT32 inum = 0; inum < MsConfig->NumInterfaces; inum++) { - alt = MsInterfaces[inum]->AlternateSetting; - endpoint = interface[inum].altsetting[alt].endpoint; + BYTE alt = MsInterfaces[inum]->AlternateSetting; + const LIBUSB_ENDPOINT_DESCEIPTOR* endpoint = interface[inum].altsetting[alt].endpoint; - for (pnum = 0; pnum < MsInterfaces[inum]->NumberOfPipes; pnum++) + for (UINT32 pnum = 0; pnum < MsInterfaces[inum]->NumberOfPipes; pnum++) { if (endpoint[pnum].bEndpointAddress == EndpointAddress) { @@ -469,9 +461,7 @@ static int func_config_release_all_interface(URBDRC_PLUGIN* urbdrc, LIBUSB_DEVICE_HANDLE* libusb_handle, UINT32 NumInterfaces) { - UINT32 i = 0; - - for (i = 0; i < NumInterfaces; i++) + for (UINT32 i = 0; i < NumInterfaces; i++) { int ret = libusb_release_interface(libusb_handle, i); @@ -485,10 +475,9 @@ static int func_config_release_all_interface(URBDRC_PLUGIN* urbdrc, static int func_claim_all_interface(URBDRC_PLUGIN* urbdrc, LIBUSB_DEVICE_HANDLE* libusb_handle, int NumInterfaces) { - int i = 0; int ret = 0; - for (i = 0; i < NumInterfaces; i++) + for (int i = 0; i < NumInterfaces; i++) { ret = libusb_claim_interface(libusb_handle, i); @@ -502,12 +491,11 @@ static int func_claim_all_interface(URBDRC_PLUGIN* urbdrc, LIBUSB_DEVICE_HANDLE* static LIBUSB_DEVICE* udev_get_libusb_dev(libusb_context* context, uint8_t bus_number, uint8_t dev_number) { - ssize_t i = 0; LIBUSB_DEVICE** libusb_list = NULL; LIBUSB_DEVICE* device = NULL; const ssize_t total_device = libusb_get_device_list(context, &libusb_list); - for (i = 0; i < total_device; i++) + for (ssize_t i = 0; i < total_device; i++) { LIBUSB_DEVICE* dev = libusb_list[i]; if ((bus_number == libusb_get_bus_number(dev)) && @@ -599,8 +587,6 @@ libusb_udev_complete_msconfig_setup(IUDEVICE* idev, MSUSB_CONFIG_DESCRIPTOR* MsC const LIBUSB_ENDPOINT_DESCEIPTOR* LibusbEndpoint = NULL; BYTE LibusbNumEndpoint = 0; URBDRC_PLUGIN* urbdrc = NULL; - UINT32 inum = 0; - UINT32 pnum = 0; UINT32 MsOutSize = 0; if (!pdev || !pdev->LibusbConfig || !pdev->urbdrc || !MsConfig) @@ -620,7 +606,7 @@ libusb_udev_complete_msconfig_setup(IUDEVICE* idev, MSUSB_CONFIG_DESCRIPTOR* MsC /* replace MsPipes for libusb */ MsInterfaces = MsConfig->MsInterfaces; - for (inum = 0; inum < MsConfig->NumInterfaces; inum++) + for (UINT32 inum = 0; inum < MsConfig->NumInterfaces; inum++) { MsInterface = MsInterfaces[inum]; /* get libusb's number of endpoints */ @@ -630,7 +616,7 @@ libusb_udev_complete_msconfig_setup(IUDEVICE* idev, MSUSB_CONFIG_DESCRIPTOR* MsC t_MsPipes = (MSUSB_PIPE_DESCRIPTOR**)calloc(LibusbNumEndpoint, sizeof(MSUSB_PIPE_DESCRIPTOR*)); - for (pnum = 0; pnum < LibusbNumEndpoint; pnum++) + for (UINT32 pnum = 0; pnum < LibusbNumEndpoint; pnum++) { t_MsPipe = (MSUSB_PIPE_DESCRIPTOR*)calloc(1, sizeof(MSUSB_PIPE_DESCRIPTOR)); @@ -671,7 +657,7 @@ libusb_udev_complete_msconfig_setup(IUDEVICE* idev, MSUSB_CONFIG_DESCRIPTOR* MsC MsConfig->bConfigurationValue | (pdev->bus_number << 24) | (pdev->dev_number << 16); MsInterfaces = MsConfig->MsInterfaces; - for (inum = 0; inum < MsConfig->NumInterfaces; inum++) + for (UINT32 inum = 0; inum < MsConfig->NumInterfaces; inum++) { MsOutSize += 16; MsInterface = MsInterfaces[inum]; @@ -695,7 +681,7 @@ libusb_udev_complete_msconfig_setup(IUDEVICE* idev, MSUSB_CONFIG_DESCRIPTOR* MsC MsPipes = MsInterface->MsPipes; LibusbNumEndpoint = LibusbAltsetting->bNumEndpoints; - for (pnum = 0; pnum < LibusbNumEndpoint; pnum++) + for (UINT32 pnum = 0; pnum < LibusbNumEndpoint; pnum++) { MsOutSize += 20; MsPipe = MsPipes[pnum]; @@ -837,7 +823,6 @@ static UINT32 libusb_udev_control_query_device_text(IUDEVICE* idev, UINT32 TextT BYTE bus_number = 0; BYTE device_address = 0; int ret = 0; - size_t i = 0; size_t len = 0; URBDRC_PLUGIN* urbdrc = NULL; WCHAR* text = (WCHAR*)Buffer; @@ -879,7 +864,7 @@ static UINT32 libusb_udev_control_query_device_text(IUDEVICE* idev, UINT32 TextT msg, ret, devDescriptor->iProduct); len = MIN(sizeof(strDesc), inSize); - for (i = 0; i < len; i++) + for (ssize_t i = 0; i < len; i++) text[i] = (WCHAR)strDesc[i]; *BufferSize = (BYTE)(len * 2); @@ -914,7 +899,7 @@ static UINT32 libusb_udev_control_query_device_text(IUDEVICE* idev, UINT32 TextT len = strnlen(deviceLocation, MIN(sizeof(deviceLocation), (inSize > 0) ? inSize - 1U : 0)); - for (i = 0; i < len; i++) + for (ssize_t i = 0; i < len; i++) text[i] = (WCHAR)deviceLocation[i]; text[len++] = '\0'; *BufferSize = (UINT8)(len * sizeof(WCHAR)); @@ -1030,7 +1015,6 @@ static int libusb_udev_query_device_descriptor(IUDEVICE* idev, int offset) static BOOL libusb_udev_detach_kernel_driver(IUDEVICE* idev) { - int i = 0; int err = 0; UDEVICE* pdev = (UDEVICE*)idev; URBDRC_PLUGIN* urbdrc = NULL; @@ -1045,7 +1029,7 @@ static BOOL libusb_udev_detach_kernel_driver(IUDEVICE* idev) if ((pdev->status & URBDRC_DEVICE_DETACH_KERNEL) == 0) { - for (i = 0; i < pdev->LibusbConfig->bNumInterfaces; i++) + for (int i = 0; i < pdev->LibusbConfig->bNumInterfaces; i++) { err = libusb_kernel_driver_active(pdev->libusb_handle, i); log_libusb_result(urbdrc->log, WLOG_DEBUG, "libusb_kernel_driver_active", err); @@ -1066,14 +1050,13 @@ static BOOL libusb_udev_detach_kernel_driver(IUDEVICE* idev) static BOOL libusb_udev_attach_kernel_driver(IUDEVICE* idev) { - int i = 0; int err = 0; UDEVICE* pdev = (UDEVICE*)idev; if (!pdev || !pdev->LibusbConfig || !pdev->libusb_handle || !pdev->urbdrc) return FALSE; - for (i = 0; i < pdev->LibusbConfig->bNumInterfaces && err != LIBUSB_ERROR_NO_DEVICE; i++) + for (int i = 0; i < pdev->LibusbConfig->bNumInterfaces && err != LIBUSB_ERROR_NO_DEVICE; i++) { err = libusb_release_interface(pdev->libusb_handle, i); @@ -1429,7 +1412,6 @@ static void libusb_udev_cancel_all_transfer_request(IUDEVICE* idev) { UDEVICE* pdev = (UDEVICE*)idev; size_t count = 0; - size_t x = 0; if (!pdev || !pdev->request_queue || !pdev->urbdrc) return; @@ -1437,7 +1419,7 @@ static void libusb_udev_cancel_all_transfer_request(IUDEVICE* idev) ArrayList_Lock(pdev->request_queue); count = ArrayList_Count(pdev->request_queue); - for (x = 0; x < count; x++) + for (size_t x = 0; x < count; x++) { struct libusb_transfer* transfer = ArrayList_GetItem(pdev->request_queue, x); func_cancel_xact_request(pdev->urbdrc, transfer); @@ -1588,7 +1570,6 @@ static int udev_get_device_handle(URBDRC_PLUGIN* urbdrc, libusb_context* ctx, UD UINT16 bus_number, UINT16 dev_number) { int error = -1; - ssize_t i = 0; uint8_t port_numbers[16] = { 0 }; LIBUSB_DEVICE** libusb_list = NULL; const ssize_t total_device = libusb_get_device_list(ctx, &libusb_list); @@ -1596,7 +1577,7 @@ static int udev_get_device_handle(URBDRC_PLUGIN* urbdrc, libusb_context* ctx, UD WINPR_ASSERT(urbdrc); /* Look for device. */ - for (i = 0; i < total_device; i++) + for (ssize_t i = 0; i < total_device; i++) { LIBUSB_DEVICE* dev = libusb_list[i]; @@ -1643,7 +1624,6 @@ static int udev_get_hub_handle(URBDRC_PLUGIN* urbdrc, libusb_context* ctx, UDEVI UINT16 bus_number, UINT16 dev_number) { int error = -1; - ssize_t i = 0; LIBUSB_DEVICE** libusb_list = NULL; LIBUSB_DEVICE_HANDLE* handle = NULL; const ssize_t total_device = libusb_get_device_list(ctx, &libusb_list); @@ -1651,7 +1631,7 @@ static int udev_get_hub_handle(URBDRC_PLUGIN* urbdrc, libusb_context* ctx, UDEVI WINPR_ASSERT(urbdrc); /* Look for device hub. */ - for (i = 0; i < total_device; i++) + for (ssize_t i = 0; i < total_device; i++) { LIBUSB_DEVICE* dev = libusb_list[i]; @@ -1811,7 +1791,6 @@ size_t udev_new_by_id(URBDRC_PLUGIN* urbdrc, libusb_context* ctx, UINT16 idVendo { LIBUSB_DEVICE** libusb_list = NULL; UDEVICE** array = NULL; - ssize_t i = 0; ssize_t total_device = 0; size_t num = 0; @@ -1829,7 +1808,7 @@ size_t udev_new_by_id(URBDRC_PLUGIN* urbdrc, libusb_context* ctx, UINT16 idVendo if (!array) goto fail; - for (i = 0; i < total_device; i++) + for (ssize_t i = 0; i < total_device; i++) { LIBUSB_DEVICE* dev = libusb_list[i]; LIBUSB_DEVICE_DESCRIPTOR* descriptor = udev_new_descript(urbdrc, dev); diff --git a/channels/urbdrc/client/libusb/libusb_udevman.c b/channels/urbdrc/client/libusb/libusb_udevman.c index b90d67aad..d52c3074b 100644 --- a/channels/urbdrc/client/libusb/libusb_udevman.c +++ b/channels/urbdrc/client/libusb/libusb_udevman.c @@ -145,7 +145,6 @@ static size_t udevman_register_udevice(IUDEVMAN* idevman, BYTE bus_number, BYTE IUDEVICE* pdev = NULL; IUDEVICE** devArray = NULL; URBDRC_PLUGIN* urbdrc = NULL; - size_t i = 0; size_t num = 0; size_t addnum = 0; @@ -200,7 +199,7 @@ static size_t udevman_register_udevice(IUDEVMAN* idevman, BYTE bus_number, BYTE idProduct); } - for (i = 0; i < num; i++) + for (size_t i = 0; i < num; i++) { UINT32 id = 0; IUDEVICE* tdev = devArray[i]; @@ -532,13 +531,10 @@ static BOOL device_is_filtered(struct libusb_device* dev, int rc = libusb_get_active_config_descriptor(dev, &config); if (rc == LIBUSB_SUCCESS) { - uint8_t x = 0; - - for (x = 0; x < config->bNumInterfaces; x++) + for (uint8_t x = 0; x < config->bNumInterfaces; x++) { - int y = 0; const struct libusb_interface* ifc = &config->interface[x]; - for (y = 0; y < ifc->num_altsetting; y++) + for (int y = 0; y < ifc->num_altsetting; y++) { const struct libusb_interface_descriptor* const alt = &ifc->altsetting[y]; if (filter_by_class(alt->bInterfaceClass, alt->bInterfaceSubClass)) @@ -718,10 +714,9 @@ static BOOL urbdrc_udevman_register_devices(UDEVMAN* udevman, const char* device static UINT urbdrc_udevman_parse_addin_args(UDEVMAN* udevman, const ADDIN_ARGV* args) { - int x = 0; LPCSTR devices = NULL; - for (x = 0; x < args->argc; x++) + for (int x = 0; x < args->argc; x++) { const char* arg = args->argv[x]; if (strcmp(arg, "dbg") == 0) diff --git a/channels/urbdrc/common/msusb.c b/channels/urbdrc/common/msusb.c index b4fb2b26f..dd76b1dca 100644 --- a/channels/urbdrc/common/msusb.c +++ b/channels/urbdrc/common/msusb.c @@ -34,11 +34,9 @@ static MSUSB_PIPE_DESCRIPTOR* msusb_mspipe_new(void) static void msusb_mspipes_free(MSUSB_PIPE_DESCRIPTOR** MsPipes, UINT32 NumberOfPipes) { - UINT32 pnum = 0; - if (MsPipes) { - for (pnum = 0; pnum < NumberOfPipes && MsPipes[pnum]; pnum++) + for (UINT32 pnum = 0; pnum < NumberOfPipes && MsPipes[pnum]; pnum++) free(MsPipes[pnum]); free(MsPipes); @@ -61,7 +59,6 @@ BOOL msusb_mspipes_replace(MSUSB_INTERFACE_DESCRIPTOR* MsInterface, static MSUSB_PIPE_DESCRIPTOR** msusb_mspipes_read(wStream* s, UINT32 NumberOfPipes) { - UINT32 pnum = 0; MSUSB_PIPE_DESCRIPTOR** MsPipes = NULL; if (!Stream_CheckAndLogRequiredCapacityOfSize(TAG, (s), NumberOfPipes, 12ull)) @@ -72,7 +69,7 @@ static MSUSB_PIPE_DESCRIPTOR** msusb_mspipes_read(wStream* s, UINT32 NumberOfPip if (!MsPipes) return NULL; - for (pnum = 0; pnum < NumberOfPipes; pnum++) + for (UINT32 pnum = 0; pnum < NumberOfPipes; pnum++) { MSUSB_PIPE_DESCRIPTOR* MsPipe = msusb_mspipe_new(); @@ -96,7 +93,7 @@ static MSUSB_PIPE_DESCRIPTOR** msusb_mspipes_read(wStream* s, UINT32 NumberOfPip return MsPipes; out_error: - for (pnum = 0; pnum < NumberOfPipes; pnum++) + for (UINT32 pnum = 0; pnum < NumberOfPipes; pnum++) free(MsPipes[pnum]); free(MsPipes); @@ -121,11 +118,9 @@ void msusb_msinterface_free(MSUSB_INTERFACE_DESCRIPTOR* MsInterface) static void msusb_msinterface_free_list(MSUSB_INTERFACE_DESCRIPTOR** MsInterfaces, UINT32 NumInterfaces) { - UINT32 inum = 0; - if (MsInterfaces) { - for (inum = 0; inum < NumInterfaces; inum++) + for (UINT32 inum = 0; inum < NumInterfaces; inum++) { msusb_msinterface_free(MsInterfaces[inum]); } @@ -188,7 +183,6 @@ BOOL msusb_msinterface_write(MSUSB_INTERFACE_DESCRIPTOR* MsInterface, wStream* o { MSUSB_PIPE_DESCRIPTOR** MsPipes = NULL; MSUSB_PIPE_DESCRIPTOR* MsPipe = NULL; - UINT32 pnum = 0; if (!MsInterface) return FALSE; @@ -217,7 +211,7 @@ BOOL msusb_msinterface_write(MSUSB_INTERFACE_DESCRIPTOR* MsInterface, wStream* o /* Pipes */ MsPipes = MsInterface->MsPipes; - for (pnum = 0; pnum < MsInterface->NumberOfPipes; pnum++) + for (UINT32 pnum = 0; pnum < MsInterface->NumberOfPipes; pnum++) { MsPipe = MsPipes[pnum]; /* MaximumPacketSize */ @@ -241,7 +235,6 @@ BOOL msusb_msinterface_write(MSUSB_INTERFACE_DESCRIPTOR* MsInterface, wStream* o static MSUSB_INTERFACE_DESCRIPTOR** msusb_msinterface_read_list(wStream* s, UINT32 NumInterfaces) { - UINT32 inum = 0; MSUSB_INTERFACE_DESCRIPTOR** MsInterfaces = NULL; MsInterfaces = (MSUSB_INTERFACE_DESCRIPTOR**)calloc(NumInterfaces, sizeof(MSUSB_INTERFACE_DESCRIPTOR*)); @@ -249,7 +242,7 @@ static MSUSB_INTERFACE_DESCRIPTOR** msusb_msinterface_read_list(wStream* s, UINT if (!MsInterfaces) return NULL; - for (inum = 0; inum < NumInterfaces; inum++) + for (UINT32 inum = 0; inum < NumInterfaces; inum++) { MsInterfaces[inum] = msusb_msinterface_read(s); @@ -260,7 +253,7 @@ static MSUSB_INTERFACE_DESCRIPTOR** msusb_msinterface_read_list(wStream* s, UINT return MsInterfaces; fail: - for (inum = 0; inum < NumInterfaces; inum++) + for (UINT32 inum = 0; inum < NumInterfaces; inum++) msusb_msinterface_free(MsInterfaces[inum]); free(MsInterfaces); @@ -269,7 +262,6 @@ fail: BOOL msusb_msconfig_write(MSUSB_CONFIG_DESCRIPTOR* MsConfg, wStream* out) { - UINT32 inum = 0; MSUSB_INTERFACE_DESCRIPTOR** MsInterfaces = NULL; MSUSB_INTERFACE_DESCRIPTOR* MsInterface = NULL; @@ -286,7 +278,7 @@ BOOL msusb_msconfig_write(MSUSB_CONFIG_DESCRIPTOR* MsConfg, wStream* out) /* Interfaces */ MsInterfaces = MsConfg->MsInterfaces; - for (inum = 0; inum < MsConfg->NumInterfaces; inum++) + for (UINT32 inum = 0; inum < MsConfg->NumInterfaces; inum++) { MsInterface = MsInterfaces[inum]; @@ -357,8 +349,7 @@ void msusb_msconfig_dump(MSUSB_CONFIG_DESCRIPTOR* MsConfig) MSUSB_INTERFACE_DESCRIPTOR* MsInterface = NULL; MSUSB_PIPE_DESCRIPTOR** MsPipes = NULL; MSUSB_PIPE_DESCRIPTOR* MsPipe = NULL; - UINT32 inum = 0; - UINT32 pnum = 0; + WLog_INFO(TAG, "=================MsConfig:========================"); WLog_INFO(TAG, "wTotalLength:%" PRIu16 "", MsConfig->wTotalLength); WLog_INFO(TAG, "bConfigurationValue:%" PRIu8 "", MsConfig->bConfigurationValue); @@ -368,7 +359,7 @@ void msusb_msconfig_dump(MSUSB_CONFIG_DESCRIPTOR* MsConfig) WLog_INFO(TAG, "NumInterfaces:%" PRIu32 "", MsConfig->NumInterfaces); MsInterfaces = MsConfig->MsInterfaces; - for (inum = 0; inum < MsConfig->NumInterfaces; inum++) + for (UINT32 inum = 0; inum < MsConfig->NumInterfaces; inum++) { MsInterface = MsInterfaces[inum]; WLog_INFO(TAG, " Interface: %" PRIu8 "", MsInterface->InterfaceNumber); @@ -384,7 +375,7 @@ void msusb_msconfig_dump(MSUSB_CONFIG_DESCRIPTOR* MsConfig) WLog_INFO(TAG, " InitCompleted: %d", MsInterface->InitCompleted); MsPipes = MsInterface->MsPipes; - for (pnum = 0; pnum < MsInterface->NumberOfPipes; pnum++) + for (UINT32 pnum = 0; pnum < MsInterface->NumberOfPipes; pnum++) { MsPipe = MsPipes[pnum]; WLog_INFO(TAG, " Pipe: %" PRIu32, pnum); 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 abef37bae..3fad71e8a 100644 --- a/client/Android/Studio/freeRDPCore/src/main/cpp/android_cliprdr.c +++ b/client/Android/Studio/freeRDPCore/src/main/cpp/android_cliprdr.c @@ -36,7 +36,6 @@ UINT android_cliprdr_send_client_format_list(CliprdrClientContext* cliprdr) { UINT rc = ERROR_INTERNAL_ERROR; - UINT32 index; UINT32 formatId; UINT32 numFormats; UINT32* pFormatIds; @@ -59,7 +58,7 @@ UINT android_cliprdr_send_client_format_list(CliprdrClientContext* cliprdr) if (!formats) goto fail; - for (index = 0; index < numFormats; index++) + for (UINT32 index = 0; index < numFormats; index++) { formatId = pFormatIds[index]; formatName = ClipboardGetFormatName(afc->clipboard, formatId); @@ -169,7 +168,6 @@ static UINT android_cliprdr_monitor_ready(CliprdrClientContext* cliprdr, static UINT android_cliprdr_server_capabilities(CliprdrClientContext* cliprdr, const CLIPRDR_CAPABILITIES* capabilities) { - UINT32 index; CLIPRDR_CAPABILITY_SET* capabilitySet; androidContext* afc; @@ -181,7 +179,7 @@ static UINT android_cliprdr_server_capabilities(CliprdrClientContext* cliprdr, if (!afc) return ERROR_INVALID_PARAMETER; - for (index = 0; index < capabilities->cCapabilitiesSets; index++) + for (UINT32 index = 0; index < capabilities->cCapabilitiesSets; index++) { capabilitySet = &(capabilities->capabilitySets[index]); @@ -207,7 +205,6 @@ static UINT android_cliprdr_server_format_list(CliprdrClientContext* cliprdr, const CLIPRDR_FORMAT_LIST* formatList) { UINT rc; - UINT32 index; CLIPRDR_FORMAT* format; androidContext* afc; @@ -221,7 +218,7 @@ static UINT android_cliprdr_server_format_list(CliprdrClientContext* cliprdr, if (afc->serverFormats) { - for (index = 0; index < afc->numServerFormats; index++) + for (UINT32 index = 0; index < afc->numServerFormats; index++) free(afc->serverFormats[index].formatName); free(afc->serverFormats); @@ -238,7 +235,7 @@ static UINT android_cliprdr_server_format_list(CliprdrClientContext* cliprdr, if (!afc->serverFormats) return CHANNEL_RC_NO_MEMORY; - for (index = 0; index < afc->numServerFormats; index++) + for (UINT32 index = 0; index < afc->numServerFormats; index++) { afc->serverFormats[index].formatId = formatList->formats[index].formatId; afc->serverFormats[index].formatName = NULL; @@ -252,7 +249,7 @@ static UINT android_cliprdr_server_format_list(CliprdrClientContext* cliprdr, } } - for (index = 0; index < afc->numServerFormats; index++) + for (UINT32 index = 0; index < afc->numServerFormats; index++) { format = &(afc->serverFormats[index]); @@ -374,7 +371,6 @@ android_cliprdr_server_format_data_response(CliprdrClientContext* cliprdr, { BYTE* data; UINT32 size; - UINT32 index; UINT32 formatId; CLIPRDR_FORMAT* format = NULL; androidContext* afc; @@ -393,7 +389,7 @@ android_cliprdr_server_format_data_response(CliprdrClientContext* cliprdr, if (!instance) return ERROR_INVALID_PARAMETER; - for (index = 0; index < afc->numServerFormats; index++) + for (UINT32 index = 0; index < afc->numServerFormats; index++) { if (afc->requestedFormatId == afc->serverFormats[index].formatId) format = &(afc->serverFormats[index]); 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 c72622981..1a132534a 100644 --- a/client/Android/Studio/freeRDPCore/src/main/cpp/android_event.c +++ b/client/Android/Studio/freeRDPCore/src/main/cpp/android_event.c @@ -57,7 +57,6 @@ static ANDROID_EVENT* android_peek_event(ANDROID_EVENT_QUEUE* queue) static ANDROID_EVENT* android_pop_event(ANDROID_EVENT_QUEUE* queue) { - int i; ANDROID_EVENT* event; if (queue->count < 1) @@ -66,7 +65,7 @@ static ANDROID_EVENT* android_pop_event(ANDROID_EVENT_QUEUE* queue) event = queue->events[0]; (queue->count)--; - for (i = 0; i < queue->count; i++) + for (size_t i = 0; i < queue->count; i++) { queue->events[i] = queue->events[i + 1]; } diff --git a/client/Android/Studio/freeRDPCore/src/main/cpp/android_freerdp.c b/client/Android/Studio/freeRDPCore/src/main/cpp/android_freerdp.c index f5b26cc25..09dd4f020 100644 --- a/client/Android/Studio/freeRDPCore/src/main/cpp/android_freerdp.c +++ b/client/Android/Studio/freeRDPCore/src/main/cpp/android_freerdp.c @@ -110,7 +110,6 @@ static BOOL android_begin_paint(rdpContext* context) static BOOL android_end_paint(rdpContext* context) { - int i; HGDI_WND hwnd; int ninvalid; rdpGdi* gdi; @@ -152,7 +151,7 @@ static BOOL android_end_paint(rdpContext* context) x2 = cinvalid[0].x + cinvalid[0].w; y2 = cinvalid[0].y + cinvalid[0].h; - for (i = 0; i < ninvalid; i++) + for (int i = 0; i < ninvalid; i++) { x1 = MIN(x1, cinvalid[i].x); y1 = MIN(y1, cinvalid[i].y); @@ -698,7 +697,7 @@ Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1parse_1arguments(JNIEn jobjectArray arguments) { freerdp* inst = (freerdp*)instance; - int i, count; + int count; char** argv; DWORD status; @@ -711,7 +710,7 @@ Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1parse_1arguments(JNIEn if (!argv) return JNI_TRUE; - for (i = 0; i < count; i++) + for (int i = 0; i < count; i++) { jstring str = (jstring)(*env)->GetObjectArrayElement(env, arguments, i); const char* raw = (*env)->GetStringUTFChars(env, str, 0); @@ -722,7 +721,7 @@ Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp_1parse_1arguments(JNIEn status = freerdp_client_settings_parse_command_line(inst->context->settings, count, argv, FALSE); - for (i = 0; i < count; i++) + for (int i = 0; i < count; i++) free(argv[i]); free(argv); diff --git a/client/Android/Studio/freeRDPCore/src/main/cpp/android_jni_utils.c b/client/Android/Studio/freeRDPCore/src/main/cpp/android_jni_utils.c index 996188239..929f6402a 100644 --- a/client/Android/Studio/freeRDPCore/src/main/cpp/android_jni_utils.c +++ b/client/Android/Studio/freeRDPCore/src/main/cpp/android_jni_utils.c @@ -112,7 +112,6 @@ jstring jniNewStringUTF(JNIEnv* env, const char* in, int len) jstring out = NULL; jchar* unicode = NULL; jint result_size = 0; - jint i; unsigned char* utf8 = (unsigned char*)in; if (!in) @@ -128,7 +127,7 @@ jstring jniNewStringUTF(JNIEnv* env, const char* in, int len) return NULL; } - for (i = 0; i < len; i++) + for (jint i = 0; i < len; i++) { unsigned char one = utf8[i]; switch (one >> 4) diff --git a/client/Mac/Clipboard.m b/client/Mac/Clipboard.m index 10ca0670f..eb35c0e0b 100644 --- a/client/Mac/Clipboard.m +++ b/client/Mac/Clipboard.m @@ -23,7 +23,6 @@ int mac_cliprdr_send_client_format_list(CliprdrClientContext *cliprdr) { - UINT32 index; UINT32 formatId; UINT32 numFormats; UINT32 *pFormatIds; @@ -43,7 +42,7 @@ int mac_cliprdr_send_client_format_list(CliprdrClientContext *cliprdr) if (!formats) return -1; - for (index = 0; index < numFormats; index++) + for (UINT32 index = 0; index < numFormats; index++) { formatId = pFormatIds[index]; formatName = ClipboardGetFormatName(mfc->clipboard, formatId); @@ -62,7 +61,7 @@ int mac_cliprdr_send_client_format_list(CliprdrClientContext *cliprdr) mfc->cliprdr->ClientFormatList(mfc->cliprdr, &formatList); - for (index = 0; index < numFormats; index++) + for (UINT32 index = 0; index < numFormats; index++) { free(formats[index].formatName); } @@ -151,11 +150,10 @@ static UINT mac_cliprdr_monitor_ready(CliprdrClientContext *cliprdr, static UINT mac_cliprdr_server_capabilities(CliprdrClientContext *cliprdr, const CLIPRDR_CAPABILITIES *capabilities) { - UINT32 index; CLIPRDR_CAPABILITY_SET *capabilitySet; mfContext *mfc = (mfContext *)cliprdr->custom; - for (index = 0; index < capabilities->cCapabilitiesSets; index++) + for (UINT32 index = 0; index < capabilities->cCapabilitiesSets; index++) { capabilitySet = &(capabilities->capabilitySets[index]); @@ -181,13 +179,12 @@ static UINT mac_cliprdr_server_capabilities(CliprdrClientContext *cliprdr, static UINT mac_cliprdr_server_format_list(CliprdrClientContext *cliprdr, const CLIPRDR_FORMAT_LIST *formatList) { - UINT32 index; CLIPRDR_FORMAT *format; mfContext *mfc = (mfContext *)cliprdr->custom; if (mfc->serverFormats) { - for (index = 0; index < mfc->numServerFormats; index++) + for (UINT32 index = 0; index < mfc->numServerFormats; index++) { free(mfc->serverFormats[index].formatName); } @@ -206,7 +203,7 @@ static UINT mac_cliprdr_server_format_list(CliprdrClientContext *cliprdr, if (!mfc->serverFormats) return CHANNEL_RC_NO_MEMORY; - for (index = 0; index < mfc->numServerFormats; index++) + for (UINT32 index = 0; index < mfc->numServerFormats; index++) { mfc->serverFormats[index].formatId = formatList->formats[index].formatId; mfc->serverFormats[index].formatName = NULL; @@ -217,7 +214,7 @@ static UINT mac_cliprdr_server_format_list(CliprdrClientContext *cliprdr, mac_cliprdr_send_client_format_list_response(cliprdr, TRUE); - for (index = 0; index < mfc->numServerFormats; index++) + for (UINT32 index = 0; index < mfc->numServerFormats; index++) { format = &(mfc->serverFormats[index]); diff --git a/client/Mac/MRDPView.m b/client/Mac/MRDPView.m index 0cbbc80e3..cba02f0ab 100644 --- a/client/Mac/MRDPView.m +++ b/client/Mac/MRDPView.m @@ -671,9 +671,7 @@ static BOOL releaseFlagStates(rdpInput *input, UINT32 aKbdModFlags) - (void)releaseResources { - int i; - - for (i = 0; i < argc; i++) + for (int i = 0; i < argc; i++) free(argv[i]); if (!is_connected) diff --git a/client/SDL/sdl_freerdp.cpp b/client/SDL/sdl_freerdp.cpp index b6d5facdb..c8b995a2f 100644 --- a/client/SDL/sdl_freerdp.cpp +++ b/client/SDL/sdl_freerdp.cpp @@ -209,8 +209,7 @@ static const struct sdl_exit_code_map_t sdl_exit_code_map[] = { static const struct sdl_exit_code_map_t* sdl_map_entry_by_code(int exit_code) { - size_t x = 0; - for (x = 0; x < ARRAYSIZE(sdl_exit_code_map); x++) + for (size_t x = 0; x < ARRAYSIZE(sdl_exit_code_map); x++) { const struct sdl_exit_code_map_t* cur = &sdl_exit_code_map[x]; if (cur->code == exit_code) @@ -221,8 +220,7 @@ static const struct sdl_exit_code_map_t* sdl_map_entry_by_code(int exit_code) static const struct sdl_exit_code_map_t* sdl_map_entry_by_error(DWORD error) { - size_t x = 0; - for (x = 0; x < ARRAYSIZE(sdl_exit_code_map); x++) + for (size_t x = 0; x < ARRAYSIZE(sdl_exit_code_map); x++) { const struct sdl_exit_code_map_t* cur = &sdl_exit_code_map[x]; if (cur->error == error) diff --git a/client/SDL/sdl_monitor.cpp b/client/SDL/sdl_monitor.cpp index 704cfd463..23b62ac7b 100644 --- a/client/SDL/sdl_monitor.cpp +++ b/client/SDL/sdl_monitor.cpp @@ -79,7 +79,6 @@ int sdl_list_monitors(SdlContext* sdl) static BOOL sdl_is_monitor_id_active(SdlContext* sdl, UINT32 id) { - UINT32 index = 0; const rdpSettings* settings = nullptr; WINPR_ASSERT(sdl); @@ -91,7 +90,7 @@ static BOOL sdl_is_monitor_id_active(SdlContext* sdl, UINT32 id) if (!NumMonitorIds) return TRUE; - for (index = 0; index < NumMonitorIds; index++) + for (UINT32 index = 0; index < NumMonitorIds; index++) { auto cur = static_cast( freerdp_settings_get_pointer_array(settings, FreeRDP_MonitorIds, index)); diff --git a/client/Wayland/wlf_cliprdr.c b/client/Wayland/wlf_cliprdr.c index 3f0ced89c..dc189d501 100644 --- a/client/Wayland/wlf_cliprdr.c +++ b/client/Wayland/wlf_cliprdr.c @@ -143,9 +143,7 @@ static BOOL wlf_mime_is_file(const char* mime) static BOOL wlf_mime_is_text(const char* mime) { - size_t x = 0; - - for (x = 0; x < ARRAYSIZE(mime_text); x++) + for (size_t x = 0; x < ARRAYSIZE(mime_text); x++) { if (strcmp(mime, mime_text[x]) == 0) return TRUE; @@ -156,9 +154,7 @@ static BOOL wlf_mime_is_text(const char* mime) static BOOL wlf_mime_is_image(const char* mime) { - size_t x = 0; - - for (x = 0; x < ARRAYSIZE(mime_image); x++) + for (size_t x = 0; x < ARRAYSIZE(mime_image); x++) { if (strcmp(mime, mime_image[x]) == 0) return TRUE; @@ -682,9 +678,7 @@ static UINT wlf_cliprdr_server_format_list(CliprdrClientContext* context, if (text) { - size_t x = 0; - - for (x = 0; x < ARRAYSIZE(mime_text); x++) + for (size_t x = 0; x < ARRAYSIZE(mime_text); x++) UwacClipboardOfferCreate(clipboard->seat, mime_text[x]); } diff --git a/client/Wayland/wlf_disp.c b/client/Wayland/wlf_disp.c index 67407e52e..0d8767581 100644 --- a/client/Wayland/wlf_disp.c +++ b/client/Wayland/wlf_disp.c @@ -290,7 +290,6 @@ UINT wlf_disp_sendLayout(DispClientContext* disp, const rdpMonitor* monitors, si { UINT ret = CHANNEL_RC_OK; DISPLAY_CONTROL_MONITOR_LAYOUT* layouts = NULL; - size_t i = 0; wlfDispContext* wlfDisp = NULL; rdpSettings* settings = NULL; @@ -310,7 +309,7 @@ UINT wlf_disp_sendLayout(DispClientContext* disp, const rdpMonitor* monitors, si if (!layouts) return CHANNEL_RC_NO_MEMORY; - for (i = 0; i < nmonitors; i++) + for (size_t i = 0; i < nmonitors; i++) { const rdpMonitor* monitor = &monitors[i]; DISPLAY_CONTROL_MONITOR_LAYOUT* layout = &layouts[i]; diff --git a/client/Wayland/wlf_input.c b/client/Wayland/wlf_input.c index 16c7886ce..60603db50 100644 --- a/client/Wayland/wlf_input.c +++ b/client/Wayland/wlf_input.c @@ -247,7 +247,6 @@ BOOL wlf_handle_pointer_frame(freerdp* instance, const UwacPointerFrameEvent* ev { BOOL success = TRUE; BOOL handle = FALSE; - size_t x = 0; wlfContext* context = NULL; enum wl_pointer_axis_source source = WL_POINTER_AXIS_SOURCE_CONTINUOUS; @@ -256,7 +255,7 @@ BOOL wlf_handle_pointer_frame(freerdp* instance, const UwacPointerFrameEvent* ev context = (wlfContext*)instance->context; - for (x = 0; x < ArrayList_Count(context->events); x++) + for (size_t x = 0; x < ArrayList_Count(context->events); x++) { UwacEvent* cev = ArrayList_GetItem(context->events, x); if (!cev) @@ -271,7 +270,7 @@ BOOL wlf_handle_pointer_frame(freerdp* instance, const UwacPointerFrameEvent* ev /* We need source events to determine how to interpret the data */ if (handle) { - for (x = 0; x < ArrayList_Count(context->events); x++) + for (size_t x = 0; x < ArrayList_Count(context->events); x++) { UwacEvent* cev = ArrayList_GetItem(context->events, x); if (!cev) diff --git a/client/Wayland/wlfreerdp.c b/client/Wayland/wlfreerdp.c index 5360ec008..037c999b5 100644 --- a/client/Wayland/wlfreerdp.c +++ b/client/Wayland/wlfreerdp.c @@ -750,7 +750,6 @@ BOOL wlf_copy_image(const void* src, size_t srcStride, size_t srcWidth, size_t s } else { - size_t i = 0; const size_t baseSrcOffset = area->top * srcStride + area->left * 4; const size_t baseDstOffset = area->top * dstStride + area->left * 4; const size_t width = MIN((size_t)area->right - area->left, dstWidth - area->left); @@ -758,7 +757,7 @@ BOOL wlf_copy_image(const void* src, size_t srcStride, size_t srcWidth, size_t s const BYTE* psrc = (const BYTE*)src; BYTE* pdst = (BYTE*)dst; - for (i = 0; i < height; i++) + for (size_t i = 0; i < height; i++) { const size_t srcOffset = i * srcStride + baseSrcOffset; const size_t dstOffset = i * dstStride + baseDstOffset; diff --git a/client/Windows/cli/wfreerdp.c b/client/Windows/cli/wfreerdp.c index c6283f979..d1e02e1fa 100644 --- a/client/Windows/cli/wfreerdp.c +++ b/client/Windows/cli/wfreerdp.c @@ -52,7 +52,7 @@ INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine char** argv = NULL; RDP_CLIENT_ENTRY_POINTS clientEntryPoints = { 0 }; int ret = 1; - int argc = 0, i; + int argc = 0; LPWSTR* args = NULL; WINPR_UNUSED(hInstance); @@ -81,7 +81,7 @@ INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine if (!argv) goto out; - for (i = 0; i < argc; i++) + for (int i = 0; i < argc; i++) { int size = WideCharToMultiByte(CP_UTF8, 0, args[i], -1, NULL, 0, NULL, NULL); if (size <= 0) @@ -134,7 +134,7 @@ out: if (argv) { - for (i = 0; i < argc; i++) + for (int i = 0; i < argc; i++) free(argv[i]); free(argv); diff --git a/client/Windows/wf_client.c b/client/Windows/wf_client.c index 1d7b5e8e4..8a86f1ba6 100644 --- a/client/Windows/wf_client.c +++ b/client/Windows/wf_client.c @@ -81,7 +81,6 @@ static BOOL wf_has_console(void) static BOOL wf_end_paint(rdpContext* context) { - int i; rdpGdi* gdi; int ninvalid; RECT updateRect; @@ -99,7 +98,7 @@ static BOOL wf_end_paint(rdpContext* context) region16_init(&invalidRegion); - for (i = 0; i < ninvalid; i++) + for (int i = 0; i < ninvalid; i++) { invalidRect.left = cinvalid[i].x; invalidRect.top = cinvalid[i].y; diff --git a/client/Windows/wf_cliprdr.c b/client/Windows/wf_cliprdr.c index ca7772668..be9318385 100644 --- a/client/Windows/wf_cliprdr.c +++ b/client/Windows/wf_cliprdr.c @@ -161,8 +161,7 @@ static void CliprdrStream_Delete(CliprdrStream* instance); static BOOL try_open_clipboard(HWND hwnd) { - size_t x; - for (x = 0; x < 10; x++) + for (size_t x = 0; x < 10; x++) { if (OpenClipboard(hwnd)) return TRUE; @@ -493,12 +492,10 @@ void CliprdrStream_Delete(CliprdrStream* instance) static LONG cliprdr_lookup_format(CliprdrDataObject* instance, FORMATETC* pFormatEtc) { - ULONG i; - if (!instance || !pFormatEtc) return -1; - for (i = 0; i < instance->m_nNumFormats; i++) + for (ULONG i = 0; i < instance->m_nNumFormats; i++) { if ((pFormatEtc->tymed & instance->m_pFormatEtc[i].tymed) && pFormatEtc->cfFormat == instance->m_pFormatEtc[i].cfFormat && @@ -564,7 +561,6 @@ static ULONG STDMETHODCALLTYPE CliprdrDataObject_Release(IDataObject* This) static HRESULT STDMETHODCALLTYPE CliprdrDataObject_GetData(IDataObject* This, FORMATETC* pFormatEtc, STGMEDIUM* pMedium) { - ULONG i; LONG idx; CliprdrDataObject* instance = (CliprdrDataObject*)This; wfClipboard* clipboard; @@ -607,7 +603,7 @@ static HRESULT STDMETHODCALLTYPE CliprdrDataObject_GetData(IDataObject* This, FO if (instance->m_pStream) { - for (i = 0; i < instance->m_nStreams; i++) + for (ULONG i = 0; i < instance->m_nStreams; i++) { instance->m_pStream[i] = (IStream*)CliprdrStream_New(i, clipboard, &dsc->fgd[i]); @@ -790,7 +786,7 @@ static CliprdrDataObject* CliprdrDataObject_New(FORMATETC* fmtetc, STGMEDIUM* st if (!instance->m_pStgMedium) goto error; - for (i = 0; i < count; i++) + for (ULONG i = 0; i < count; i++) { instance->m_pFormatEtc[i] = fmtetc[i]; instance->m_pStgMedium[i] = stgmed[i]; @@ -813,9 +809,7 @@ void CliprdrDataObject_Delete(CliprdrDataObject* instance) if (instance->m_pStream) { - ULONG i; - - for (i = 0; i < instance->m_nStreams; i++) + for (ULONG i = 0; i < instance->m_nStreams; i++) CliprdrStream_Release(instance->m_pStream[i]); free(instance->m_pStream); @@ -990,7 +984,6 @@ static HRESULT STDMETHODCALLTYPE CliprdrEnumFORMATETC_Clone(IEnumFORMATETC* This CliprdrEnumFORMATETC* CliprdrEnumFORMATETC_New(ULONG nFormats, FORMATETC* pFormatEtc) { - ULONG i; CliprdrEnumFORMATETC* instance; IEnumFORMATETC* iEnumFORMATETC; @@ -1026,7 +1019,7 @@ CliprdrEnumFORMATETC* CliprdrEnumFORMATETC_New(ULONG nFormats, FORMATETC* pForma if (!instance->m_pFormatEtc) goto error; - for (i = 0; i < nFormats; i++) + for (ULONG i = 0; i < nFormats; i++) cliprdr_format_deep_copy(&instance->m_pFormatEtc[i], &pFormatEtc[i]); } @@ -1038,15 +1031,13 @@ error: void CliprdrEnumFORMATETC_Delete(CliprdrEnumFORMATETC* instance) { - LONG i; - if (instance) { free(instance->iEnumFORMATETC.lpVtbl); if (instance->m_pFormatEtc) { - for (i = 0; i < instance->m_nNumFormats; i++) + for (LONG i = 0; i < instance->m_nNumFormats; i++) { if (instance->m_pFormatEtc[i].ptd) CoTaskMemFree(instance->m_pFormatEtc[i].ptd); @@ -1063,7 +1054,6 @@ void CliprdrEnumFORMATETC_Delete(CliprdrEnumFORMATETC* instance) static UINT32 get_local_format_id_by_name(wfClipboard* clipboard, const TCHAR* format_name) { - size_t i; formatMapping* map; WCHAR* unicode_name; #if !defined(UNICODE) @@ -1088,7 +1078,7 @@ static UINT32 get_local_format_id_by_name(wfClipboard* clipboard, const TCHAR* f if (!unicode_name) return 0; - for (i = 0; i < clipboard->map_size; i++) + for (size_t i = 0; i < clipboard->map_size; i++) { map = &clipboard->format_mappings[i]; @@ -1113,13 +1103,12 @@ static INLINE BOOL file_transferring(wfClipboard* clipboard) static UINT32 get_remote_format_id(wfClipboard* clipboard, UINT32 local_format) { - UINT32 i; formatMapping* map; if (!clipboard) return 0; - for (i = 0; i < clipboard->map_size; i++) + for (UINT32 i = 0; i < clipboard->map_size; i++) { map = &clipboard->format_mappings[i]; @@ -1153,7 +1142,6 @@ static void map_ensure_capacity(wfClipboard* clipboard) static BOOL clear_format_map(wfClipboard* clipboard) { - size_t i; formatMapping* map; if (!clipboard) @@ -1161,7 +1149,7 @@ static BOOL clear_format_map(wfClipboard* clipboard) if (clipboard->format_mappings) { - for (i = 0; i < clipboard->map_capacity; i++) + for (size_t i = 0; i < clipboard->map_capacity; i++) { map = &clipboard->format_mappings[i]; map->remote_format_id = 0; @@ -1227,7 +1215,6 @@ static UINT cliprdr_send_format_list(wfClipboard* clipboard) { UINT rc; int count = 0; - UINT32 index; UINT32 numFormats = 0; UINT32 formatId = 0; char formatName[1024]; @@ -1250,20 +1237,22 @@ static UINT cliprdr_send_format_list(wfClipboard* clipboard) return CHANNEL_RC_NO_MEMORY; } - index = 0; - - if (IsClipboardFormatAvailable(CF_HDROP)) { - formats[index++].formatId = RegisterClipboardFormat(CFSTR_FILEDESCRIPTORW); - formats[index++].formatId = RegisterClipboardFormat(CFSTR_FILECONTENTS); - } - else - { - while (formatId = EnumClipboardFormats(formatId)) - formats[index++].formatId = formatId; - } + UINT32 index = 0; - numFormats = index; + if (IsClipboardFormatAvailable(CF_HDROP)) + { + formats[index++].formatId = RegisterClipboardFormat(CFSTR_FILEDESCRIPTORW); + formats[index++].formatId = RegisterClipboardFormat(CFSTR_FILECONTENTS); + } + else + { + while (formatId = EnumClipboardFormats(formatId)) + formats[index++].formatId = formatId; + } + + numFormats = index; + } if (!CloseClipboard()) { @@ -1271,7 +1260,7 @@ static UINT cliprdr_send_format_list(wfClipboard* clipboard) return ERROR_INTERNAL_ERROR; } - for (index = 0; index < numFormats; index++) + for (UINT index = 0; index < numFormats; index++) { if (GetClipboardFormatNameA(formats[index].formatId, formatName, sizeof(formatName))) { @@ -1285,7 +1274,7 @@ static UINT cliprdr_send_format_list(wfClipboard* clipboard) formatList.common.msgType = CB_FORMAT_LIST; rc = clipboard->context->ClientFormatList(clipboard->context, &formatList); - for (index = 0; index < numFormats; index++) + for (UINT index = 0; index < numFormats; index++) free(formats[index].formatName); free(formats); @@ -1579,15 +1568,13 @@ static DWORD WINAPI cliprdr_thread_func(LPVOID arg) static void clear_file_array(wfClipboard* clipboard) { - size_t i; - if (!clipboard) return; /* clear file_names array */ if (clipboard->file_names) { - for (i = 0; i < clipboard->nFiles; i++) + for (size_t i = 0; i < clipboard->nFiles; i++) { free(clipboard->file_names[i]); clipboard->file_names[i] = NULL; @@ -1600,7 +1587,7 @@ static void clear_file_array(wfClipboard* clipboard) /* clear fileDescriptor array */ if (clipboard->fileDescriptor) { - for (i = 0; i < clipboard->nFiles; i++) + for (size_t i = 0; i < clipboard->nFiles; i++) { free(clipboard->fileDescriptor[i]); clipboard->fileDescriptor[i] = NULL; @@ -1853,14 +1840,13 @@ static UINT wf_cliprdr_monitor_ready(CliprdrClientContext* context, static UINT wf_cliprdr_server_capabilities(CliprdrClientContext* context, const CLIPRDR_CAPABILITIES* capabilities) { - UINT32 index; CLIPRDR_CAPABILITY_SET* capabilitySet; wfClipboard* clipboard = (wfClipboard*)context->custom; if (!context || !capabilities) return ERROR_INTERNAL_ERROR; - for (index = 0; index < capabilities->cCapabilitiesSets; index++) + for (UINT32 index = 0; index < capabilities->cCapabilitiesSets; index++) { capabilitySet = &(capabilities->capabilitySets[index]); @@ -1886,7 +1872,6 @@ static UINT wf_cliprdr_server_format_list(CliprdrClientContext* context, const CLIPRDR_FORMAT_LIST* formatList) { UINT rc = ERROR_INTERNAL_ERROR; - UINT32 i; formatMapping* mapping; CLIPRDR_FORMAT* format; wfClipboard* clipboard = (wfClipboard*)context->custom; @@ -1894,7 +1879,7 @@ static UINT wf_cliprdr_server_format_list(CliprdrClientContext* context, if (!clear_format_map(clipboard)) return ERROR_INTERNAL_ERROR; - for (i = 0; i < formatList->numFormats; i++) + for (UINT32 i = 0; i < formatList->numFormats; i++) { format = &(formatList->formats[i]); mapping = &(clipboard->format_mappings[i]); @@ -1929,7 +1914,7 @@ static UINT wf_cliprdr_server_format_list(CliprdrClientContext* context, if (EmptyClipboard()) { - for (i = 0; i < (UINT32)clipboard->map_size; i++) + for (UINT32 i = 0; i < (UINT32)clipboard->map_size; i++) SetClipboardData(clipboard->format_mappings[i].local_format_id, NULL); rc = CHANNEL_RC_OK; @@ -2052,8 +2037,6 @@ wf_cliprdr_server_format_data_request(CliprdrClientContext* context, if (requestedFormatId == RegisterClipboardFormat(CFSTR_FILEDESCRIPTORW)) { size_t len; - size_t i; - WCHAR* wFileName; HRESULT result; LPDATAOBJECT dataObj = NULL; FORMATETC format_etc = { 0 }; @@ -2093,7 +2076,7 @@ wf_cliprdr_server_format_data_request(CliprdrClientContext* context, if (dropFiles->fWide) { /* dropFiles contains file names */ - for (wFileName = (WCHAR*)((char*)dropFiles + dropFiles->pFiles); + for (WCHAR* wFileName = (WCHAR*)((char*)dropFiles + dropFiles->pFiles); (len = wcslen(wFileName)) > 0; wFileName += len + 1) { wf_cliprdr_process_filename(clipboard, wFileName, wcslen(wFileName)); @@ -2101,9 +2084,7 @@ wf_cliprdr_server_format_data_request(CliprdrClientContext* context, } else { - char* p; - - for (p = (char*)((char*)dropFiles + dropFiles->pFiles); (len = strlen(p)) > 0; + for (char* p = (char*)((char*)dropFiles + dropFiles->pFiles); (len = strlen(p)) > 0; p += len + 1, clipboard->nFiles++) { int cchWideChar; @@ -2125,7 +2106,7 @@ wf_cliprdr_server_format_data_request(CliprdrClientContext* context, { groupDsc->cItems = clipboard->nFiles; - for (i = 0; i < clipboard->nFiles; i++) + for (size_t i = 0; i < clipboard->nFiles; i++) { if (clipboard->fileDescriptor[i]) groupDsc->fgd[i] = *clipboard->fileDescriptor[i]; diff --git a/client/Windows/wf_floatbar.c b/client/Windows/wf_floatbar.c index ab5ad864b..f91047ce2 100644 --- a/client/Windows/wf_floatbar.c +++ b/client/Windows/wf_floatbar.c @@ -95,13 +95,12 @@ struct s_FloatBar static BOOL floatbar_kill_timers(wfFloatBar* floatbar) { - size_t x; UINT_PTR timers[] = { TIMER_HIDE, TIMER_ANIMAT_HIDE, TIMER_ANIMAT_SHOW }; if (!floatbar) return FALSE; - for (x = 0; x < ARRAYSIZE(timers); x++) + for (size_t x = 0; x < ARRAYSIZE(timers); x++) KillTimer(floatbar->hwnd, timers[x]); floatbar->animating = 0; @@ -324,11 +323,9 @@ static Button* floatbar_create_lock_button(wfFloatBar* const floatbar, const int static Button* floatbar_get_button(const wfFloatBar* const floatbar, const int x, const int y) { - int i; - if ((y > BUTTON_Y) && (y < BUTTON_Y + BUTTON_HEIGHT)) { - for (i = 0; i < BTN_MAX; i++) + for (int i = 0; i < BTN_MAX; i++) { if ((floatbar->buttons[i] != NULL) && (x > floatbar->buttons[i]->x) && (x < floatbar->buttons[i]->x + floatbar->buttons[i]->w)) @@ -343,7 +340,6 @@ static Button* floatbar_get_button(const wfFloatBar* const floatbar, const int x static BOOL floatbar_paint(wfFloatBar* const floatbar, const HDC hdc) { - int i; HPEN hpen; HGDIOBJECT orig; /* paint background */ @@ -389,7 +385,7 @@ static BOOL floatbar_paint(wfFloatBar* const floatbar, const HDC hdc) /* paint buttons */ - for (i = 0; i < BTN_MAX; i++) + for (int i = 0; i < BTN_MAX; i++) button_paint(floatbar->buttons[i], hdc); return TRUE; @@ -497,9 +493,7 @@ static LRESULT CALLBACK floatbar_proc(const HWND hWnd, const UINT Msg, const WPA } else { - int i; - - for (i = 0; i < BTN_MAX; i++) + for (int i = 0; i < BTN_MAX; i++) { if (floatbar->buttons[i] != NULL) { @@ -525,9 +519,7 @@ static LRESULT CALLBACK floatbar_proc(const HWND hWnd, const UINT Msg, const WPA case WM_MOUSELEAVE: { - int i; - - for (i = 0; i < BTN_MAX; i++) + for (int i = 0; i < BTN_MAX; i++) { if (floatbar->buttons[i] != NULL) { diff --git a/client/Windows/wf_gdi.c b/client/Windows/wf_gdi.c index c81aed806..bf7cbebd9 100644 --- a/client/Windows/wf_gdi.c +++ b/client/Windows/wf_gdi.c @@ -126,25 +126,18 @@ static void wf_glyph_free(wfBitmap* glyph) wf_image_free(glyph); } -static BYTE* wf_glyph_convert(wfContext* wfc, int width, int height, BYTE* data) +static BYTE* wf_glyph_convert(wfContext* wfc, int width, int height, const BYTE* data) { - int indexx; - int indexy; - BYTE* src; - BYTE* dst; - BYTE* cdata; - int src_bytes_per_row; - int dst_bytes_per_row; - src_bytes_per_row = (width + 7) / 8; - dst_bytes_per_row = src_bytes_per_row + (src_bytes_per_row % 2); - cdata = (BYTE*)malloc(dst_bytes_per_row * height); - src = data; + const int src_bytes_per_row = (width + 7) / 8; + const int dst_bytes_per_row = src_bytes_per_row + (src_bytes_per_row % 2); + BYTE* cdata = (BYTE*)malloc(dst_bytes_per_row * height); + const BYTE* src = data; - for (indexy = 0; indexy < height; indexy++) + for (int indexy = 0; indexy < height; indexy++) { - dst = cdata + indexy * dst_bytes_per_row; + BYTE* dst = cdata + indexy * dst_bytes_per_row; - for (indexx = 0; indexx < dst_bytes_per_row; indexx++) + for (int indexx = 0; indexx < dst_bytes_per_row; indexx++) { if (indexx < src_bytes_per_row) *dst++ = *src++; @@ -158,7 +151,6 @@ static BYTE* wf_glyph_convert(wfContext* wfc, int width, int height, BYTE* data) static HBRUSH wf_create_brush(wfContext* wfc, rdpBrush* brush, UINT32 color, UINT32 bpp) { - UINT32 i; HBRUSH br; LOGBRUSH lbr; BYTE* cdata; @@ -182,7 +174,7 @@ static HBRUSH wf_create_brush(wfContext* wfc, rdpBrush* brush, UINT32 color, UIN } else { - for (i = 0; i != 8; i++) + for (UINT32 i = 0; i != 8; i++) ipattern[7 - i] = brush->data[i]; cdata = wf_glyph_convert(wfc, 8, 8, ipattern); @@ -595,7 +587,6 @@ static BOOL wf_gdi_opaque_rect(rdpContext* context, const OPAQUE_RECT_ORDER* opa static BOOL wf_gdi_multi_opaque_rect(rdpContext* context, const MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect) { - UINT32 i; RECT rect; HBRUSH brush; COLORREF brush_color; @@ -607,7 +598,7 @@ static BOOL wf_gdi_multi_opaque_rect(rdpContext* context, if (!wf_decode_color(wfc, multi_opaque_rect->color, &brush_color, NULL)) return FALSE; - for (i = 0; i < multi_opaque_rect->numRectangles; i++) + for (UINT32 i = 0; i < multi_opaque_rect->numRectangles; i++) { const DELTA_RECT* rectangle = &multi_opaque_rect->rectangles[i]; rect.left = rectangle->left; @@ -684,13 +675,12 @@ static BOOL wf_gdi_polyline(rdpContext* context, const POLYLINE_ORDER* polyline) POINT* pts; POINT temp; int numPoints; - int i; numPoints = polyline->numDeltaEntries + 1; pts = (POINT*)malloc(sizeof(POINT) * numPoints); pts[0].x = temp.x = polyline->xStart; pts[0].y = temp.y = polyline->yStart; - for (i = 0; i < (int)polyline->numDeltaEntries; i++) + for (UINT32 i = 0; i < polyline->numDeltaEntries; i++) { temp.x += polyline->points[i].x; temp.y += polyline->points[i].y; diff --git a/client/Windows/wf_graphics.c b/client/Windows/wf_graphics.c index 58776d415..a60054a50 100644 --- a/client/Windows/wf_graphics.c +++ b/client/Windows/wf_graphics.c @@ -172,10 +172,9 @@ static BOOL wf_Bitmap_SetSurface(rdpContext* context, rdpBitmap* bitmap, BOOL pr static BOOL flip_bitmap(const BYTE* src, BYTE* dst, UINT32 scanline, UINT32 nHeight) { - UINT32 x; BYTE* bottomLine = dst + scanline * (nHeight - 1); - for (x = 0; x < nHeight; x++) + for (UINT32 x = 0; x < nHeight; x++) { memcpy(bottomLine, src, scanline); src += scanline; diff --git a/client/Windows/wf_rail.c b/client/Windows/wf_rail.c index 7cc639f73..6d185e3fc 100644 --- a/client/Windows/wf_rail.c +++ b/client/Windows/wf_rail.c @@ -111,10 +111,9 @@ static const WINDOW_STYLE EXTENDED_WINDOW_STYLES[] = { static void PrintWindowStyles(UINT32 style) { - int i; WLog_INFO(TAG, "\tWindow Styles:\t{"); - for (i = 0; i < ARRAYSIZE(WINDOW_STYLES); i++) + for (size_t i = 0; i < ARRAYSIZE(WINDOW_STYLES); i++) { if (style & WINDOW_STYLES[i].style) { @@ -131,10 +130,9 @@ static void PrintWindowStyles(UINT32 style) static void PrintExtendedWindowStyles(UINT32 style) { - int i; WLog_INFO(TAG, "\tExtended Window Styles:\t{"); - for (i = 0; i < ARRAYSIZE(EXTENDED_WINDOW_STYLES); i++) + for (size_t i = 0; i < ARRAYSIZE(EXTENDED_WINDOW_STYLES); i++) { if (style & EXTENDED_WINDOW_STYLES[i].style) { @@ -228,11 +226,10 @@ static void PrintRailWindowState(const WINDOW_ORDER_INFO* orderInfo, if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_RECTS) { - UINT32 index; RECTANGLE_16* rect; WLog_INFO(TAG, "\tnumWindowRects: %u", windowState->numWindowRects); - for (index = 0; index < windowState->numWindowRects; index++) + for (UINT32 index = 0; index < windowState->numWindowRects; index++) { rect = &windowState->windowRects[index]; WLog_INFO(TAG, "\twindowRect[%u]: left: %hu top: %hu right: %hu bottom: %hu", index, @@ -248,11 +245,10 @@ static void PrintRailWindowState(const WINDOW_ORDER_INFO* orderInfo, if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_VISIBILITY) { - UINT32 index; RECTANGLE_16* rect; WLog_INFO(TAG, "\tnumVisibilityRects: %u", windowState->numVisibilityRects); - for (index = 0; index < windowState->numVisibilityRects; index++) + for (UINT32 index = 0; index < windowState->numVisibilityRects; index++) { rect = &windowState->visibilityRects[index]; WLog_INFO(TAG, "\tvisibilityRect[%u]: left: %hu top: %hu right: %hu bottom: %hu", index, @@ -623,7 +619,6 @@ static BOOL wf_rail_window_common(rdpContext* context, const WINDOW_ORDER_INFO* if (fieldFlags & WINDOW_ORDER_FIELD_WND_RECTS) { - UINT32 index; HRGN hWndRect; HRGN hWndRects; RECTANGLE_16* rect; @@ -633,7 +628,7 @@ static BOOL wf_rail_window_common(rdpContext* context, const WINDOW_ORDER_INFO* rect = &(windowState->windowRects[0]); hWndRects = CreateRectRgn(rect->left, rect->top, rect->right, rect->bottom); - for (index = 1; index < windowState->numWindowRects; index++) + for (UINT32 index = 1; index < windowState->numWindowRects; index++) { rect = &(windowState->windowRects[index]); hWndRect = CreateRectRgn(rect->left, rect->top, rect->right, rect->bottom); @@ -936,8 +931,6 @@ static UINT wf_rail_server_get_appid_response(RailClientContext* context, void wf_rail_invalidate_region(wfContext* wfc, REGION16* invalidRegion) { - int index; - int count; RECT updateRect; RECTANGLE_16 windowRect; ULONG_PTR* pKeys = NULL; @@ -945,9 +938,9 @@ void wf_rail_invalidate_region(wfContext* wfc, REGION16* invalidRegion) const RECTANGLE_16* extents; REGION16 windowInvalidRegion; region16_init(&windowInvalidRegion); - count = HashTable_GetKeys(wfc->railWindows, &pKeys); + size_t count = HashTable_GetKeys(wfc->railWindows, &pKeys); - for (index = 0; index < count; index++) + for (size_t index = 0; index < count; index++) { railWindow = (wfRailWindow*)HashTable_GetItemValue(wfc->railWindows, (void*)pKeys[index]); diff --git a/client/X11/xf_client.c b/client/X11/xf_client.c index c346c506a..0f517457d 100644 --- a/client/X11/xf_client.c +++ b/client/X11/xf_client.c @@ -150,8 +150,7 @@ static void xf_teardown_x11(xfContext* xfc); static int xf_map_error_to_exit_code(DWORD error) { - size_t x = 0; - for (x = 0; x < ARRAYSIZE(xf_exit_code_map); x++) + for (size_t x = 0; x < ARRAYSIZE(xf_exit_code_map); x++) { const struct xf_exit_code_map_t* cur = &xf_exit_code_map[x]; if (cur->error == error) @@ -920,7 +919,6 @@ static void xf_get_x11_button_map(xfContext* xfc, unsigned char* x11_map) XExtensionVersion* version = NULL; XDeviceInfo* devices1 = NULL; XIDeviceInfo* devices2 = NULL; - int i = 0; int num_devices = 0; if (XQueryExtension(xfc->display, "XInputExtension", &opcode, &event, &error)) @@ -937,7 +935,7 @@ static void xf_get_x11_button_map(xfContext* xfc, unsigned char* x11_map) if (devices2) { - for (i = 0; i < num_devices; ++i) + for (int i = 0; i < num_devices; ++i) { if ((devices2[i].use == XISlavePointer) && (strncmp(devices2[i].name, TEST_PTR_STR, TEST_PTR_LEN) != 0)) @@ -958,7 +956,7 @@ static void xf_get_x11_button_map(xfContext* xfc, unsigned char* x11_map) if (devices1) { - for (i = 0; i < num_devices; ++i) + for (int i = 0; i < num_devices; ++i) { if ((devices1[i].use == IsXExtensionPointer) && (strncmp(devices1[i].name, TEST_PTR_STR, TEST_PTR_LEN) != 0)) @@ -1015,9 +1013,7 @@ static const button_map xf_button_flags[NUM_BUTTONS_MAPPED] = { static UINT16 get_flags_for_button(int button) { - size_t x = 0; - - for (x = 0; x < ARRAYSIZE(xf_button_flags); x++) + for (size_t x = 0; x < ARRAYSIZE(xf_button_flags); x++) { const button_map* map = &xf_button_flags[x]; @@ -1032,7 +1028,7 @@ static void xf_button_map_init(xfContext* xfc) { size_t pos = 0; /* loop counter for array initialization */ - size_t physical = 0; + /* logical mouse button which is used for each physical mouse */ /* button (indexed from zero). This is the default map. */ unsigned char x11_map[112] = { 0 }; @@ -1061,7 +1057,7 @@ static void xf_button_map_init(xfContext* xfc) /* iterate over all (mapped) physical buttons; for each of them */ /* find the logical button in X11, and assign to this the */ /* appropriate value to send over the RDP wire. */ - for (physical = 0; physical < ARRAYSIZE(x11_map); ++physical) + for (size_t physical = 0; physical < ARRAYSIZE(x11_map); ++physical) { const unsigned char logical = x11_map[physical]; const UINT16 flags = get_flags_for_button(logical); @@ -1777,10 +1773,9 @@ static int xfreerdp_client_start(rdpContext* context) static Atom get_supported_atom(xfContext* xfc, const char* atomName) { - unsigned long i = 0; const Atom atom = XInternAtom(xfc->display, atomName, False); - for (i = 0; i < xfc->supportedAtomCount; i++) + for (unsigned long i = 0; i < xfc->supportedAtomCount; i++) { if (xfc->supportedAtoms[i] == atom) return atom; diff --git a/client/X11/xf_cliprdr.c b/client/X11/xf_cliprdr.c index 60e270d77..bac21d378 100644 --- a/client/X11/xf_cliprdr.c +++ b/client/X11/xf_cliprdr.c @@ -443,7 +443,6 @@ static UINT xf_cliprdr_send_data_response(xfClipboard* clipboard, const xfCliprd static wStream* xf_cliprdr_serialize_server_format_list(xfClipboard* clipboard) { - UINT32 i = 0; UINT32 formatCount = 0; wStream* s = NULL; @@ -460,7 +459,7 @@ static wStream* xf_cliprdr_serialize_server_format_list(xfClipboard* clipboard) formatCount = (clipboard->numServerFormats > 0) ? clipboard->numServerFormats - 1 : 0; Stream_Write_UINT32(s, formatCount); - for (i = 0; i < formatCount; i++) + for (UINT32 i = 0; i < formatCount; i++) { CLIPRDR_FORMAT* format = &clipboard->serverFormats[i]; size_t name_length = format->formatName ? strlen(format->formatName) : 0; @@ -491,7 +490,6 @@ error: static CLIPRDR_FORMAT* xf_cliprdr_parse_server_format_list(BYTE* data, size_t length, UINT32* numFormats) { - UINT32 i = 0; wStream* s = NULL; CLIPRDR_FORMAT* formats = NULL; @@ -521,7 +519,7 @@ static CLIPRDR_FORMAT* xf_cliprdr_parse_server_format_list(BYTE* data, size_t le goto error; } - for (i = 0; i < *numFormats; i++) + for (UINT32 i = 0; i < *numFormats; i++) { const char* formatName = NULL; size_t formatNameLength = 0; @@ -555,11 +553,9 @@ error: static void xf_cliprdr_free_formats(CLIPRDR_FORMAT* formats, UINT32 numFormats) { - UINT32 i = 0; - WINPR_ASSERT(formats || (numFormats == 0)); - for (i = 0; i < numFormats; i++) + for (UINT32 i = 0; i < numFormats; i++) { free(formats[i].formatName); } @@ -729,20 +725,17 @@ static BOOL xf_clipboard_format_equal(const CLIPRDR_FORMAT* a, const CLIPRDR_FOR static BOOL xf_clipboard_changed(xfClipboard* clipboard, const CLIPRDR_FORMAT* formats, UINT32 numFormats) { - UINT32 x = 0; - UINT32 y = 0; - WINPR_ASSERT(clipboard); WINPR_ASSERT(formats || (numFormats == 0)); if (clipboard->lastSentNumFormats != numFormats) return TRUE; - for (x = 0; x < numFormats; x++) + for (UINT32 x = 0; x < numFormats; x++) { const CLIPRDR_FORMAT* cur = &clipboard->lastSentFormats[x]; BOOL contained = FALSE; - for (y = 0; y < numFormats; y++) + for (UINT32 y = 0; y < numFormats; y++) { if (xf_clipboard_format_equal(cur, &formats[y])) { @@ -769,8 +762,6 @@ static void xf_clipboard_formats_free(xfClipboard* clipboard) static BOOL xf_clipboard_copy_formats(xfClipboard* clipboard, const CLIPRDR_FORMAT* formats, UINT32 numFormats) { - UINT32 x = 0; - WINPR_ASSERT(clipboard); WINPR_ASSERT(formats || (numFormats == 0)); @@ -779,7 +770,7 @@ static BOOL xf_clipboard_copy_formats(xfClipboard* clipboard, const CLIPRDR_FORM if (!clipboard->lastSentFormats) return FALSE; clipboard->lastSentNumFormats = numFormats; - for (x = 0; x < numFormats; x++) + for (UINT32 x = 0; x < numFormats; x++) { CLIPRDR_FORMAT* lcur = &clipboard->lastSentFormats[x]; const CLIPRDR_FORMAT* cur = &formats[x]; @@ -1752,7 +1743,6 @@ static UINT xf_cliprdr_monitor_ready(CliprdrClientContext* context, static UINT xf_cliprdr_server_capabilities(CliprdrClientContext* context, const CLIPRDR_CAPABILITIES* capabilities) { - UINT32 i = 0; const CLIPRDR_GENERAL_CAPABILITY_SET* generalCaps = NULL; const BYTE* capsPtr = NULL; xfClipboard* clipboard = NULL; @@ -1768,7 +1758,7 @@ static UINT xf_cliprdr_server_capabilities(CliprdrClientContext* context, cliprdr_file_context_remote_set_flags(clipboard->file, 0); - for (i = 0; i < capabilities->cCapabilitiesSets; i++) + for (UINT32 i = 0; i < capabilities->cCapabilitiesSets; i++) { const CLIPRDR_CAPABILITY_SET* caps = (const CLIPRDR_CAPABILITY_SET*)capsPtr; @@ -1879,9 +1869,7 @@ static UINT xf_cliprdr_server_format_list(CliprdrClientContext* context, if (!srvFormat->formatName) { - UINT32 k = 0; - - for (k = 0; k < i; k++) + for (UINT32 k = 0; k < i; k++) free(clipboard->serverFormats[k].formatName); clipboard->numServerFormats = 0; @@ -2224,8 +2212,6 @@ xf_cliprdr_server_format_data_response(CliprdrClientContext* context, static BOOL xf_cliprdr_is_valid_unix_filename(LPCWSTR filename) { - LPCWSTR c = NULL; - if (!filename) return FALSE; @@ -2233,7 +2219,7 @@ static BOOL xf_cliprdr_is_valid_unix_filename(LPCWSTR filename) return FALSE; /* Reserved characters */ - for (c = filename; *c; ++c) + for (const WCHAR* c = filename; *c; ++c) { if (*c == L'/') return FALSE; diff --git a/client/X11/xf_disp.c b/client/X11/xf_disp.c index 24b8453b9..f7be11873 100644 --- a/client/X11/xf_disp.c +++ b/client/X11/xf_disp.c @@ -356,7 +356,6 @@ void xf_disp_free(xfDispContext* disp) UINT xf_disp_sendLayout(DispClientContext* disp, const rdpMonitor* monitors, UINT32 nmonitors) { UINT ret = CHANNEL_RC_OK; - UINT32 i = 0; xfDispContext* xfDisp = NULL; rdpSettings* settings = NULL; DISPLAY_CONTROL_MONITOR_LAYOUT* layouts = NULL; @@ -377,7 +376,7 @@ UINT xf_disp_sendLayout(DispClientContext* disp, const rdpMonitor* monitors, UIN if (!layouts) return CHANNEL_RC_NO_MEMORY; - for (i = 0; i < nmonitors; i++) + for (UINT32 i = 0; i < nmonitors; i++) { const rdpMonitor* monitor = &monitors[i]; DISPLAY_CONTROL_MONITOR_LAYOUT* layout = &layouts[i]; diff --git a/client/X11/xf_event.c b/client/X11/xf_event.c index fbb93a302..6bc4c4daf 100644 --- a/client/X11/xf_event.c +++ b/client/X11/xf_event.c @@ -225,7 +225,6 @@ void xf_event_action_script_free(xfContext* xfc) static BOOL xf_event_execute_action_script(xfContext* xfc, const XEvent* event) { - int index = 0; int count = 0; char* name = NULL; FILE* actionScript = NULL; @@ -244,7 +243,7 @@ static BOOL xf_event_execute_action_script(xfContext* xfc, const XEvent* event) xeventName = x11_event_string(event->type); count = ArrayList_Count(xfc->xevents); - for (index = 0; index < count; index++) + for (int index = 0; index < count; index++) { name = (char*)ArrayList_GetItem(xfc->xevents, index); @@ -916,7 +915,6 @@ static BOOL xf_event_PropertyNotify(xfContext* xfc, const XPropertyEvent* event, if ((((Atom)event->atom == xfc->_NET_WM_STATE) && (event->state != PropertyDelete)) || (((Atom)event->atom == xfc->WM_STATE) && (event->state != PropertyDelete))) { - unsigned long i = 0; BOOL status = FALSE; BOOL minimized = FALSE; BOOL minimizedChanged = FALSE; @@ -945,7 +943,7 @@ static BOOL xf_event_PropertyNotify(xfContext* xfc, const XPropertyEvent* event, appWindow->maxVert = FALSE; appWindow->maxHorz = FALSE; } - for (i = 0; i < nitems; i++) + for (unsigned long i = 0; i < nitems; i++) { if ((Atom)((UINT16**)prop)[i] == XInternAtom(xfc->display, "_NET_WM_STATE_MAXIMIZED_VERT", False)) @@ -1266,12 +1264,11 @@ BOOL xf_event_process(freerdp* instance, const XEvent* event) BOOL xf_generic_RawButtonEvent(xfContext* xfc, int button, BOOL app, BOOL down) { UINT16 flags = 0; - size_t i = 0; if (app) return FALSE; - for (i = 0; i < ARRAYSIZE(xfc->button_map); i++) + for (size_t i = 0; i < ARRAYSIZE(xfc->button_map); i++) { const button_map* cur = &xfc->button_map[i]; diff --git a/client/X11/xf_floatbar.c b/client/X11/xf_floatbar.c index 2d6122720..e4e290a12 100644 --- a/client/X11/xf_floatbar.c +++ b/client/X11/xf_floatbar.c @@ -222,7 +222,6 @@ static BOOL create_floatbar(xfFloatbar* floatbar) BOOL xf_floatbar_toggle_fullscreen(xfFloatbar* floatbar, bool fullscreen) { - int i = 0; int size = 0; bool visible = False; xfContext* xfc = NULL; @@ -250,7 +249,7 @@ BOOL xf_floatbar_toggle_fullscreen(xfFloatbar* floatbar, bool fullscreen) XMapWindow(xfc->display, floatbar->handle); size = ARRAYSIZE(floatbar->buttons); - for (i = 0; i < size; i++) + for (int i = 0; i < size; i++) { xfFloatbarButton* button = floatbar->buttons[i]; XMapWindow(xfc->display, button->handle); @@ -898,7 +897,6 @@ static void xf_floatbar_button_free(xfContext* xfc, xfFloatbarButton* button) void xf_floatbar_free(xfFloatbar* floatbar) { - size_t i = 0; size_t size = 0; xfContext* xfc = NULL; @@ -911,7 +909,7 @@ void xf_floatbar_free(xfFloatbar* floatbar) size = ARRAYSIZE(floatbar->buttons); - for (i = 0; i < size; i++) + for (size_t i = 0; i < size; i++) { xf_floatbar_button_free(xfc, floatbar->buttons[i]); floatbar->buttons[i] = NULL; diff --git a/client/X11/xf_gfx.c b/client/X11/xf_gfx.c index a6a502bb7..757b424e7 100644 --- a/client/X11/xf_gfx.c +++ b/client/X11/xf_gfx.c @@ -40,7 +40,6 @@ static UINT xf_OutputUpdate(xfContext* xfc, xfGfxSurface* surface) rdpGdi* gdi = NULL; const rdpSettings* settings = NULL; UINT32 nbRects = 0; - UINT32 x = 0; double sx = NAN; double sy = NAN; const RECTANGLE_16* rects = NULL; @@ -71,7 +70,7 @@ static UINT xf_OutputUpdate(xfContext* xfc, xfGfxSurface* surface) if (!(rects = region16_rects(&surface->gdi.invalidRegion, &nbRects))) return CHANNEL_RC_OK; - for (x = 0; x < nbRects; x++) + for (UINT32 x = 0; x < nbRects; x++) { const RECTANGLE_16* rect = &rects[x]; const UINT32 nXSrc = rect->left; @@ -134,7 +133,6 @@ static UINT xf_WindowUpdate(RdpgfxClientContext* context, xfGfxSurface* surface) static UINT xf_UpdateSurfaces(RdpgfxClientContext* context) { UINT16 count = 0; - UINT32 index = 0; UINT status = CHANNEL_RC_OK; UINT16* pSurfaceIds = NULL; rdpGdi* gdi = (rdpGdi*)context->custom; @@ -150,7 +148,7 @@ static UINT xf_UpdateSurfaces(RdpgfxClientContext* context) EnterCriticalSection(&context->mux); context->GetSurfaceIds(context, &pSurfaceIds, &count); - for (index = 0; index < count; index++) + for (UINT32 index = 0; index < count; index++) { xfGfxSurface* surface = (xfGfxSurface*)context->GetSurfaceData(context, pSurfaceIds[index]); @@ -181,7 +179,6 @@ static UINT xf_UpdateSurfaces(RdpgfxClientContext* context) UINT xf_OutputExpose(xfContext* xfc, UINT32 x, UINT32 y, UINT32 width, UINT32 height) { UINT16 count = 0; - UINT32 index = 0; UINT status = ERROR_INTERNAL_ERROR; RECTANGLE_16 invalidRect = { 0 }; RECTANGLE_16 intersection = { 0 }; @@ -208,7 +205,7 @@ UINT xf_OutputExpose(xfContext* xfc, UINT32 x, UINT32 y, UINT32 width, UINT32 he free(pSurfaceIds); return CHANNEL_RC_OK; } - for (index = 0; index < count; index++) + for (UINT32 index = 0; index < count; index++) { RECTANGLE_16 surfaceRect = { 0 }; xfGfxSurface* surface = (xfGfxSurface*)context->GetSurfaceData(context, pSurfaceIds[index]); diff --git a/client/X11/xf_graphics.c b/client/X11/xf_graphics.c index 458947c60..10b0eb588 100644 --- a/client/X11/xf_graphics.c +++ b/client/X11/xf_graphics.c @@ -330,7 +330,6 @@ static void xf_Pointer_Free(rdpContext* context, rdpPointer* pointer) WLog_DBG(TAG, "%p", pointer); #ifdef WITH_XCURSOR - UINT32 i = 0; xfContext* xfc = (xfContext*)context; xfPointer* xpointer = (xfPointer*)pointer; @@ -340,7 +339,7 @@ static void xf_Pointer_Free(rdpContext* context, rdpPointer* pointer) free(xpointer->cursorWidths); free(xpointer->cursorHeights); - for (i = 0; i < xpointer->nCursors; i++) + for (UINT32 i = 0; i < xpointer->nCursors; i++) { XFreeCursor(xfc->display, xpointer->cursors[i]); } diff --git a/client/X11/xf_input.c b/client/X11/xf_input.c index fd751d2d0..f1cdc836a 100644 --- a/client/X11/xf_input.c +++ b/client/X11/xf_input.c @@ -485,10 +485,8 @@ static void xf_input_detect_pinch(xfContext* xfc) static void xf_input_touch_begin(xfContext* xfc, const XIDeviceEvent* event) { - int i = 0; - WINPR_UNUSED(xfc); - for (i = 0; i < MAX_CONTACTS; i++) + for (int i = 0; i < MAX_CONTACTS; i++) { if (xfc->contacts[i].id == 0) { @@ -504,12 +502,10 @@ static void xf_input_touch_begin(xfContext* xfc, const XIDeviceEvent* event) static void xf_input_touch_update(xfContext* xfc, const XIDeviceEvent* event) { - int i = 0; - WINPR_ASSERT(xfc); WINPR_ASSERT(event); - for (i = 0; i < MAX_CONTACTS; i++) + for (int i = 0; i < MAX_CONTACTS; i++) { if (xfc->contacts[i].id == event->detail) { @@ -527,10 +523,8 @@ static void xf_input_touch_update(xfContext* xfc, const XIDeviceEvent* event) static void xf_input_touch_end(xfContext* xfc, const XIDeviceEvent* event) { - int i = 0; - WINPR_UNUSED(xfc); - for (i = 0; i < MAX_CONTACTS; i++) + for (int i = 0; i < MAX_CONTACTS; i++) { if (xfc->contacts[i].id == event->detail) { diff --git a/client/X11/xf_monitor.c b/client/X11/xf_monitor.c index 392717c7f..d872a4cbd 100644 --- a/client/X11/xf_monitor.c +++ b/client/X11/xf_monitor.c @@ -58,7 +58,6 @@ int xf_list_monitors(xfContext* xfc) Display* display = NULL; int major = 0; int minor = 0; - int i = 0; int nmonitors = 0; display = XOpenDisplay(NULL); @@ -76,7 +75,7 @@ int xf_list_monitors(xfContext* xfc) XRRMonitorInfo* monitors = XRRGetMonitors(display, DefaultRootWindow(display), 1, &nmonitors); - for (i = 0; i < nmonitors; i++) + for (int i = 0; i < nmonitors; i++) { printf(" %s [%d] %dx%d\t+%d+%d\n", monitors[i].primary ? "*" : " ", i, monitors[i].width, monitors[i].height, monitors[i].x, monitors[i].y); @@ -93,7 +92,7 @@ int xf_list_monitors(xfContext* xfc) { XineramaScreenInfo* screen = XineramaQueryScreens(display, &nmonitors); - for (i = 0; i < nmonitors; i++) + for (int i = 0; i < nmonitors; i++) { printf(" %s [%d] %hdx%hd\t+%hd+%hd\n", (i == 0) ? "*" : " ", i, screen[i].width, screen[i].height, screen[i].x_org, screen[i].y_org); @@ -116,7 +115,6 @@ int xf_list_monitors(xfContext* xfc) static BOOL xf_is_monitor_id_active(xfContext* xfc, UINT32 id) { - UINT32 index = 0; const rdpSettings* settings = NULL; WINPR_ASSERT(xfc); @@ -128,7 +126,7 @@ static BOOL xf_is_monitor_id_active(xfContext* xfc, UINT32 id) if (NumMonitorIds == 0) return TRUE; - for (index = 0; index < NumMonitorIds; index++) + for (UINT32 index = 0; index < NumMonitorIds; index++) { const UINT32* cur = freerdp_settings_get_pointer_array(settings, FreeRDP_MonitorIds, index); if (cur && (*cur == id)) @@ -196,9 +194,7 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight) if (vscreen->nmonitors) { - int i = 0; - - for (i = 0; i < vscreen->nmonitors; i++) + for (int i = 0; i < vscreen->nmonitors; i++) { MONITOR_INFO* cur_vscreen = &vscreen->monitors[i]; const XRRMonitorInfo* cur_monitor = &rrmonitors[i]; @@ -224,9 +220,7 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight) if (vscreen->nmonitors) { - int i = 0; - - for (i = 0; i < vscreen->nmonitors; i++) + for (int i = 0; i < vscreen->nmonitors; i++) { MONITOR_INFO* monitor = &vscreen->monitors[i]; monitor->area.left = screenInfo[i].x_org; @@ -246,9 +240,7 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight) /* Determine which monitor that the mouse cursor is on */ if (vscreen->monitors) { - int i = 0; - - for (i = 0; i < vscreen->nmonitors; i++) + for (int i = 0; i < vscreen->nmonitors; i++) { const MONITOR_INFO* monitor = &vscreen->monitors[i]; diff --git a/client/X11/xf_rail.c b/client/X11/xf_rail.c index 853b3a536..7402bb291 100644 --- a/client/X11/xf_rail.c +++ b/client/X11/xf_rail.c @@ -592,11 +592,9 @@ static xfRailIconCache* RailIconCache_New(rdpSettings* settings) static void RailIconCache_Free(xfRailIconCache* cache) { - UINT32 i = 0; - if (cache) { - for (i = 0; i < cache->numCaches * cache->numCacheEntries; i++) + for (UINT32 i = 0; i < cache->numCaches * cache->numCacheEntries; i++) { free(cache->entries[i].data); } @@ -645,7 +643,6 @@ static BOOL convert_rail_icon(const ICON_INFO* iconInfo, xfRailIcon* railIcon) BYTE* argbPixels = NULL; BYTE* nextPixel = NULL; long* pixels = NULL; - int i = 0; int nelements = 0; argbPixels = calloc(1ull * iconInfo->width * iconInfo->height, 4); @@ -670,7 +667,7 @@ static BOOL convert_rail_icon(const ICON_INFO* iconInfo, xfRailIcon* railIcon) pixels[1] = iconInfo->height; nextPixel = argbPixels; - for (i = 2; i < nelements; i++) + for (int i = 2; i < nelements; i++) { pixels[i] = FreeRDPReadColor(nextPixel, PIXEL_FORMAT_BGRA32); nextPixel += 4; diff --git a/client/X11/xf_tsmf.c b/client/X11/xf_tsmf.c index 01154a0f0..1c5e5b36d 100644 --- a/client/X11/xf_tsmf.c +++ b/client/X11/xf_tsmf.c @@ -56,12 +56,10 @@ typedef struct xf_xv_context xfXvContext; static BOOL xf_tsmf_is_format_supported(xfXvContext* xv, UINT32 pixfmt) { - int i = 0; - if (!xv->xv_pixfmts) return FALSE; - for (i = 0; xv->xv_pixfmts[i]; i++) + for (int i = 0; xv->xv_pixfmts[i]; i++) { if (xv->xv_pixfmts[i] == pixfmt) return TRUE; @@ -72,7 +70,6 @@ static BOOL xf_tsmf_is_format_supported(xfXvContext* xv, UINT32 pixfmt) static int xf_tsmf_xv_video_frame_event(TsmfClientContext* tsmf, TSMF_VIDEO_FRAME_EVENT* event) { - int i = 0; int x = 0; int y = 0; UINT32 width = 0; @@ -122,7 +119,7 @@ static int xf_tsmf_xv_video_frame_event(TsmfClientContext* tsmf, TSMF_VIDEO_FRAM if (!xrects) return -1; - for (i = 0; i < numRects; i++) + for (int i = 0; i < numRects; i++) { x = event->x + event->visibleRects[i].left; y = event->y + event->visibleRects[i].top; @@ -232,7 +229,7 @@ static int xf_tsmf_xv_video_frame_event(TsmfClientContext* tsmf, TSMF_VIDEO_FRAM } else { - for (i = 0; i < event->frameHeight; i++) + for (int i = 0; i < event->frameHeight; i++) { CopyMemory(image->data + image->offsets[0] + i * image->pitches[0], event->frameData + i * event->frameWidth, event->frameWidth); @@ -263,7 +260,7 @@ static int xf_tsmf_xv_video_frame_event(TsmfClientContext* tsmf, TSMF_VIDEO_FRAM } else { - for (i = 0; i < event->frameHeight / 2; i++) + for (int i = 0; i < event->frameHeight / 2; i++) { CopyMemory(image->data + image->offsets[1] + i * image->pitches[1], data1 + i * event->frameWidth / 2, event->frameWidth / 2); @@ -309,7 +306,6 @@ static int xf_tsmf_xv_video_frame_event(TsmfClientContext* tsmf, TSMF_VIDEO_FRAM static int xf_tsmf_xv_init(xfContext* xfc, TsmfClientContext* tsmf) { int ret = 0; - unsigned int i = 0; unsigned int version = 0; unsigned int release = 0; unsigned int event_base = 0; @@ -360,7 +356,7 @@ static int xf_tsmf_xv_init(xfContext* xfc, TsmfClientContext* tsmf) return -1; } - for (i = 0; i < num_adaptors; i++) + for (unsigned int i = 0; i < num_adaptors; i++) { WLog_DBG(TAG, "adapter port %lu-%lu (%s)", ai[i].base_id, ai[i].base_id + ai[i].num_ports - 1, ai[i].name); @@ -381,7 +377,8 @@ static int xf_tsmf_xv_init(xfContext* xfc, TsmfClientContext* tsmf) attr = XvQueryPortAttributes(xfc->display, xv->xv_port, &ret); - for (i = 0; i < (unsigned int)ret; i++) + unsigned int i = 0; + for (; i < (unsigned int)ret; i++) { if (strcmp(attr[i].name, "XV_COLORKEY") == 0) { @@ -401,7 +398,7 @@ static int xf_tsmf_xv_init(xfContext* xfc, TsmfClientContext* tsmf) { xv->xv_pixfmts = (UINT32*)calloc((ret + 1), sizeof(UINT32)); - for (i = 0; i < (unsigned int)ret; i++) + for (unsigned int i = 0; i < (unsigned int)ret; i++) { xv->xv_pixfmts[i] = fo[i].id; WLog_DBG(TAG, "%c%c%c%c ", ((char*)(xv->xv_pixfmts + i))[0], diff --git a/client/X11/xf_window.c b/client/X11/xf_window.c index d0f65acf1..38eb3cdc8 100644 --- a/client/X11/xf_window.c +++ b/client/X11/xf_window.c @@ -127,7 +127,6 @@ static void xf_SetWindowTitleText(xfContext* xfc, Window window, const char* nam void xf_SendClientEvent(xfContext* xfc, Window window, Atom atom, unsigned int numArgs, ...) { XEvent xevent = { 0 }; - unsigned int i = 0; va_list argp; va_start(argp, numArgs); @@ -139,7 +138,7 @@ void xf_SendClientEvent(xfContext* xfc, Window window, Atom atom, unsigned int n xevent.xclient.message_type = atom; xevent.xclient.format = 32; - for (i = 0; i < numArgs; i++) + for (size_t i = 0; i < numArgs; i++) { xevent.xclient.data.l[i] = va_arg(argp, int); } @@ -158,7 +157,6 @@ void xf_SetWindowMinimized(xfContext* xfc, xfWindow* window) void xf_SetWindowFullscreen(xfContext* xfc, xfWindow* window, BOOL fullscreen) { - UINT32 i = 0; const rdpSettings* settings = NULL; int startX = 0; int startY = 0; @@ -210,7 +208,7 @@ void xf_SetWindowFullscreen(xfContext* xfc, xfWindow* window, BOOL fullscreen) startY = firstMonitor->y; /* Search all monitors to find the lowest startX and startY values */ - for (i = 0; i < freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount); i++) + for (size_t i = 0; i < freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount); i++) { const rdpMonitor* monitor = freerdp_settings_get_pointer_array(settings, FreeRDP_MonitorDefArray, i); @@ -1060,7 +1058,6 @@ void xf_ShowWindow(xfContext* xfc, xfAppWindow* appWindow, BYTE state) void xf_SetWindowRects(xfContext* xfc, xfAppWindow* appWindow, RECTANGLE_16* rects, int nrects) { - int i = 0; XRectangle* xrects = NULL; if (nrects < 1) @@ -1069,7 +1066,7 @@ void xf_SetWindowRects(xfContext* xfc, xfAppWindow* appWindow, RECTANGLE_16* rec #ifdef WITH_XEXT xrects = (XRectangle*)calloc(nrects, sizeof(XRectangle)); - for (i = 0; i < nrects; i++) + for (int i = 0; i < nrects; i++) { xrects[i].x = rects[i].left; xrects[i].y = rects[i].top; @@ -1086,7 +1083,6 @@ void xf_SetWindowRects(xfContext* xfc, xfAppWindow* appWindow, RECTANGLE_16* rec void xf_SetWindowVisibilityRects(xfContext* xfc, xfAppWindow* appWindow, UINT32 rectsOffsetX, UINT32 rectsOffsetY, RECTANGLE_16* rects, int nrects) { - int i = 0; XRectangle* xrects = NULL; if (nrects < 1) @@ -1095,7 +1091,7 @@ void xf_SetWindowVisibilityRects(xfContext* xfc, xfAppWindow* appWindow, UINT32 #ifdef WITH_XEXT xrects = (XRectangle*)calloc(nrects, sizeof(XRectangle)); - for (i = 0; i < nrects; i++) + for (int i = 0; i < nrects; i++) { xrects[i].x = rects[i].left; xrects[i].y = rects[i].top; @@ -1200,17 +1196,15 @@ void xf_DestroyWindow(xfContext* xfc, xfAppWindow* appWindow) xfAppWindow* xf_AppWindowFromX11Window(xfContext* xfc, Window wnd) { - size_t index = 0; - size_t count = 0; ULONG_PTR* pKeys = NULL; WINPR_ASSERT(xfc); if (!xfc->railWindows) return NULL; - count = HashTable_GetKeys(xfc->railWindows, &pKeys); + size_t count = HashTable_GetKeys(xfc->railWindows, &pKeys); - for (index = 0; index < count; index++) + for (size_t index = 0; index < count; index++) { xfAppWindow* appWindow = xf_rail_get_window(xfc, *(UINT64*)pKeys[index]); diff --git a/client/common/client.c b/client/common/client.c index 195a7447e..9d6ec0367 100644 --- a/client/common/client.c +++ b/client/common/client.c @@ -367,7 +367,6 @@ out: int freerdp_client_settings_parse_assistance_file(rdpSettings* settings, int argc, char* argv[]) { int status = 0; - int x = 0; int ret = -1; char* filename = NULL; char* password = NULL; @@ -378,7 +377,7 @@ int freerdp_client_settings_parse_assistance_file(rdpSettings* settings, int arg filename = argv[1]; - for (x = 2; x < argc; x++) + for (int x = 2; x < argc; x++) { const char* key = strstr(argv[x], "assistance:"); diff --git a/client/common/client_cliprdr_file.c b/client/common/client_cliprdr_file.c index e8a9125de..9b3ee22f6 100644 --- a/client/common/client_cliprdr_file.c +++ b/client/common/client_cliprdr_file.c @@ -1033,8 +1033,6 @@ static void cliprdr_file_fuse_readdir(fuse_req_t fuse_req, fuse_ino_t fuse_ino, size_t entry_size = 0; char* filename = NULL; char* buf = NULL; - off_t i = 0; - size_t j = 0; WINPR_ASSERT(file_context); @@ -1071,7 +1069,7 @@ static void cliprdr_file_fuse_readdir(fuse_req_t fuse_req, fuse_ino_t fuse_ino, } written_size = 0; - for (i = offset; i < 2; ++i) + for (off_t i = offset; i < 2; ++i) { if (i == 0) { @@ -1102,7 +1100,7 @@ static void cliprdr_file_fuse_readdir(fuse_req_t fuse_req, fuse_ino_t fuse_ino, written_size += entry_size; } - for (j = 0, i = 2; j < ArrayList_Count(fuse_file->children); ++j, ++i) + for (size_t j = 0, i = 2; j < ArrayList_Count(fuse_file->children); ++j, ++i) { if (i < offset) continue; diff --git a/client/common/cmdline.c b/client/common/cmdline.c index f87a2c214..2ce693be4 100644 --- a/client/common/cmdline.c +++ b/client/common/cmdline.c @@ -287,10 +287,9 @@ BOOL freerdp_client_print_buildconfig(void) static void freerdp_client_print_scancodes(void) { - DWORD x = 0; printf("RDP scancodes and their name for use with /kbd:remap\n"); - for (x = 0; x < UINT16_MAX; x++) + for (UINT32 x = 0; x < UINT16_MAX; x++) { const char* name = freerdp_keyboard_scancode_name(x); if (name) @@ -923,9 +922,8 @@ static BOOL parseSubOptions(rdpSettings* settings, const CmdLineSubOptions* opts const char* arg) { BOOL found = FALSE; - size_t xx = 0; - for (xx = 0; xx < count; xx++) + for (size_t xx = 0; xx < count; xx++) { const CmdLineSubOptions* opt = &opts[xx]; @@ -995,7 +993,6 @@ static int freerdp_client_command_line_post_filter(void* context, COMMAND_LINE_A ptr.p = CommandLineParseCommaSeparatedValuesEx("kerberos", arg->Value, &count); if (ptr.pc) { - size_t x = 0; const CmdLineSubOptions opts[] = { { "kdc-url:", FreeRDP_KerberosKdcUrl, CMDLINE_SUBOPTION_STRING, NULL }, { "start-time:", FreeRDP_KerberosStartTime, CMDLINE_SUBOPTION_STRING, NULL }, @@ -1008,7 +1005,7 @@ static int freerdp_client_command_line_post_filter(void* context, COMMAND_LINE_A { "pkcs11-module:", FreeRDP_Pkcs11Module, CMDLINE_SUBOPTION_STRING, NULL } }; - for (x = 1; x < count; x++) + for (size_t x = 1; x < count; x++) { const char* cur = ptr.pc[x]; if (!parseSubOptions(settings, opts, ARRAYSIZE(opts), cur)) @@ -1386,14 +1383,13 @@ BOOL freerdp_set_connection_type(rdpSettings* settings, UINT32 type) static UINT32 freerdp_get_keyboard_layout_for_type(const char* name, DWORD type) { size_t count = 0; - size_t x = 0; RDP_KEYBOARD_LAYOUT* layouts = freerdp_keyboard_get_layouts(RDP_KEYBOARD_LAYOUT_TYPE_STANDARD, &count); if (!layouts || (count == 0)) return FALSE; - for (x = 0; x < count; x++) + for (size_t x = 0; x < count; x++) { const RDP_KEYBOARD_LAYOUT* layout = &layouts[x]; if (option_equals(layout->name, name)) @@ -1408,11 +1404,10 @@ static UINT32 freerdp_get_keyboard_layout_for_type(const char* name, DWORD type) static UINT32 freerdp_map_keyboard_layout_name_to_id(const char* name) { - size_t x = 0; const UINT32 variants[] = { RDP_KEYBOARD_LAYOUT_TYPE_STANDARD, RDP_KEYBOARD_LAYOUT_TYPE_VARIANT, RDP_KEYBOARD_LAYOUT_TYPE_IME }; - for (x = 0; x < ARRAYSIZE(variants); x++) + for (size_t x = 0; x < ARRAYSIZE(variants); x++) { UINT32 rc = freerdp_get_keyboard_layout_for_type(name, variants[x]); if (rc > 0) @@ -1588,15 +1583,13 @@ int freerdp_client_settings_command_line_status_print(rdpSettings* settings, int static void freerdp_client_print_keyboard_type_list(const char* msg, DWORD type) { - - size_t x = 0; size_t count = 0; RDP_KEYBOARD_LAYOUT* layouts = NULL; layouts = freerdp_keyboard_get_layouts(type, &count); printf("\n%s\n", msg); - for (x = 0; x < count; x++) + for (size_t x = 0; x < count; x++) { const RDP_KEYBOARD_LAYOUT* layout = &layouts[x]; printf("0x%08" PRIX32 "\t%s\n", layout->code, layout->name); @@ -1892,7 +1885,6 @@ static BOOL parseSizeValue(const char* input, unsigned long* v1, unsigned long* static BOOL prepare_default_settings(rdpSettings* settings, COMMAND_LINE_ARGUMENT_A* args, BOOL rdp_file) { - size_t x = 0; const char* arguments[] = { "network", "gfx", "rfx", "bpp" }; WINPR_ASSERT(settings); WINPR_ASSERT(args); @@ -1900,7 +1892,7 @@ static BOOL prepare_default_settings(rdpSettings* settings, COMMAND_LINE_ARGUMEN if (rdp_file) return FALSE; - for (x = 0; x < ARRAYSIZE(arguments); x++) + for (size_t x = 0; x < ARRAYSIZE(arguments); x++) { const char* arg = arguments[x]; const COMMAND_LINE_ARGUMENT_A* p = CommandLineFindArgumentA(args, arg); @@ -2129,9 +2121,8 @@ static int parse_tls_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_ WINPR_ASSERT(arg); size_t count = 0; - size_t x = 0; char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count); - for (x = 0; x < count; x++) + for (size_t x = 0; x < count; x++) { COMMAND_LINE_ARGUMENT_A larg = *arg; larg.Value = ptr[x]; @@ -2942,9 +2933,8 @@ static int parse_clipboard_options(rdpSettings* settings, const COMMAND_LINE_ARG const char** pc; } ptr; size_t count = 0; - size_t x = 0; ptr.p = CommandLineParseCommaSeparatedValues(arg->Value, &count); - for (x = 0; (x < count) && (rc == 0); x++) + for (size_t x = 0; (x < count) && (rc == 0); x++) { const char* usesel = "use-selection:"; @@ -3109,13 +3099,12 @@ static int parse_sec_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT_ WINPR_ASSERT(arg); size_t count = 0; - size_t x = 0; char** ptr = CommandLineParseCommaSeparatedValues(arg->Value, &count); if (count == 0) return COMMAND_LINE_ERROR_UNEXPECTED_VALUE; FreeRDP_Settings_Keys_Bool singleOptionWithoutOnOff = FreeRDP_BOOL_UNUSED; - for (x = 0; x < count; x++) + for (size_t x = 0; x < count; x++) { const char* cur = ptr[x]; const PARSE_ON_OFF_RESULT bval = parse_on_off_option(cur); @@ -3229,9 +3218,8 @@ static int parse_cert_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT const char** pc; } ptr; size_t count = 0; - size_t x = 0; ptr.p = CommandLineParseCommaSeparatedValues(arg->Value, &count); - for (x = 0; (x < count) && (rc == 0); x++) + for (size_t x = 0; (x < count) && (rc == 0); x++) { const char deny[] = "deny"; const char ignore[] = "ignore"; @@ -3495,7 +3483,6 @@ static int parse_smartcard_logon_options(rdpSettings* settings, const COMMAND_LI ptr.p = CommandLineParseCommaSeparatedValuesEx("smartcard-logon", arg->Value, &count); if (ptr.pc) { - size_t x = 0; const CmdLineSubOptions opts[] = { { "cert:", FreeRDP_SmartcardCertificate, CMDLINE_SUBOPTION_FILE, setSmartcardEmulation }, @@ -3507,7 +3494,7 @@ static int parse_smartcard_logon_options(rdpSettings* settings, const COMMAND_LI { "container:", FreeRDP_ContainerName, CMDLINE_SUBOPTION_STRING, NULL } }; - for (x = 1; x < count; x++) + for (size_t x = 1; x < count; x++) { const char* cur = ptr.pc[x]; if (!parseSubOptions(settings, opts, ARRAYSIZE(opts), cur)) @@ -3526,7 +3513,6 @@ static int parse_tune_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT WINPR_ASSERT(settings); WINPR_ASSERT(arg); - size_t x = 0; size_t count = 0; union { @@ -3536,7 +3522,7 @@ static int parse_tune_options(rdpSettings* settings, const COMMAND_LINE_ARGUMENT ptr.p = CommandLineParseCommaSeparatedValuesEx("tune", arg->Value, &count); if (!ptr.pc) return COMMAND_LINE_ERROR; - for (x = 1; x < count; x++) + for (size_t x = 1; x < count; x++) { const char* cur = ptr.pc[x]; char* sep = strchr(cur, ':'); diff --git a/client/common/file.c b/client/common/file.c index 437ec7fc4..760c62e9a 100644 --- a/client/common/file.c +++ b/client/common/file.c @@ -1317,14 +1317,13 @@ BOOL freerdp_client_populate_rdp_file_from_settings(rdpFile* file, const rdpSett { size_t offset = 0; - UINT32 x = 0; UINT32 count = freerdp_settings_get_uint32(settings, FreeRDP_NumMonitorIds); const UINT32* MonitorIds = freerdp_settings_get_pointer(settings, FreeRDP_MonitorIds); /* String size: 10 char UINT32 max string length, 1 char separator, one element NULL */ size_t size = count * (10 + 1) + 1; char* str = calloc(size, sizeof(char)); - for (x = 0; x < count; x++) + for (UINT32 x = 0; x < count; x++) { int rc = _snprintf(&str[offset], size - offset, "%" PRIu32 ",", MonitorIds[x]); if (rc <= 0) @@ -1625,7 +1624,6 @@ size_t freerdp_client_write_rdp_file_buffer(const rdpFile* file, char* buffer, s static ADDIN_ARGV* rdp_file_to_args(const char* channel, const char* values) { size_t count = 0; - size_t x = 0; char** p = NULL; ADDIN_ARGV* args = freerdp_addin_argv_new(0, NULL); if (!args) @@ -1634,7 +1632,7 @@ static ADDIN_ARGV* rdp_file_to_args(const char* channel, const char* values) goto fail; p = CommandLineParseCommaSeparatedValues(values, &count); - for (x = 0; x < count; x++) + for (size_t x = 0; x < count; x++) { BOOL rc = 0; const char* val = p[x]; @@ -2423,7 +2421,6 @@ BOOL freerdp_client_populate_settings_from_rdp_file(const rdpFile* file, rdpSett if (~(size_t)file->SelectedMonitors) { size_t count = 0; - size_t x = 0; char** args = CommandLineParseCommaSeparatedValues(file->SelectedMonitors, &count); UINT32* list = NULL; @@ -2438,7 +2435,7 @@ BOOL freerdp_client_populate_settings_from_rdp_file(const rdpFile* file, rdpSett free(args); return FALSE; } - for (x = 0; x < count; x++) + for (size_t x = 0; x < count; x++) { unsigned long val = 0; errno = 0; @@ -2543,11 +2540,10 @@ BOOL freerdp_client_populate_settings_from_rdp_file(const rdpFile* file, rdpSett static rdpFileLine* freerdp_client_rdp_file_find_line_by_name(const rdpFile* file, const char* name) { - size_t index = 0; BOOL bFound = FALSE; rdpFileLine* line = NULL; - for (index = 0; index < file->lineCount; index++) + for (size_t index = 0; index < file->lineCount; index++) { line = &(file->lines[index]); @@ -2660,8 +2656,7 @@ void freerdp_client_rdp_file_free(rdpFile* file) { if (file->lineCount) { - size_t i = 0; - for (i = 0; i < file->lineCount; i++) + for (size_t i = 0; i < file->lineCount; i++) { free(file->lines[i].name); free(file->lines[i].sValue); diff --git a/client/common/test/TestClientChannels.c b/client/common/test/TestClientChannels.c index 0522a3cae..b15a7345f 100644 --- a/client/common/test/TestClientChannels.c +++ b/client/common/test/TestClientChannels.c @@ -8,9 +8,7 @@ int TestClientChannels(int argc, char* argv[]) { - int index = 0; DWORD dwFlags = 0; - FREERDP_ADDIN* pAddin = NULL; FREERDP_ADDIN** ppAddins = NULL; WINPR_UNUSED(argc); @@ -20,9 +18,9 @@ int TestClientChannels(int argc, char* argv[]) printf("Enumerate all\n"); ppAddins = freerdp_channels_list_addins(NULL, NULL, NULL, dwFlags); - for (index = 0; ppAddins[index] != NULL; index++) + for (size_t index = 0; ppAddins[index] != NULL; index++) { - pAddin = ppAddins[index]; + FREERDP_ADDIN* pAddin = ppAddins[index]; printf("Addin: Name: %s Subsystem: %s Type: %s\n", pAddin->cName, pAddin->cSubsystem, pAddin->cType); @@ -33,9 +31,9 @@ int TestClientChannels(int argc, char* argv[]) printf("Enumerate rdpsnd\n"); ppAddins = freerdp_channels_list_addins(RDPSND_CHANNEL_NAME, NULL, NULL, dwFlags); - for (index = 0; ppAddins[index] != NULL; index++) + for (size_t index = 0; ppAddins[index] != NULL; index++) { - pAddin = ppAddins[index]; + FREERDP_ADDIN* pAddin = ppAddins[index]; printf("Addin: Name: %s Subsystem: %s Type: %s\n", pAddin->cName, pAddin->cSubsystem, pAddin->cType); @@ -47,9 +45,9 @@ int TestClientChannels(int argc, char* argv[]) printf("Enumerate tsmf video\n"); ppAddins = freerdp_channels_list_addins("tsmf", NULL, "video", dwFlags); - for (index = 0; ppAddins[index] != NULL; index++) + for (size_t index = 0; ppAddins[index] != NULL; index++) { - pAddin = ppAddins[index]; + FREERDP_ADDIN* pAddin = ppAddins[index]; printf("Addin: Name: %s Subsystem: %s Type: %s\n", pAddin->cName, pAddin->cSubsystem, pAddin->cType); @@ -60,9 +58,9 @@ int TestClientChannels(int argc, char* argv[]) ppAddins = freerdp_channels_list_addins("unknown", NULL, NULL, dwFlags); - for (index = 0; ppAddins[index] != NULL; index++) + for (size_t index = 0; ppAddins[index] != NULL; index++) { - pAddin = ppAddins[index]; + FREERDP_ADDIN* pAddin = ppAddins[index]; printf("Addin: Name: %s Subsystem: %s Type: %s\n", pAddin->cName, pAddin->cSubsystem, pAddin->cType); @@ -75,9 +73,9 @@ int TestClientChannels(int argc, char* argv[]) dwFlags = FREERDP_ADDIN_STATIC; ppAddins = freerdp_channels_list_addins(NULL, NULL, NULL, dwFlags); - for (index = 0; ppAddins[index] != NULL; index++) + for (size_t index = 0; ppAddins[index] != NULL; index++) { - pAddin = ppAddins[index]; + FREERDP_ADDIN* pAddin = ppAddins[index]; printf("Addin: Name: %s Subsystem: %s Type: %s\n", pAddin->cName, pAddin->cSubsystem, pAddin->cType); diff --git a/client/common/test/TestClientCmdLine.c b/client/common/test/TestClientCmdLine.c index b580eb4ba..2ce0c472c 100644 --- a/client/common/test/TestClientCmdLine.c +++ b/client/common/test/TestClientCmdLine.c @@ -30,10 +30,9 @@ typedef BOOL (*validate_settings_pr)(rdpSettings* settings); static void print_test_title(int argc, char** argv) { - int i = 0; printf("Running test:"); - for (i = 0; i < argc; i++) + for (int i = 0; i < argc; i++) { printf(" %s", argv[i]); } @@ -212,10 +211,9 @@ static const test tests[] = { static void check_modified_arguments(const test* test, char** command_line, int* rc) { - int k = 0; const char* expected_argument = NULL; - for (k = 0; (expected_argument = test->modified_arguments[k].expected_value); k++) + for (int k = 0; (expected_argument = test->modified_arguments[k].expected_value); k++) { int index = test->modified_arguments[k].index; char* actual_argument = command_line[index]; @@ -234,11 +232,10 @@ static void check_modified_arguments(const test* test, char** command_line, int* int TestClientCmdLine(int argc, char* argv[]) { int rc = 0; - size_t i = 0; WINPR_UNUSED(argc); WINPR_UNUSED(argv); - for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) + for (size_t i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) { const test* current = &tests[i]; int failure = 0; diff --git a/client/common/test/TestClientRdpFile.c b/client/common/test/TestClientRdpFile.c index f8696229e..e631bc8d4 100644 --- a/client/common/test/TestClientRdpFile.c +++ b/client/common/test/TestClientRdpFile.c @@ -422,7 +422,6 @@ int TestClientRdpFile(int argc, char* argv[]) /* Check [MS-RDPECAM] related options */ #if defined(CHANNEL_RDPECAM_CLIENT) { - int x = 0; ADDIN_ARGV* args = NULL; iValue = freerdp_client_rdp_file_get_integer_option(file, "encode redirected video capture"); @@ -451,7 +450,7 @@ int TestClientRdpFile(int argc, char* argv[]) goto fail; } - for (x = 0; x < args->argc; x++) + for (int x = 0; x < args->argc; x++) { if (strcmp(args->argv[x], camera_args[x]) != 0) { @@ -465,7 +464,6 @@ int TestClientRdpFile(int argc, char* argv[]) /* Check [URBDRC] related options */ #if defined(CHANNEL_URBDRC_CLIENT) { - int x = 0; ADDIN_ARGV* args = freerdp_dynamic_channel_collection_find(settings, "urbdrc"); if (!args) { @@ -478,7 +476,7 @@ int TestClientRdpFile(int argc, char* argv[]) goto fail; } - for (x = 0; x < args->argc; x++) + for (int x = 0; x < args->argc; x++) { if (strcmp(args->argv[x], urbdrc_args[x]) != 0) { diff --git a/client/iOS/Additions/OrderedDictionary.m b/client/iOS/Additions/OrderedDictionary.m index e7081948e..9b3718634 100644 --- a/client/iOS/Additions/OrderedDictionary.m +++ b/client/iOS/Additions/OrderedDictionary.m @@ -146,8 +146,8 @@ NSString *DescriptionForObject(NSObject *object, id locale, NSUInteger indent) - (NSString *)descriptionWithLocale:(id)locale indent:(NSUInteger)level { NSMutableString *indentString = [NSMutableString string]; - NSUInteger i, count = level; - for (i = 0; i < count; i++) + NSUInteger count = level; + for (NSUInteger i = 0; i < count; i++) { [indentString appendFormat:@" "]; } diff --git a/client/iOS/Additions/TSXAdditions.m b/client/iOS/Additions/TSXAdditions.m index c0dc878e2..3d5f40ada 100644 --- a/client/iOS/Additions/TSXAdditions.m +++ b/client/iOS/Additions/TSXAdditions.m @@ -108,12 +108,11 @@ withSeparator:(NSString *)sep afterNthChar:(int)sepnth { - int i; NSMutableString *result; NSString *immutableResult; result = [[NSMutableString alloc] init]; - for (i = 0; i < size; i++) + for (int i = 0; i < size; i++) { if (i && sep && sepnth && i % sepnth == 0) [result appendString:sep]; diff --git a/client/iOS/FreeRDP/ios_cliprdr.m b/client/iOS/FreeRDP/ios_cliprdr.m index 7e86fc4f8..e5d5fdcc2 100644 --- a/client/iOS/FreeRDP/ios_cliprdr.m +++ b/client/iOS/FreeRDP/ios_cliprdr.m @@ -34,7 +34,6 @@ UINT ios_cliprdr_send_client_format_list(CliprdrClientContext *cliprdr) { UINT rc = ERROR_INTERNAL_ERROR; - UINT32 index; UINT32 formatId; UINT32 numFormats; UINT32 *pFormatIds; @@ -57,7 +56,7 @@ UINT ios_cliprdr_send_client_format_list(CliprdrClientContext *cliprdr) if (!formats) goto fail; - for (index = 0; index < numFormats; index++) + for (UINT32 index = 0; index < numFormats; index++) { formatId = pFormatIds[index]; formatName = ClipboardGetFormatName(afc->clipboard, formatId); @@ -167,7 +166,6 @@ static UINT ios_cliprdr_monitor_ready(CliprdrClientContext *cliprdr, static UINT ios_cliprdr_server_capabilities(CliprdrClientContext *cliprdr, const CLIPRDR_CAPABILITIES *capabilities) { - UINT32 index; CLIPRDR_CAPABILITY_SET *capabilitySet; mfContext *afc; @@ -179,7 +177,7 @@ static UINT ios_cliprdr_server_capabilities(CliprdrClientContext *cliprdr, if (!afc) return ERROR_INVALID_PARAMETER; - for (index = 0; index < capabilities->cCapabilitiesSets; index++) + for (UINT32 index = 0; index < capabilities->cCapabilitiesSets; index++) { capabilitySet = &(capabilities->capabilitySets[index]); @@ -205,7 +203,6 @@ static UINT ios_cliprdr_server_format_list(CliprdrClientContext *cliprdr, const CLIPRDR_FORMAT_LIST *formatList) { UINT rc; - UINT32 index; CLIPRDR_FORMAT *format; mfContext *afc; @@ -219,7 +216,7 @@ static UINT ios_cliprdr_server_format_list(CliprdrClientContext *cliprdr, if (afc->serverFormats) { - for (index = 0; index < afc->numServerFormats; index++) + for (UINT32 index = 0; index < afc->numServerFormats; index++) free(afc->serverFormats[index].formatName); free(afc->serverFormats); @@ -236,7 +233,7 @@ static UINT ios_cliprdr_server_format_list(CliprdrClientContext *cliprdr, if (!afc->serverFormats) return CHANNEL_RC_NO_MEMORY; - for (index = 0; index < afc->numServerFormats; index++) + for (UINT32 index = 0; index < afc->numServerFormats; index++) { afc->serverFormats[index].formatId = formatList->formats[index].formatId; afc->serverFormats[index].formatName = NULL; @@ -252,7 +249,7 @@ static UINT ios_cliprdr_server_format_list(CliprdrClientContext *cliprdr, BOOL unicode = FALSE; BOOL text = FALSE; - for (index = 0; index < afc->numServerFormats; index++) + for (UINT32 index = 0; index < afc->numServerFormats; index++) { format = &(afc->serverFormats[index]); @@ -368,7 +365,6 @@ ios_cliprdr_server_format_data_response(CliprdrClientContext *cliprdr, { BYTE *data; UINT32 size; - UINT32 index; UINT32 formatId; CLIPRDR_FORMAT *format = NULL; mfContext *afc; @@ -387,7 +383,7 @@ ios_cliprdr_server_format_data_response(CliprdrClientContext *cliprdr, if (!instance) return ERROR_INVALID_PARAMETER; - for (index = 0; index < afc->numServerFormats; index++) + for (UINT32 index = 0; index < afc->numServerFormats; index++) { if (afc->requestedFormatId == afc->serverFormats[index].formatId) format = &(afc->serverFormats[index]); diff --git a/client/iOS/Models/RDPSession.m b/client/iOS/Models/RDPSession.m index e7f34539c..1092af2dc 100644 --- a/client/iOS/Models/RDPSession.m +++ b/client/iOS/Models/RDPSession.m @@ -69,9 +69,7 @@ static BOOL addFlag(int *argc, char ***argv, const char *str, BOOL flag) static void freeArguments(int argc, char **argv) { - int i; - - for (i = 0; i < argc; i++) + for (int i = 0; i < argc; i++) free(argv[i]); free(argv); diff --git a/client/iOS/Views/TouchPointerView.m b/client/iOS/Views/TouchPointerView.m index 8bd76c8db..c299593f4 100644 --- a/client/iOS/Views/TouchPointerView.m +++ b/client/iOS/Views/TouchPointerView.m @@ -78,12 +78,11 @@ _pointer_scrolling = NO; // create areas array - int i, j; CGFloat area_width = [_cur_pointer_img size].width / 3.0f; CGFloat area_height = [_cur_pointer_img size].height / 3.0f; - for (i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { - for (j = 0; j < 3; j++) + for (int j = 0; j < 3; j++) { _pointer_areas[j + i * 3] = CGRectMake(j * area_width, i * area_height, area_width, area_height); diff --git a/include/freerdp/utils/pod_arrays.h b/include/freerdp/utils/pod_arrays.h index 30cff6bef..ef8667d24 100644 --- a/include/freerdp/utils/pod_arrays.h +++ b/include/freerdp/utils/pod_arrays.h @@ -90,9 +90,8 @@ extern "C" static INLINE BOOL array_##TLOWER##_contains(const Array##T* a, T v) \ { \ WINPR_ASSERT(a); \ - UINT32 i; \ \ - for (i = 0; i < a->nvalues; i++) \ + for (UINT32 i = 0; i < a->nvalues; i++) \ { \ if (memcmp(&a->values[i], &v, sizeof(T)) == 0) \ return TRUE; \ @@ -104,8 +103,7 @@ extern "C" static INLINE BOOL array_##TLOWER##_foreach(Array##T* a, Array##T##Cb cb, void* data) \ { \ WINPR_ASSERT(a); \ - size_t i; \ - for (i = 0; i < a->nvalues; i++) \ + for (size_t i = 0; i < a->nvalues; i++) \ { \ if (!cb(&a->values[i], data)) \ return FALSE; \ diff --git a/libfreerdp/cache/bitmap.c b/libfreerdp/cache/bitmap.c index 25070b8fc..dd5ae1d71 100644 --- a/libfreerdp/cache/bitmap.c +++ b/libfreerdp/cache/bitmap.c @@ -348,7 +348,6 @@ end: rdpBitmapCache* bitmap_cache_new(rdpContext* context) { - UINT32 i = 0; rdpSettings* settings = NULL; rdpBitmapCache* bitmapCache = NULL; @@ -371,7 +370,7 @@ rdpBitmapCache* bitmap_cache_new(rdpContext* context) goto fail; bitmapCache->maxCells = BitmapCacheV2NumCells; - for (i = 0; i < bitmapCache->maxCells; i++) + for (UINT32 i = 0; i < bitmapCache->maxCells; i++) { const BITMAP_CACHE_V2_CELL_INFO* info = freerdp_settings_get_pointer_array(settings, FreeRDP_BitmapCacheV2CellInfo, i); @@ -430,12 +429,10 @@ void bitmap_cache_free(rdpBitmapCache* bitmapCache) static void free_bitmap_data(BITMAP_DATA* data, size_t count) { - size_t x = 0; - if (!data) return; - for (x = 0; x < count; x++) + for (size_t x = 0; x < count; x++) free(data[x].bitmapDataStream); free(data); @@ -443,13 +440,12 @@ static void free_bitmap_data(BITMAP_DATA* data, size_t count) static BITMAP_DATA* copy_bitmap_data(const BITMAP_DATA* data, size_t count) { - size_t x = 0; BITMAP_DATA* dst = (BITMAP_DATA*)calloc(count, sizeof(BITMAP_DATA)); if (!dst) goto fail; - for (x = 0; x < count; x++) + for (size_t x = 0; x < count; x++) { dst[x] = data[x]; diff --git a/libfreerdp/cache/brush.c b/libfreerdp/cache/brush.c index 7463be35c..94900764c 100644 --- a/libfreerdp/cache/brush.c +++ b/libfreerdp/cache/brush.c @@ -279,13 +279,11 @@ fail: void brush_cache_free(rdpBrushCache* brushCache) { - size_t i = 0; - if (brushCache) { if (brushCache->entries) { - for (i = 0; i < brushCache->maxEntries; i++) + for (size_t i = 0; i < brushCache->maxEntries; i++) free(brushCache->entries[i].entry); free(brushCache->entries); @@ -293,7 +291,7 @@ void brush_cache_free(rdpBrushCache* brushCache) if (brushCache->monoEntries) { - for (i = 0; i < brushCache->maxMonoEntries; i++) + for (size_t i = 0; i < brushCache->maxMonoEntries; i++) free(brushCache->monoEntries[i].entry); free(brushCache->monoEntries); diff --git a/libfreerdp/cache/glyph.c b/libfreerdp/cache/glyph.c index bd672123d..ad394a9bc 100644 --- a/libfreerdp/cache/glyph.c +++ b/libfreerdp/cache/glyph.c @@ -138,7 +138,6 @@ static BOOL update_process_glyph_fragments(rdpContext* context, const BYTE* data INT32 opX, INT32 opY, INT32 opWidth, INT32 opHeight, BOOL fOpRedundant) { - UINT32 n = 0; UINT32 id = 0; UINT32 size = 0; UINT32 index = 0; @@ -251,7 +250,7 @@ static BOOL update_process_glyph_fragments(rdpContext* context, const BYTE* data if (fragments == NULL) return FALSE; - for (n = 0; n < size;) + for (size_t n = 0; n < size;) { const UINT32 fop = fragments[n++]; n = update_glyph_offset(fragments, size, n, &x, &y, ulCharInc, flAccel); @@ -492,7 +491,6 @@ static BOOL update_gdi_fast_glyph(rdpContext* context, const FAST_GLYPH_ORDER* f static BOOL update_gdi_cache_glyph(rdpContext* context, const CACHE_GLYPH_ORDER* cacheGlyph) { - UINT32 i = 0; rdpCache* cache = NULL; if (!context || !cacheGlyph || !context->cache) @@ -500,7 +498,7 @@ static BOOL update_gdi_cache_glyph(rdpContext* context, const CACHE_GLYPH_ORDER* cache = context->cache; - for (i = 0; i < cacheGlyph->cGlyphs; i++) + for (size_t i = 0; i < cacheGlyph->cGlyphs; i++) { const GLYPH_DATA* glyph_data = &cacheGlyph->glyphData[i]; rdpGlyph* glyph = NULL; @@ -524,7 +522,6 @@ static BOOL update_gdi_cache_glyph(rdpContext* context, const CACHE_GLYPH_ORDER* static BOOL update_gdi_cache_glyph_v2(rdpContext* context, const CACHE_GLYPH_V2_ORDER* cacheGlyphV2) { - UINT32 i = 0; rdpCache* cache = NULL; if (!context || !cacheGlyphV2 || !context->cache) @@ -532,7 +529,7 @@ static BOOL update_gdi_cache_glyph_v2(rdpContext* context, const CACHE_GLYPH_V2_ cache = context->cache; - for (i = 0; i < cacheGlyphV2->cGlyphs; i++) + for (size_t i = 0; i < cacheGlyphV2->cGlyphs; i++) { const GLYPH_DATA_V2* glyphData = &cacheGlyphV2->glyphData[i]; rdpGlyph* glyph = NULL; @@ -693,7 +690,6 @@ void glyph_cache_register_callbacks(rdpUpdate* update) rdpGlyphCache* glyph_cache_new(rdpContext* context) { - size_t i = 0; rdpGlyphCache* glyphCache = NULL; rdpSettings* settings = NULL; @@ -710,7 +706,7 @@ rdpGlyphCache* glyph_cache_new(rdpContext* context) glyphCache->log = WLog_Get("com.freerdp.cache.glyph"); glyphCache->context = context; - for (i = 0; i < 10; i++) + for (size_t i = 0; i < 10; i++) { const GLYPH_CACHE_DEFINITION* currentGlyph = freerdp_settings_get_pointer_array(settings, FreeRDP_GlyphCache, i); @@ -736,18 +732,16 @@ void glyph_cache_free(rdpGlyphCache* glyphCache) { if (glyphCache) { - size_t i = 0; GLYPH_CACHE* cache = glyphCache->glyphCache; - for (i = 0; i < 10; i++) + for (size_t i = 0; i < 10; i++) { - UINT32 j = 0; rdpGlyph** entries = cache[i].entries; if (!entries) continue; - for (j = 0; j < cache[i].number; j++) + for (size_t j = 0; j < cache[i].number; j++) { rdpGlyph* glyph = entries[j]; @@ -762,7 +756,7 @@ void glyph_cache_free(rdpGlyphCache* glyphCache) cache[i].entries = NULL; } - for (i = 0; i < ARRAYSIZE(glyphCache->fragCache.entries); i++) + for (size_t i = 0; i < ARRAYSIZE(glyphCache->fragCache.entries); i++) { free(glyphCache->fragCache.entries[i].fragment); glyphCache->fragCache.entries[i].fragment = NULL; @@ -774,7 +768,6 @@ void glyph_cache_free(rdpGlyphCache* glyphCache) CACHE_GLYPH_ORDER* copy_cache_glyph_order(rdpContext* context, const CACHE_GLYPH_ORDER* glyph) { - size_t x = 0; CACHE_GLYPH_ORDER* dst = NULL; WINPR_ASSERT(context); @@ -786,7 +779,7 @@ CACHE_GLYPH_ORDER* copy_cache_glyph_order(rdpContext* context, const CACHE_GLYPH *dst = *glyph; - for (x = 0; x < glyph->cGlyphs; x++) + for (size_t x = 0; x < glyph->cGlyphs; x++) { const GLYPH_DATA* src = &glyph->glyphData[x]; GLYPH_DATA* data = &dst->glyphData[x]; @@ -826,9 +819,7 @@ void free_cache_glyph_order(rdpContext* context, CACHE_GLYPH_ORDER* glyph) { if (glyph) { - size_t x = 0; - - for (x = 0; x < ARRAYSIZE(glyph->glyphData); x++) + for (size_t x = 0; x < ARRAYSIZE(glyph->glyphData); x++) free(glyph->glyphData[x].aj); free(glyph->unicodeCharacters); @@ -840,7 +831,6 @@ void free_cache_glyph_order(rdpContext* context, CACHE_GLYPH_ORDER* glyph) CACHE_GLYPH_V2_ORDER* copy_cache_glyph_v2_order(rdpContext* context, const CACHE_GLYPH_V2_ORDER* glyph) { - size_t x = 0; CACHE_GLYPH_V2_ORDER* dst = NULL; WINPR_ASSERT(context); @@ -852,7 +842,7 @@ CACHE_GLYPH_V2_ORDER* copy_cache_glyph_v2_order(rdpContext* context, *dst = *glyph; - for (x = 0; x < glyph->cGlyphs; x++) + for (size_t x = 0; x < glyph->cGlyphs; x++) { const GLYPH_DATA_V2* src = &glyph->glyphData[x]; GLYPH_DATA_V2* data = &dst->glyphData[x]; @@ -892,9 +882,7 @@ void free_cache_glyph_v2_order(rdpContext* context, CACHE_GLYPH_V2_ORDER* glyph) { if (glyph) { - size_t x = 0; - - for (x = 0; x < ARRAYSIZE(glyph->glyphData); x++) + for (size_t x = 0; x < ARRAYSIZE(glyph->glyphData); x++) free(glyph->glyphData[x].aj); free(glyph->unicodeCharacters); diff --git a/libfreerdp/cache/nine_grid.c b/libfreerdp/cache/nine_grid.c index 392b546db..c169a4f2a 100644 --- a/libfreerdp/cache/nine_grid.c +++ b/libfreerdp/cache/nine_grid.c @@ -158,8 +158,7 @@ void nine_grid_cache_free(rdpNineGridCache* nine_grid) { if (nine_grid->entries != NULL) { - size_t i = 0; - for (i = 0; i < nine_grid->maxEntries; i++) + for (size_t i = 0; i < nine_grid->maxEntries; i++) free(nine_grid->entries[i].entry); free(nine_grid->entries); diff --git a/libfreerdp/cache/offscreen.c b/libfreerdp/cache/offscreen.c index 499f5f596..3b8b43e74 100644 --- a/libfreerdp/cache/offscreen.c +++ b/libfreerdp/cache/offscreen.c @@ -52,7 +52,6 @@ static BOOL update_gdi_create_offscreen_bitmap(rdpContext* context, const CREATE_OFFSCREEN_BITMAP_ORDER* createOffscreenBitmap) { - UINT32 i = 0; UINT16 index = 0; rdpBitmap* bitmap = NULL; rdpCache* cache = NULL; @@ -80,7 +79,7 @@ update_gdi_create_offscreen_bitmap(rdpContext* context, if (cache->offscreen->currentSurface == createOffscreenBitmap->id) bitmap->SetSurface(context, bitmap, FALSE); - for (i = 0; i < createOffscreenBitmap->deleteList.cIndices; i++) + for (UINT32 i = 0; i < createOffscreenBitmap->deleteList.cIndices; i++) { index = createOffscreenBitmap->deleteList.indices[i]; offscreen_cache_delete(cache->offscreen, index); @@ -229,10 +228,9 @@ void offscreen_cache_free(rdpOffscreenCache* offscreenCache) { if (offscreenCache) { - size_t i = 0; if (offscreenCache->entries) { - for (i = 0; i < offscreenCache->maxEntries; i++) + for (size_t i = 0; i < offscreenCache->maxEntries; i++) { rdpBitmap* bitmap = offscreenCache->entries[i]; Bitmap_Free(offscreenCache->context, bitmap); diff --git a/libfreerdp/cache/palette.c b/libfreerdp/cache/palette.c index 584e913f7..8a99abcd3 100644 --- a/libfreerdp/cache/palette.c +++ b/libfreerdp/cache/palette.c @@ -111,9 +111,7 @@ void palette_cache_free(rdpPaletteCache* paletteCache) { if (paletteCache) { - UINT32 i = 0; - - for (i = 0; i < paletteCache->maxEntries; i++) + for (UINT32 i = 0; i < paletteCache->maxEntries; i++) free(paletteCache->entries[i].entry); free(paletteCache->entries); diff --git a/libfreerdp/cache/pointer.c b/libfreerdp/cache/pointer.c index e5187aa49..cf9fb4c0a 100644 --- a/libfreerdp/cache/pointer.c +++ b/libfreerdp/cache/pointer.c @@ -373,14 +373,11 @@ void pointer_cache_free(rdpPointerCache* pointer_cache) { if (pointer_cache != NULL) { - UINT32 i = 0; - rdpPointer* pointer = NULL; - if (pointer_cache->entries) { - for (i = 0; i < pointer_cache->cacheSize; i++) + for (UINT32 i = 0; i < pointer_cache->cacheSize; i++) { - pointer = pointer_cache->entries[i]; + rdpPointer* pointer = pointer_cache->entries[i]; pointer_free(pointer_cache->context, pointer); } } diff --git a/libfreerdp/codec/audio.c b/libfreerdp/codec/audio.c index 68475e464..ff2786dd0 100644 --- a/libfreerdp/codec/audio.c +++ b/libfreerdp/codec/audio.c @@ -130,16 +130,13 @@ void audio_format_print(wLog* log, DWORD level, const AUDIO_FORMAT* format) void audio_formats_print(wLog* log, DWORD level, const AUDIO_FORMAT* formats, UINT16 count) { - UINT16 index = 0; - const AUDIO_FORMAT* format = NULL; - if (formats) { WLog_Print(log, level, "AUDIO_FORMATS (%" PRIu16 ") ={", count); - for (index = 0; index < count; index++) + for (UINT32 index = 0; index < count; index++) { - format = &formats[index]; + const AUDIO_FORMAT* format = &formats[index]; WLog_Print(log, level, "\t"); audio_format_print(log, level, format); } @@ -288,11 +285,9 @@ void audio_format_free(AUDIO_FORMAT* format) void audio_formats_free(AUDIO_FORMAT* formats, size_t count) { - size_t index = 0; - if (formats) { - for (index = 0; index < count; index++) + for (size_t index = 0; index < count; index++) { AUDIO_FORMAT* format = &formats[index]; audio_format_free(format); diff --git a/libfreerdp/codec/bitmap.c b/libfreerdp/codec/bitmap.c index 2372f1149..d51f2f736 100644 --- a/libfreerdp/codec/bitmap.c +++ b/libfreerdp/codec/bitmap.c @@ -484,7 +484,6 @@ static SSIZE_T freerdp_bitmap_compress_24(const void* srcData, UINT32 width, UIN while ((line >= start) && (out_count < 32768)) { - UINT32 j = 0; size_t i = Stream_GetPosition(s) + count * 3U; if ((i - (color_count * 3) >= byte_limit) && (i - (bicolor_count * 3) >= byte_limit) && @@ -496,7 +495,7 @@ static SSIZE_T freerdp_bitmap_compress_24(const void* srcData, UINT32 width, UIN out_count += end * 3; - for (j = 0; j < end; j++) + for (UINT32 j = 0; j < end; j++) { /* read next pixel */ const UINT32 pixel = IN_PIXEL32(line, j, 0, width, last_pixel); @@ -790,7 +789,6 @@ static SSIZE_T freerdp_bitmap_compress_16(const void* srcData, UINT32 width, UIN while ((line >= start) && (out_count < 32768)) { - UINT32 j = 0; size_t i = Stream_GetPosition(s) + count * 2; if ((i - (color_count * 2) >= byte_limit) && (i - (bicolor_count * 2) >= byte_limit) && @@ -802,7 +800,7 @@ static SSIZE_T freerdp_bitmap_compress_16(const void* srcData, UINT32 width, UIN out_count += end * 2; - for (j = 0; j < end; j++) + for (UINT32 j = 0; j < end; j++) { /* read next pixel */ const UINT16 pixel = IN_PIXEL16(line, j, 0, width, last_pixel); diff --git a/libfreerdp/codec/clear.c b/libfreerdp/codec/clear.c index 4052abf6b..5c009d8e9 100644 --- a/libfreerdp/codec/clear.c +++ b/libfreerdp/codec/clear.c @@ -151,7 +151,6 @@ static BOOL clear_decompress_subcode_rlex(wStream* s, UINT32 bitmapDataByteCount { UINT32 x = 0; UINT32 y = 0; - UINT32 i = 0; UINT32 pixelCount = 0; UINT32 bitmapDataOffset = 0; size_t pixelIndex = 0; @@ -180,7 +179,7 @@ static BOOL clear_decompress_subcode_rlex(wStream* s, UINT32 bitmapDataByteCount if (!Stream_CheckAndLogRequiredLengthOfSize(TAG, s, paletteCount, 3ull)) return FALSE; - for (i = 0; i < paletteCount; i++) + for (UINT32 i = 0; i < paletteCount; i++) { BYTE r = 0; BYTE g = 0; @@ -262,7 +261,7 @@ static BOOL clear_decompress_subcode_rlex(wStream* s, UINT32 bitmapDataByteCount return FALSE; } - for (i = 0; i < runLengthFactor; i++) + for (UINT32 i = 0; i < runLengthFactor; i++) { BYTE* pTmpData = &pDstData[(nXDstRel + x) * FreeRDPGetBytesPerPixel(DstFormat) + (nYDstRel + y) * nDstStep]; @@ -287,7 +286,7 @@ static BOOL clear_decompress_subcode_rlex(wStream* s, UINT32 bitmapDataByteCount return FALSE; } - for (i = 0; i <= suiteDepth; i++) + for (UINT32 i = 0; i <= suiteDepth; i++) { BYTE* pTmpData = &pDstData[(nXDstRel + x) * FreeRDPGetBytesPerPixel(DstFormat) + (nYDstRel + y) * nDstStep]; @@ -356,7 +355,6 @@ static BOOL clear_decompress_residual_data(CLEAR_CONTEXT* clear, wStream* s, UINT32 nXDst, UINT32 nYDst, UINT32 nDstWidth, UINT32 nDstHeight, const gdiPalette* palette) { - UINT32 i = 0; UINT32 nSrcStep = 0; UINT32 suboffset = 0; BYTE* dstBuffer = NULL; @@ -420,7 +418,7 @@ static BOOL clear_decompress_residual_data(CLEAR_CONTEXT* clear, wStream* s, return FALSE; } - for (i = 0; i < runLengthFactor; i++) + for (UINT32 i = 0; i < runLengthFactor; i++) { FreeRDPWriteColor(dstBuffer, clear->format, color); dstBuffer += FreeRDPGetBytesPerPixel(clear->format); @@ -756,7 +754,6 @@ static BOOL clear_decompress_bands_data(CLEAR_CONTEXT* clear, wStream* s, UINT32 if (vBarUpdate) { - UINT32 x = 0; BYTE* pSrcPixel = NULL; BYTE* dstBuffer = NULL; @@ -805,7 +802,7 @@ static BOOL clear_decompress_bands_data(CLEAR_CONTEXT* clear, wStream* s, UINT32 &vBarShortEntry ->pixels[(y - vBarYOn) * FreeRDPGetBytesPerPixel(clear->format)]; - for (x = 0; x < count; x++) + for (UINT32 x = 0; x < count; x++) { UINT32 color = 0; color = FreeRDPReadColor(&pSrcPixel[x * FreeRDPGetBytesPerPixel(clear->format)], diff --git a/libfreerdp/codec/color.c b/libfreerdp/codec/color.c index 24e8273d9..b113fb065 100644 --- a/libfreerdp/codec/color.c +++ b/libfreerdp/codec/color.c @@ -43,31 +43,25 @@ BYTE* freerdp_glyph_convert(UINT32 width, UINT32 height, const BYTE* data) { - UINT32 x = 0; - UINT32 y = 0; - const BYTE* srcp = NULL; - BYTE* dstp = NULL; - BYTE* dstData = NULL; - UINT32 scanline = 0; /* * converts a 1-bit-per-pixel glyph to a one-byte-per-pixel glyph: * this approach uses a little more memory, but provides faster * means of accessing individual pixels in blitting operations */ - scanline = (width + 7) / 8; - dstData = (BYTE*)winpr_aligned_malloc(1ull * width * height, 16); + const UINT32 scanline = (width + 7) / 8; + BYTE* dstData = (BYTE*)winpr_aligned_malloc(1ull * width * height, 16); if (!dstData) return NULL; ZeroMemory(dstData, width * height); - dstp = dstData; + BYTE* dstp = dstData; - for (y = 0; y < height; y++) + for (UINT32 y = 0; y < height; y++) { - srcp = data + (y * scanline); + const BYTE* srcp = data + (y * scanline); - for (x = 0; x < width; x++) + for (UINT32 x = 0; x < width; x++) { if ((*srcp & (0x80 >> (x % 8))) != 0) *dstp = 0xFF; @@ -88,8 +82,6 @@ BOOL freerdp_image_copy_from_monochrome(BYTE* WINPR_RESTRICT pDstData, UINT32 Ds UINT32 backColor, UINT32 foreColor, const gdiPalette* WINPR_RESTRICT palette) { - UINT32 x = 0; - UINT32 y = 0; BOOL vFlip = 0; UINT32 monoStep = 0; const UINT32 dstBytesPerPixel = FreeRDPGetBytesPerPixel(DstFormat); @@ -103,7 +95,7 @@ BOOL freerdp_image_copy_from_monochrome(BYTE* WINPR_RESTRICT pDstData, UINT32 Ds vFlip = FALSE; monoStep = (nWidth + 7) / 8; - for (y = 0; y < nHeight; y++) + for (UINT32 y = 0; y < nHeight; y++) { const BYTE* monoBits = NULL; BYTE* pDstLine = &pDstData[((nYDst + y) * nDstStep)]; @@ -114,7 +106,7 @@ BOOL freerdp_image_copy_from_monochrome(BYTE* WINPR_RESTRICT pDstData, UINT32 Ds else monoBits = &pSrcData[monoStep * (nHeight - y - 1)]; - for (x = 0; x < nWidth; x++) + for (UINT32 x = 0; x < nWidth; x++) { BYTE* pDstPixel = &pDstLine[((nXDst + x) * FreeRDPGetBytesPerPixel(DstFormat))]; BOOL monoPixel = (*monoBits & monoBit) ? TRUE : FALSE; @@ -161,8 +153,6 @@ static INLINE UINT32 freerdp_image_inverted_pointer_color(UINT32 x, UINT32 y, UI static void fill_gdi_palette_for_icon(const BYTE* colorTable, UINT16 cbColorTable, gdiPalette* palette) { - UINT16 i = 0; - WINPR_ASSERT(palette); palette->format = PIXEL_FORMAT_BGRX32; @@ -177,7 +167,7 @@ static void fill_gdi_palette_for_icon(const BYTE* colorTable, UINT16 cbColorTabl return; } - for (i = 0; i < cbColorTable / 4; i++) + for (UINT16 i = 0; i < cbColorTable / 4; i++) { palette->palette[i] = FreeRDPReadColor(&colorTable[4 * i], palette->format); } @@ -260,8 +250,6 @@ BOOL freerdp_image_copy_from_icon_data(BYTE* WINPR_RESTRICT pDstData, UINT32 Dst { BYTE nextBit = 0; const BYTE* maskByte = NULL; - UINT32 x = 0; - UINT32 y = 0; UINT32 stride = 0; BYTE r = 0; BYTE g = 0; @@ -276,12 +264,12 @@ BOOL freerdp_image_copy_from_icon_data(BYTE* WINPR_RESTRICT pDstData, UINT32 Dst */ stride = round_up(div_ceil(nWidth, 8), 4); - for (y = 0; y < nHeight; y++) + for (UINT32 y = 0; y < nHeight; y++) { maskByte = &bitsMask[stride * (nHeight - 1 - y)]; nextBit = 0x80; - for (x = 0; x < nWidth; x++) + for (UINT32 x = 0; x < nWidth; x++) { UINT32 color = 0; BYTE alpha = (*maskByte & nextBit) ? 0x00 : 0xFF; @@ -311,8 +299,6 @@ static BOOL freerdp_image_copy_from_pointer_data_1bpp( UINT32 nWidth, UINT32 nHeight, const BYTE* WINPR_RESTRICT xorMask, UINT32 xorMaskLength, const BYTE* WINPR_RESTRICT andMask, UINT32 andMaskLength, UINT32 xorBpp) { - UINT32 x = 0; - UINT32 y = 0; BOOL vFlip = 0; UINT32 xorStep = 0; UINT32 andStep = 0; @@ -339,7 +325,7 @@ static BOOL freerdp_image_copy_from_pointer_data_1bpp( if (andStep * nHeight > andMaskLength) return FALSE; - for (y = 0; y < nHeight; y++) + for (UINT32 y = 0; y < nHeight; y++) { const BYTE* andBits = NULL; const BYTE* xorBits = NULL; @@ -358,7 +344,7 @@ static BOOL freerdp_image_copy_from_pointer_data_1bpp( andBits = &andMask[andStep * (nHeight - y - 1)]; } - for (x = 0; x < nWidth; x++) + for (UINT32 x = 0; x < nWidth; x++) { UINT32 color = 0; xorPixel = (*xorBits & xorBit) ? 1 : 0; @@ -400,8 +386,6 @@ static BOOL freerdp_image_copy_from_pointer_data_xbpp( const BYTE* WINPR_RESTRICT andMask, UINT32 andMaskLength, UINT32 xorBpp, const gdiPalette* palette) { - UINT32 x = 0; - UINT32 y = 0; BOOL vFlip = 0; UINT32 xorStep = 0; UINT32 andStep = 0; @@ -439,7 +423,7 @@ static BOOL freerdp_image_copy_from_pointer_data_xbpp( return FALSE; } - for (y = 0; y < nHeight; y++) + for (UINT32 y = 0; y < nHeight; y++) { const BYTE* xorBits = NULL; const BYTE* andBits = NULL; @@ -462,7 +446,7 @@ static BOOL freerdp_image_copy_from_pointer_data_xbpp( xorBits = &xorMask[xorStep * (nHeight - y - 1)]; } - for (x = 0; x < nWidth; x++) + for (UINT32 x = 0; x < nWidth; x++) { UINT32 pixelFormat = 0; UINT32 color = 0; @@ -769,12 +753,10 @@ static BOOL freerdp_image_copy_overlap(BYTE* pDstData, DWORD DstFormat, UINT32 n } else if (FreeRDPAreColorFormatsEqualNoAlpha(SrcFormat, DstFormat)) { - INT32 y = 0; - /* Copy down */ if (nYDst < nYSrc) { - for (y = 0; y < (INT32)nHeight; y++) + for (INT32 y = 0; y < (INT32)nHeight; y++) { const BYTE* srcLine = &pSrcData[(y + nYSrc) * nSrcStep * srcVMultiplier + srcVOffset]; @@ -785,7 +767,7 @@ static BOOL freerdp_image_copy_overlap(BYTE* pDstData, DWORD DstFormat, UINT32 n /* Copy up */ else if (nYDst > nYSrc) { - for (y = nHeight - 1; y >= 0; y--) + for (INT32 y = nHeight - 1; y >= 0; y--) { const BYTE* srcLine = &pSrcData[(y + nYSrc) * nSrcStep * srcVMultiplier + srcVOffset]; @@ -796,7 +778,7 @@ static BOOL freerdp_image_copy_overlap(BYTE* pDstData, DWORD DstFormat, UINT32 n /* Copy left */ else if (nXSrc > nXDst) { - for (y = 0; y < (INT32)nHeight; y++) + for (INT32 y = 0; y < (INT32)nHeight; y++) { const BYTE* srcLine = &pSrcData[(y + nYSrc) * nSrcStep * srcVMultiplier + srcVOffset]; @@ -807,7 +789,7 @@ static BOOL freerdp_image_copy_overlap(BYTE* pDstData, DWORD DstFormat, UINT32 n /* Copy right */ else if (nXSrc < nXDst) { - for (y = (INT32)nHeight - 1; y >= 0; y--) + for (INT32 y = (INT32)nHeight - 1; y >= 0; y--) { const BYTE* srcLine = &pSrcData[(y + nYSrc) * nSrcStep * srcVMultiplier + srcVOffset]; diff --git a/libfreerdp/codec/dsp.c b/libfreerdp/codec/dsp.c index 7171c08f8..68800e480 100644 --- a/libfreerdp/codec/dsp.c +++ b/libfreerdp/codec/dsp.c @@ -150,7 +150,6 @@ static BOOL freerdp_dsp_channel_mix(FREERDP_DSP_CONTEXT* context, const BYTE* sr { UINT32 bpp; size_t samples; - size_t x, y; if (!context || !data || !length) return FALSE; @@ -179,12 +178,12 @@ static BOOL freerdp_dsp_channel_mix(FREERDP_DSP_CONTEXT* context, const BYTE* sr if (!Stream_EnsureCapacity(context->channelmix, size * 2)) return FALSE; - for (x = 0; x < samples; x++) + for (size_t x = 0; x < samples; x++) { - for (y = 0; y < bpp; y++) + for (size_t y = 0; y < bpp; y++) Stream_Write_UINT8(context->channelmix, src[x * bpp + y]); - for (y = 0; y < bpp; y++) + for (size_t y = 0; y < bpp; y++) Stream_Write_UINT8(context->channelmix, src[x * bpp + y]); } @@ -208,9 +207,9 @@ static BOOL freerdp_dsp_channel_mix(FREERDP_DSP_CONTEXT* context, const BYTE* sr /* Simply drop second channel. * TODO: Calculate average */ - for (x = 0; x < samples; x++) + for (size_t x = 0; x < samples; x++) { - for (y = 0; y < bpp; y++) + for (size_t y = 0; y < bpp; y++) Stream_Write_UINT8(context->channelmix, src[2 * x * bpp + y]); } @@ -362,7 +361,6 @@ static BOOL freerdp_dsp_decode_ima_adpcm(FREERDP_DSP_CONTEXT* context, const BYT UINT32 channel; const UINT32 block_size = context->format.nBlockAlign; const UINT32 channels = context->format.nChannels; - size_t i; if (!Stream_EnsureCapacity(out, out_size)) return FALSE; @@ -391,7 +389,7 @@ static BOOL freerdp_dsp_decode_ima_adpcm(FREERDP_DSP_CONTEXT* context, const BYT if (channels > 1) { - for (i = 0; i < 8; i++) + for (size_t i = 0; i < 8; i++) { BYTE* dst = Stream_Pointer(out); @@ -494,7 +492,7 @@ static BOOL freerdp_dsp_encode_gsm610(FREERDP_DSP_CONTEXT* context, const BYTE* static BOOL freerdp_dsp_decode_mp3(FREERDP_DSP_CONTEXT* context, const BYTE* src, size_t size, wStream* out) { - int rc, x; + int rc; short* pcm_l; short* pcm_r; size_t buffer_size; @@ -518,7 +516,7 @@ static BOOL freerdp_dsp_decode_mp3(FREERDP_DSP_CONTEXT* context, const BYTE* src if (!Stream_EnsureRemainingCapacity(out, (size_t)rc * context->format.nChannels * 2)) return FALSE; - for (x = 0; x < rc; x++) + for (size_t x = 0; x < rc; x++) { Stream_Write_UINT16(out, (UINT16)pcm_l[x]); Stream_Write_UINT16(out, (UINT16)pcm_r[x]); @@ -560,7 +558,7 @@ static BOOL freerdp_dsp_encode_faac(FREERDP_DSP_CONTEXT* context, const BYTE* sr { const int16_t* inSamples = (const int16_t*)src; unsigned int bpp; - size_t nrSamples, x; + size_t nrSamples; int rc; if (!context || !src || !out) @@ -572,7 +570,7 @@ static BOOL freerdp_dsp_encode_faac(FREERDP_DSP_CONTEXT* context, const BYTE* sr if (!Stream_EnsureRemainingCapacity(context->buffer, nrSamples * sizeof(int16_t))) return FALSE; - for (x = 0; x < nrSamples; x++) + for (size_t x = 0; x < nrSamples; x++) { Stream_Write_INT16(context->buffer, inSamples[x]); if (Stream_GetPosition(context->buffer) / bpp >= context->faacInputSamples) @@ -793,7 +791,6 @@ static BYTE dsp_encode_ima_adpcm_sample(ADPCM* adpcm, int channel, INT16 sample) static BOOL freerdp_dsp_encode_ima_adpcm(FREERDP_DSP_CONTEXT* context, const BYTE* src, size_t size, wStream* out) { - int i; INT16 sample; BYTE encoded; size_t align; @@ -827,7 +824,7 @@ static BOOL freerdp_dsp_encode_ima_adpcm(FREERDP_DSP_CONTEXT* context, const BYT BYTE* dst = Stream_Pointer(context->buffer); ZeroMemory(dst, 8); - for (i = 0; i < 16; i++) + for (size_t i = 0; i < 16; i++) { sample = (INT16)(((UINT16)(*src)) | (((UINT16)(*(src + 1))) << 8)); src += 2; diff --git a/libfreerdp/codec/dsp_ffmpeg.c b/libfreerdp/codec/dsp_ffmpeg.c index 98d78a63e..caa7414d8 100644 --- a/libfreerdp/codec/dsp_ffmpeg.c +++ b/libfreerdp/codec/dsp_ffmpeg.c @@ -675,8 +675,6 @@ static BOOL freerdp_dsp_channel_mix(FREERDP_DSP_CONTEXT* context, const BYTE* sr { UINT32 bpp = 0; size_t samples = 0; - size_t x = 0; - size_t y = 0; if (!context || !data || !length || !dstFormat) return FALSE; @@ -706,12 +704,12 @@ static BOOL freerdp_dsp_channel_mix(FREERDP_DSP_CONTEXT* context, const BYTE* sr if (!Stream_EnsureCapacity(context->channelmix, size * 2)) return FALSE; - for (x = 0; x < samples; x++) + for (UINT32 x = 0; x < samples; x++) { - for (y = 0; y < bpp; y++) + for (UINT32 y = 0; y < bpp; y++) Stream_Write_UINT8(context->channelmix, src[x * bpp + y]); - for (y = 0; y < bpp; y++) + for (UINT32 y = 0; y < bpp; y++) Stream_Write_UINT8(context->channelmix, src[x * bpp + y]); } @@ -737,9 +735,9 @@ static BOOL freerdp_dsp_channel_mix(FREERDP_DSP_CONTEXT* context, const BYTE* sr /* Simply drop second channel. * TODO: Calculate average */ - for (x = 0; x < samples; x++) + for (UINT32 x = 0; x < samples; x++) { - for (y = 0; y < bpp; y++) + for (UINT32 y = 0; y < bpp; y++) Stream_Write_UINT8(context->channelmix, src[2 * x * bpp + y]); } diff --git a/libfreerdp/codec/h264.c b/libfreerdp/codec/h264.c index 4b211b865..718bd2ccf 100644 --- a/libfreerdp/codec/h264.c +++ b/libfreerdp/codec/h264.c @@ -122,8 +122,6 @@ INT32 avc420_decompress(H264_CONTEXT* h264, const BYTE* pSrcData, UINT32 SrcSize static BOOL allocate_h264_metablock(UINT32 QP, RECTANGLE_16* rectangles, RDPGFX_H264_METABLOCK* meta, size_t count) { - size_t x = 0; - /* [MS-RDPEGFX] 2.2.4.4.2 RDPGFX_AVC420_QUANT_QUALITY */ if (!meta || (QP > UINT8_MAX)) { @@ -143,7 +141,7 @@ static BOOL allocate_h264_metablock(UINT32 QP, RECTANGLE_16* rectangles, if (!meta->quantQualityVals || !meta->regionRects) return FALSE; meta->numRegionRects = (UINT32)count; - for (x = 0; x < count; x++) + for (size_t x = 0; x < count; x++) { RDPGFX_H264_QUANT_QUALITY* cur = &meta->quantQualityVals[x]; cur->qp = (UINT8)QP; @@ -159,7 +157,7 @@ static INLINE BOOL diff_tile(const RECTANGLE_16* regionRect, BYTE* pYUVData[3], BYTE* pOldYUVData[3], UINT32 const iStride[3]) { size_t size = 0; - size_t y = 0; + if (!regionRect || !pYUVData || !pOldYUVData || !iStride) return FALSE; size = regionRect->right - regionRect->left; @@ -170,7 +168,7 @@ static INLINE BOOL diff_tile(const RECTANGLE_16* regionRect, BYTE* pYUVData[3], if (regionRect->right / 2u > iStride[2]) return FALSE; - for (y = regionRect->top; y < regionRect->bottom; y++) + for (UINT16 y = regionRect->top; y < regionRect->bottom; y++) { const BYTE* cur0 = &pYUVData[0][y * iStride[0]]; const BYTE* cur1 = &pYUVData[1][y * iStride[1]]; @@ -213,11 +211,9 @@ static BOOL detect_changes(BOOL firstFrameDone, const UINT32 QP, const RECTANGLE } else { - size_t x = 0; - size_t y = 0; - for (y = regionRect->top; y < regionRect->bottom; y += 64) + for (size_t y = regionRect->top; y < regionRect->bottom; y += 64) { - for (x = regionRect->left; x < regionRect->right; x += 64) + for (size_t x = regionRect->left; x < regionRect->right; x += 64) { RECTANGLE_16 rect; rect.left = (UINT16)MIN(UINT16_MAX, regionRect->left + x); @@ -240,7 +236,6 @@ INT32 avc420_compress(H264_CONTEXT* h264, const BYTE* pSrcData, DWORD SrcFormat, UINT32 nSrcWidth, UINT32 nSrcHeight, const RECTANGLE_16* regionRect, BYTE** ppDstData, UINT32* pDstSize, RDPGFX_H264_METABLOCK* meta) { - size_t x = 0; INT32 rc = -1; BYTE* pYUVData[3] = { 0 }; const BYTE* pcYUVData[3] = { 0 }; @@ -257,7 +252,7 @@ INT32 avc420_compress(H264_CONTEXT* h264, const BYTE* pSrcData, DWORD SrcFormat, if (h264->encodingBuffer) { - for (x = 0; x < 3; x++) + for (size_t x = 0; x < 3; x++) { pYUVData[x] = h264->pYUVData[x]; pOldYUVData[x] = h264->pOldYUVData[x]; @@ -265,7 +260,7 @@ INT32 avc420_compress(H264_CONTEXT* h264, const BYTE* pSrcData, DWORD SrcFormat, } else { - for (x = 0; x < 3; x++) + for (size_t x = 0; x < 3; x++) { pYUVData[x] = h264->pOldYUVData[x]; pOldYUVData[x] = h264->pYUVData[x]; @@ -287,7 +282,7 @@ INT32 avc420_compress(H264_CONTEXT* h264, const BYTE* pSrcData, DWORD SrcFormat, goto fail; } - for (x = 0; x < 3; x++) + for (size_t x = 0; x < 3; x++) pcYUVData[x] = pYUVData[x]; rc = h264->subsystem->Compress(h264, pcYUVData, h264->iStride, ppDstData, pDstSize); @@ -633,8 +628,6 @@ static BOOL CALLBACK h264_register_subsystems(PINIT_ONCE once, PVOID param, PVOI static BOOL h264_context_init(H264_CONTEXT* h264) { - int i = 0; - if (!h264) return FALSE; @@ -646,7 +639,7 @@ static BOOL h264_context_init(H264_CONTEXT* h264) h264->subsystem = NULL; InitOnceExecuteOnce(&subsystems_once, h264_register_subsystems, NULL, NULL); - for (i = 0; i < MAX_SUBSYSTEMS; i++) + for (size_t i = 0; i < MAX_SUBSYSTEMS; i++) { const H264_CONTEXT_SUBSYSTEM* subsystem = subSystems[i]; @@ -709,11 +702,10 @@ void h264_context_free(H264_CONTEXT* h264) { if (h264) { - size_t x = 0; if (h264->subsystem) h264->subsystem->Uninit(h264); - for (x = 0; x < 3; x++) + for (size_t x = 0; x < 3; x++) { if (h264->Compressor) { diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c index 33aa6b0cc..54492e13a 100644 --- a/libfreerdp/codec/h264_ffmpeg.c +++ b/libfreerdp/codec/h264_ffmpeg.c @@ -533,9 +533,7 @@ static enum AVPixelFormat libavcodec_get_format(struct AVCodecContext* ctx, H264_CONTEXT_LIBAVCODEC* sys = (H264_CONTEXT_LIBAVCODEC*)h264->pSystemData; WINPR_ASSERT(sys); - const enum AVPixelFormat* p = NULL; - - for (p = fmts; *p != AV_PIX_FMT_NONE; p++) + for (const enum AVPixelFormat* p = fmts; *p != AV_PIX_FMT_NONE; p++) { if (*p == sys->hw_pix_fmt) { diff --git a/libfreerdp/codec/h264_mf.c b/libfreerdp/codec/h264_mf.c index 4ce34c914..b5e65f5f1 100644 --- a/libfreerdp/codec/h264_mf.c +++ b/libfreerdp/codec/h264_mf.c @@ -393,7 +393,6 @@ static BOOL mf_plat_loaded(H264_CONTEXT_MF* sys) static void mf_uninit(H264_CONTEXT* h264) { - UINT32 x; H264_CONTEXT_MF* sys = (H264_CONTEXT_MF*)h264->pSystemData; if (sys) @@ -440,7 +439,7 @@ static void mf_uninit(H264_CONTEXT* h264) CoUninitialize(); } - for (x = 0; x < sizeof(h264->pYUVData) / sizeof(h264->pYUVData[0]); x++) + for (size_t x = 0; x < sizeof(h264->pYUVData) / sizeof(h264->pYUVData[0]); x++) winpr_aligned_free(h264->pYUVData[x]); memset(h264->pYUVData, 0, sizeof(h264->pYUVData)); diff --git a/libfreerdp/codec/h264_openh264.c b/libfreerdp/codec/h264_openh264.c index 470974241..2fa6a03cf 100644 --- a/libfreerdp/codec/h264_openh264.c +++ b/libfreerdp/codec/h264_openh264.c @@ -182,8 +182,6 @@ static int openh264_decompress(H264_CONTEXT* h264, const BYTE* pSrcData, UINT32 static int openh264_compress(H264_CONTEXT* h264, const BYTE** pYUVData, const UINT32* iStride, BYTE** ppDstData, UINT32* pDstSize) { - int i = 0; - int j = 0; int status = 0; SFrameBSInfo info = { 0 }; SSourcePicture pic = { 0 }; @@ -375,9 +373,9 @@ static int openh264_compress(H264_CONTEXT* h264, const BYTE** pYUVData, const UI *ppDstData = info.sLayerInfo[0].pBsBuf; *pDstSize = 0; - for (i = 0; i < info.iLayerNum; i++) + for (int i = 0; i < info.iLayerNum; i++) { - for (j = 0; j < info.sLayerInfo[i].iNalCount; j++) + for (int j = 0; j < info.sLayerInfo[i].iNalCount; j++) { *pDstSize += info.sLayerInfo[i].pNalLengthInByte[j]; } @@ -388,7 +386,6 @@ static int openh264_compress(H264_CONTEXT* h264, const BYTE** pYUVData, const UI static void openh264_uninit(H264_CONTEXT* h264) { - UINT32 x = 0; H264_CONTEXT_OPENH264* sysContexts = NULL; WINPR_ASSERT(h264); @@ -397,7 +394,7 @@ static void openh264_uninit(H264_CONTEXT* h264) if (sysContexts) { - for (x = 0; x < h264->numSystemData; x++) + for (UINT32 x = 0; x < h264->numSystemData; x++) { H264_CONTEXT_OPENH264* sys = &sysContexts[x]; @@ -490,9 +487,7 @@ static BOOL openh264_init(H264_CONTEXT* h264) { #if defined(WITH_OPENH264_LOADING) BOOL success = FALSE; - size_t i; #endif - UINT32 x = 0; long status = 0; H264_CONTEXT_OPENH264* sysContexts = NULL; static int traceLevel = WELS_LOG_DEBUG; @@ -513,7 +508,7 @@ static BOOL openh264_init(H264_CONTEXT* h264) h264->pSystemData = (void*)sysContexts; #if defined(WITH_OPENH264_LOADING) - for (i = 0; i < ARRAYSIZE(openh264_library_names); i++) + for (size_t i = 0; i < ARRAYSIZE(openh264_library_names); i++) { const char* current = openh264_library_names[i]; success = openh264_load_functionpointers(h264, current); @@ -533,7 +528,7 @@ static BOOL openh264_init(H264_CONTEXT* h264) sysContexts->WelsDestroySVCEncoder = WelsDestroySVCEncoder; #endif - for (x = 0; x < h264->numSystemData; x++) + for (UINT32 x = 0; x < h264->numSystemData; x++) { SDecodingParam sDecParam = { 0 }; H264_CONTEXT_OPENH264* sys = &sysContexts[x]; diff --git a/libfreerdp/codec/interleaved.c b/libfreerdp/codec/interleaved.c index 3f39ea3c6..75b2e2775 100644 --- a/libfreerdp/codec/interleaved.c +++ b/libfreerdp/codec/interleaved.c @@ -29,17 +29,16 @@ #define TAG FREERDP_TAG("codec") -#define UNROLL_BODY(_exp, _count) \ - do \ - { \ - size_t x; \ - for (x = 0; x < (_count); x++) \ - { \ - do \ - { \ - _exp \ - } while (FALSE); \ - } \ +#define UNROLL_BODY(_exp, _count) \ + do \ + { \ + for (size_t x = 0; x < (_count); x++) \ + { \ + do \ + { \ + _exp \ + } while (FALSE); \ + } \ } while (FALSE) #define UNROLL_MULTIPLE(_condition, _exp, _count) \ diff --git a/libfreerdp/codec/ncrush.c b/libfreerdp/codec/ncrush.c index 8bfe0b105..4a7162c89 100644 --- a/libfreerdp/codec/ncrush.c +++ b/libfreerdp/codec/ncrush.c @@ -2363,8 +2363,6 @@ static int ncrush_find_match_length(const BYTE* Ptr1, const BYTE* Ptr2, BYTE* Hi static int ncrush_find_best_match(NCRUSH_CONTEXT* ncrush, UINT16 HistoryOffset, UINT32* pMatchOffset) { - int i = 0; - int j = 0; int Length = 0; int MatchLength = 0; BYTE* MatchPtr = NULL; @@ -2387,9 +2385,9 @@ static int ncrush_find_best_match(NCRUSH_CONTEXT* ncrush, UINT16 HistoryOffset, NextOffset = ncrush->MatchTable[Offset]; MatchPtr = &HistoryBuffer[MatchLength]; - for (i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { - j = -1; + int j = -1; if (j < 0) { @@ -2482,8 +2480,6 @@ static int ncrush_find_best_match(NCRUSH_CONTEXT* ncrush, UINT16 HistoryOffset, static int ncrush_move_encoder_windows(NCRUSH_CONTEXT* ncrush, BYTE* HistoryPtr) { - int i = 0; - int j = 0; int NewHash = 0; int NewMatch = 0; UINT32 HistoryOffset = 0; @@ -2503,7 +2499,7 @@ static int ncrush_move_encoder_windows(NCRUSH_CONTEXT* ncrush, BYTE* HistoryPtr) WINPR_ASSERT(hsize >= 0); HistoryOffset = (UINT32)hsize; - for (i = 0; i < 65536; i += 4) + for (int i = 0; i < 65536; i += 4) { NewHash = ncrush->HashTable[i + 0] - HistoryOffset; ncrush->HashTable[i + 0] = (NewHash <= 0) ? 0 : NewHash; @@ -2515,7 +2511,7 @@ static int ncrush_move_encoder_windows(NCRUSH_CONTEXT* ncrush, BYTE* HistoryPtr) ncrush->HashTable[i + 3] = (NewHash <= 0) ? 0 : NewHash; } - for (j = 0; j < 32768; j += 4) + for (int j = 0; j < 32768; j += 4) { NewMatch = ncrush->MatchTable[HistoryOffset + j + 0] - HistoryOffset; ncrush->MatchTable[j + 0] = (NewMatch <= 0) ? 0 : NewMatch; @@ -2942,29 +2938,23 @@ int ncrush_compress(NCRUSH_CONTEXT* ncrush, const BYTE* pSrcData, UINT32 SrcSize static int ncrush_generate_tables(NCRUSH_CONTEXT* context) { - UINT32 k = 0; - UINT32 i = 0; - int j = 0; - int l = 0; - k = 0; - WINPR_ASSERT(context); WINPR_ASSERT(28 < ARRAYSIZE(LOMBitsLUT)); - for (i = 0; i < 28; i++) + UINT32 k = 0; + for (int i = 0; i < 28; i++) { - for (j = 0; j < 1 << LOMBitsLUT[i]; j++) + for (int j = 0; j < 1 << LOMBitsLUT[i]; j++) { - l = (k++) + 2; + size_t l = (k++) + 2ull; context->HuffTableLOM[l] = (int)i; } } - for (k = 2; k < 4096; k++) + for (UINT32 k = 2; k < 4096; k++) { - if ((k - 2) >= 768) - i = 28; - else + size_t i = 28; + if ((k - 2) < 768) i = context->HuffTableLOM[k]; if (i >= ARRAYSIZE(LOMBitsLUT)) @@ -2978,22 +2968,22 @@ static int ncrush_generate_tables(NCRUSH_CONTEXT* context) k = 0; - for (i = 0; i < 16; i++) + for (int i = 0; i < 16; i++) { - for (j = 0; j < 1 << CopyOffsetBitsLUT[i]; j++) + for (int j = 0; j < 1 << CopyOffsetBitsLUT[i]; j++) { - l = k++ + 2; + size_t l = k++ + 2ull; context->HuffTableCopyOffset[l] = i; } } k /= 128; - for (i = 16; i < 32; i++) + for (int i = 16; i < 32; i++) { - for (j = 0; j < 1 << (CopyOffsetBitsLUT[i] - 7); j++) + for (int j = 0; j < 1 << (CopyOffsetBitsLUT[i] - 7); j++) { - l = k++ + 2 + 256; + size_t l = k++ + 2 + 256ull; context->HuffTableCopyOffset[l] = i; } } diff --git a/libfreerdp/codec/nsc.c b/libfreerdp/codec/nsc.c index 31cb5ffa3..049b541f1 100644 --- a/libfreerdp/codec/nsc.c +++ b/libfreerdp/codec/nsc.c @@ -48,8 +48,6 @@ static BOOL nsc_decode(NSC_CONTEXT* context) { - UINT16 x = 0; - UINT16 y = 0; UINT16 rw = 0; BYTE shift = 0; BYTE* bmpdata = NULL; @@ -65,7 +63,7 @@ static BOOL nsc_decode(NSC_CONTEXT* context) if (!bmpdata) return FALSE; - for (y = 0; y < context->height; y++) + for (UINT32 y = 0; y < context->height; y++) { const BYTE* yplane = NULL; const BYTE* coplane = NULL; @@ -85,7 +83,7 @@ static BOOL nsc_decode(NSC_CONTEXT* context) cgplane = context->priv->PlaneBuffers[2] + y * context->width; /* Cg */ } - for (x = 0; x < context->width; x++) + for (UINT32 x = 0; x < context->width; x++) { INT16 y_val = (INT16)*yplane; INT16 co_val = (INT16)(INT8)(*coplane << shift); diff --git a/libfreerdp/codec/nsc_encode.c b/libfreerdp/codec/nsc_encode.c index 0478a6032..a56e9181a 100644 --- a/libfreerdp/codec/nsc_encode.c +++ b/libfreerdp/codec/nsc_encode.c @@ -58,7 +58,6 @@ static BOOL nsc_write_message(NSC_CONTEXT* context, wStream* s, const NSC_MESSAG static BOOL nsc_context_initialize_encode(NSC_CONTEXT* context) { - int i = 0; UINT32 length = 0; UINT32 tempWidth = 0; UINT32 tempHeight = 0; @@ -69,7 +68,7 @@ static BOOL nsc_context_initialize_encode(NSC_CONTEXT* context) if (length > context->priv->PlaneBuffersLength) { - for (i = 0; i < 5; i++) + for (int i = 0; i < 5; i++) { BYTE* tmp = (BYTE*)winpr_aligned_recalloc(context->priv->PlaneBuffers[i], length, sizeof(BYTE), 32); @@ -103,7 +102,7 @@ fail: if (length > context->priv->PlaneBuffersLength) { - for (i = 0; i < 5; i++) + for (int i = 0; i < 5; i++) winpr_aligned_free(context->priv->PlaneBuffers[i]); } @@ -133,7 +132,7 @@ static BOOL nsc_encode_argb_to_aycocg(NSC_CONTEXT* context, const BYTE* data, UI rw = (context->ChromaSubsamplingLevel ? tempWidth : context->width); ccl = context->ColorLossLevel; - for (y = 0; y < context->height; y++) + for (; y < context->height; y++) { src = data + (context->height - 1 - y) * scanline; yplane = context->priv->PlaneBuffers[0] + y * rw; @@ -141,7 +140,7 @@ 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 (x = 0; x < context->width; x++) + for (UINT16 x = 0; x < context->width; x++) { switch (context->format) { @@ -273,7 +272,6 @@ static BOOL nsc_encode_argb_to_aycocg(NSC_CONTEXT* context, const BYTE* data, UI static BOOL nsc_encode_subsampling(NSC_CONTEXT* context) { - UINT32 y = 0; UINT32 tempWidth = 0; UINT32 tempHeight = 0; @@ -289,9 +287,8 @@ static BOOL nsc_encode_subsampling(NSC_CONTEXT* context) if (tempWidth > context->priv->PlaneBuffersLength / tempHeight) return FALSE; - for (y = 0; y < tempHeight >> 1; y++) + for (UINT32 y = 0; y < tempHeight >> 1; y++) { - UINT32 x = 0; BYTE* co_dst = context->priv->PlaneBuffers[1] + y * (tempWidth >> 1); BYTE* cg_dst = context->priv->PlaneBuffers[2] + y * (tempWidth >> 1); const INT8* co_src0 = (INT8*)context->priv->PlaneBuffers[1] + (y << 1) * tempWidth; @@ -299,7 +296,7 @@ static BOOL nsc_encode_subsampling(NSC_CONTEXT* context) const INT8* cg_src0 = (INT8*)context->priv->PlaneBuffers[2] + (y << 1) * tempWidth; const INT8* cg_src1 = cg_src0 + tempWidth; - for (x = 0; x < tempWidth >> 1; x++) + for (UINT32 x = 0; x < tempWidth >> 1; x++) { *co_dst++ = (BYTE)(((INT16)*co_src0 + (INT16) * (co_src0 + 1) + (INT16)*co_src1 + (INT16) * (co_src1 + 1)) >> @@ -390,11 +387,10 @@ static UINT32 nsc_rle_encode(const BYTE* in, BYTE* out, UINT32 originalSize) static void nsc_rle_compress_data(NSC_CONTEXT* context) { - UINT16 i = 0; UINT32 planeSize = 0; UINT32 originalSize = 0; - for (i = 0; i < 4; i++) + for (UINT16 i = 0; i < 4; i++) { originalSize = context->OrgByteCount[i]; diff --git a/libfreerdp/codec/nsc_sse2.c b/libfreerdp/codec/nsc_sse2.c index 9033933cd..7ef0275cf 100644 --- a/libfreerdp/codec/nsc_sse2.c +++ b/libfreerdp/codec/nsc_sse2.c @@ -35,7 +35,6 @@ static BOOL nsc_encode_argb_to_aycocg_sse2(NSC_CONTEXT* context, const BYTE* data, UINT32 scanline) { - UINT16 x = 0; UINT16 y = 0; UINT16 rw = 0; BYTE ccl = 0; @@ -60,7 +59,7 @@ static BOOL nsc_encode_argb_to_aycocg_sse2(NSC_CONTEXT* context, const BYTE* dat rw = (context->ChromaSubsamplingLevel > 0 ? tempWidth : context->width); ccl = context->ColorLossLevel; - for (y = 0; y < context->height; y++) + for (; y < context->height; y++) { src = data + (context->height - 1 - y) * scanline; yplane = context->priv->PlaneBuffers[0] + y * rw; @@ -68,7 +67,7 @@ static BOOL nsc_encode_argb_to_aycocg_sse2(NSC_CONTEXT* context, const BYTE* dat cgplane = context->priv->PlaneBuffers[2] + y * rw; aplane = context->priv->PlaneBuffers[3] + y * context->width; - for (x = 0; x < context->width; x += 8) + for (UINT16 x = 0; x < context->width; x += 8) { switch (context->format) { @@ -204,10 +203,9 @@ static BOOL nsc_encode_argb_to_aycocg_sse2(NSC_CONTEXT* context, const BYTE* dat case PIXEL_FORMAT_A4: { - int shift = 0; - BYTE idx[8]; + BYTE idx[8] = { 0 }; - for (shift = 7; shift >= 0; shift--) + for (int shift = 7; shift >= 0; shift--) { idx[shift] = ((*src) >> shift) & 1; idx[shift] |= (((*(src + 1)) >> shift) & 1) << 1; @@ -318,7 +316,6 @@ static BOOL nsc_encode_argb_to_aycocg_sse2(NSC_CONTEXT* context, const BYTE* dat static void nsc_encode_subsampling_sse2(NSC_CONTEXT* context) { - UINT32 y = 0; BYTE* co_dst = NULL; BYTE* cg_dst = NULL; INT8* co_src0 = NULL; @@ -333,9 +330,8 @@ static void nsc_encode_subsampling_sse2(NSC_CONTEXT* context) tempWidth = ROUND_UP_TO(context->width, 8); tempHeight = ROUND_UP_TO(context->height, 2); - for (y = 0; y < tempHeight >> 1; y++) + for (UINT32 y = 0; y < tempHeight >> 1; y++) { - UINT32 x = 0; co_dst = context->priv->PlaneBuffers[1] + y * (tempWidth >> 1); cg_dst = context->priv->PlaneBuffers[2] + y * (tempWidth >> 1); co_src0 = (INT8*)context->priv->PlaneBuffers[1] + (y << 1) * tempWidth; @@ -343,7 +339,7 @@ static void nsc_encode_subsampling_sse2(NSC_CONTEXT* context) cg_src0 = (INT8*)context->priv->PlaneBuffers[2] + (y << 1) * tempWidth; cg_src1 = cg_src0 + tempWidth; - for (x = 0; x < tempWidth >> 1; x += 8) + for (UINT32 x = 0; x < tempWidth >> 1; x += 8) { t = _mm_loadu_si128((__m128i*)co_src0); t = _mm_avg_epu8(t, _mm_loadu_si128((__m128i*)co_src1)); diff --git a/libfreerdp/codec/planar.c b/libfreerdp/codec/planar.c index c1eb2ca52..0ec086269 100644 --- a/libfreerdp/codec/planar.c +++ b/libfreerdp/codec/planar.c @@ -167,15 +167,13 @@ static INLINE INT32 planar_skip_plane_rle(const BYTE* pSrcData, UINT32 SrcSize, UINT32 nHeight) { UINT32 used = 0; - UINT32 x = 0; - UINT32 y = 0; BYTE controlByte = 0; WINPR_ASSERT(pSrcData); - for (y = 0; y < nHeight; y++) + for (UINT32 y = 0; y < nHeight; y++) { - for (x = 0; x < nWidth;) + for (UINT32 x = 0; x < nWidth;) { int cRawBytes = 0; int nRunLength = 0; @@ -232,8 +230,6 @@ static INLINE INT32 planar_skip_plane_rle(const BYTE* pSrcData, UINT32 SrcSize, static INLINE INT32 planar_decompress_plane_rle_only(const BYTE* pSrcData, UINT32 SrcSize, BYTE* pDstData, UINT32 nWidth, UINT32 nHeight) { - INT32 x = 0; - INT32 y = 0; UINT32 pixel = 0; UINT32 cRawBytes = 0; UINT32 nRunLength = 0; @@ -248,13 +244,13 @@ static INLINE INT32 planar_decompress_plane_rle_only(const BYTE* pSrcData, UINT3 previousScanline = NULL; - for (y = 0; y < (INT32)nHeight; y++) + for (INT32 y = 0; y < (INT32)nHeight; y++) { BYTE* dstp = &pDstData[((y) * (INT32)nWidth)]; pixel = 0; currentScanline = dstp; - for (x = 0; x < (INT32)nWidth;) + for (INT32 x = 0; x < (INT32)nWidth;) { controlByte = *srcp; srcp++; @@ -355,8 +351,6 @@ static INLINE INT32 planar_decompress_plane_rle(const BYTE* pSrcData, UINT32 Src UINT32 nYDst, UINT32 nWidth, UINT32 nHeight, UINT32 nChannel, BOOL vFlip) { - INT32 x = 0; - INT32 y = 0; UINT32 pixel = 0; UINT32 cRawBytes = 0; UINT32 nRunLength = 0; @@ -388,13 +382,13 @@ static INLINE INT32 planar_decompress_plane_rle(const BYTE* pSrcData, UINT32 Src inc = 1; } - for (y = beg; y != end; y += inc) + for (INT32 y = beg; y != end; y += inc) { BYTE* dstp = &pDstData[((nYDst + y) * (INT32)nDstStep) + (nXDst * 4) + nChannel]; pixel = 0; currentScanline = dstp; - for (x = 0; x < (INT32)nWidth;) + for (INT32 x = 0; x < (INT32)nWidth;) { controlByte = *srcp; srcp++; @@ -494,8 +488,6 @@ static INLINE INT32 planar_set_plane(BYTE bValue, BYTE* pDstData, INT32 nDstStep UINT32 nYDst, UINT32 nWidth, UINT32 nHeight, UINT32 nChannel, BOOL vFlip) { - INT32 x = 0; - INT32 y = 0; INT32 beg = 0; INT32 end = 0; INT32 inc = 0; @@ -517,11 +509,11 @@ static INLINE INT32 planar_set_plane(BYTE bValue, BYTE* pDstData, INT32 nDstStep inc = 1; } - for (y = beg; y != end; y += inc) + for (INT32 y = beg; y != end; y += inc) { BYTE* dstp = &pDstData[((nYDst + y) * (INT32)nDstStep) + (nXDst * 4) + nChannel]; - for (x = 0; x < (INT32)nWidth; ++x) + for (INT32 x = 0; x < (INT32)nWidth; ++x) { *dstp = bValue; dstp += 4; @@ -534,8 +526,6 @@ static INLINE INT32 planar_set_plane(BYTE bValue, BYTE* pDstData, INT32 nDstStep static INLINE BOOL writeLine(BYTE** ppRgba, UINT32 DstFormat, UINT32 width, const BYTE** ppR, const BYTE** ppG, const BYTE** ppB, const BYTE** ppA) { - UINT32 x = 0; - WINPR_ASSERT(ppRgba); WINPR_ASSERT(ppR); WINPR_ASSERT(ppG); @@ -544,7 +534,7 @@ static INLINE BOOL writeLine(BYTE** ppRgba, UINT32 DstFormat, UINT32 width, cons switch (DstFormat) { case PIXEL_FORMAT_BGRA32: - for (x = 0; x < width; x++) + for (UINT32 x = 0; x < width; x++) { *(*ppRgba)++ = *(*ppB)++; *(*ppRgba)++ = *(*ppG)++; @@ -555,7 +545,7 @@ static INLINE BOOL writeLine(BYTE** ppRgba, UINT32 DstFormat, UINT32 width, cons return TRUE; case PIXEL_FORMAT_BGRX32: - for (x = 0; x < width; x++) + for (UINT32 x = 0; x < width; x++) { *(*ppRgba)++ = *(*ppB)++; *(*ppRgba)++ = *(*ppG)++; @@ -568,7 +558,7 @@ static INLINE BOOL writeLine(BYTE** ppRgba, UINT32 DstFormat, UINT32 width, cons default: if (ppA) { - for (x = 0; x < width; x++) + for (UINT32 x = 0; x < width; x++) { BYTE alpha = *(*ppA)++; UINT32 color = @@ -581,7 +571,7 @@ static INLINE BOOL writeLine(BYTE** ppRgba, UINT32 DstFormat, UINT32 width, cons { const BYTE alpha = 0xFF; - for (x = 0; x < width; x++) + for (UINT32 x = 0; x < width; x++) { UINT32 color = FreeRDPGetColor(DstFormat, *(*ppR)++, *(*ppG)++, *(*ppB)++, alpha); @@ -599,7 +589,6 @@ static INLINE BOOL planar_decompress_planes_raw(const BYTE* pSrcData[4], BYTE* p UINT32 nYDst, UINT32 nWidth, UINT32 nHeight, BOOL vFlip, UINT32 totalHeight) { - INT32 y = 0; INT32 beg = 0; INT32 end = 0; INT32 inc = 0; @@ -640,7 +629,7 @@ static INLINE BOOL planar_decompress_planes_raw(const BYTE* pSrcData[4], BYTE* p return FALSE; } - for (y = beg; y != end; y += inc) + for (INT32 y = beg; y != end; y += inc) { BYTE* pRGB = NULL; @@ -665,7 +654,6 @@ static BOOL planar_subsample_expand(const BYTE* plane, size_t planeLength, UINT3 BYTE* deltaPlane) { size_t pos = 0; - UINT32 y = 0; WINPR_UNUSED(planeLength); WINPR_ASSERT(plane); @@ -685,12 +673,11 @@ static BOOL planar_subsample_expand(const BYTE* plane, size_t planeLength, UINT3 return FALSE; } - for (y = 0; y < nHeight; y++) + for (UINT32 y = 0; y < nHeight; y++) { const BYTE* src = plane + y / 2 * nPlaneWidth; - UINT32 x = 0; - for (x = 0; x < nWidth; x++) + for (UINT32 x = 0; x < nWidth; x++) { deltaPlane[pos++] = src[x / 2]; } @@ -1105,14 +1092,12 @@ static INLINE BOOL freerdp_split_color_planes(BITMAP_PLANAR_CONTEXT* planar, con if (planar->topdown) { - UINT32 i = 0; - UINT32 j = 0; UINT32 k = 0; - for (i = 0; i < height; i++) + for (UINT32 i = 0; i < height; i++) { const BYTE* pixel = &data[scanline * (UINT32)i]; - for (j = 0; j < width; j++) + for (UINT32 j = 0; j < width; j++) { const UINT32 color = FreeRDPReadColor(pixel, format); pixel += FreeRDPGetBytesPerPixel(format); @@ -1124,15 +1109,13 @@ static INLINE BOOL freerdp_split_color_planes(BITMAP_PLANAR_CONTEXT* planar, con } else { - INT64 i = 0; - UINT32 j = 0; UINT32 k = 0; - for (i = (INT64)height - 1; i >= 0; i--) + for (INT64 i = (INT64)height - 1; i >= 0; i--) { const BYTE* pixel = &data[scanline * (UINT32)i]; - for (j = 0; j < width; j++) + for (UINT32 j = 0; j < width; j++) { const UINT32 color = FreeRDPReadColor(pixel, format); pixel += FreeRDPGetBytesPerPixel(format); @@ -1434,8 +1417,6 @@ BYTE* freerdp_bitmap_planar_delta_encode_plane(const BYTE* inPlane, UINT32 width BYTE* outPlane) { char s2c = 0; - UINT32 y = 0; - UINT32 x = 0; BYTE* outPtr = NULL; const BYTE* srcPtr = NULL; const BYTE* prevLinePtr = NULL; @@ -1455,9 +1436,9 @@ BYTE* freerdp_bitmap_planar_delta_encode_plane(const BYTE* inPlane, UINT32 width srcPtr = inPlane + width; prevLinePtr = inPlane; - for (y = 1; y < height; y++) + for (UINT32 y = 1; y < height; y++) { - for (x = 0; x < width; x++, outPtr++, srcPtr++, prevLinePtr++) + for (UINT32 x = 0; x < width; x++, outPtr++, srcPtr++, prevLinePtr++) { INT32 delta = *srcPtr - *prevLinePtr; s2c = (delta >= 0) ? (char)delta : (char)(~((BYTE)(-delta)) + 1); @@ -1473,9 +1454,7 @@ BYTE* freerdp_bitmap_planar_delta_encode_plane(const BYTE* inPlane, UINT32 width static INLINE BOOL freerdp_bitmap_planar_delta_encode_planes(BYTE* inPlanes[4], UINT32 width, UINT32 height, BYTE* outPlanes[4]) { - UINT32 i = 0; - - for (i = 0; i < 4; i++) + for (UINT32 i = 0; i < 4; i++) { outPlanes[i] = freerdp_bitmap_planar_delta_encode_plane(inPlanes[i], width, height, outPlanes[i]); diff --git a/libfreerdp/codec/progressive.c b/libfreerdp/codec/progressive.c index 1d755df50..df98ad3a1 100644 --- a/libfreerdp/codec/progressive.c +++ b/libfreerdp/codec/progressive.c @@ -354,14 +354,13 @@ static void progressive_tile_free(RFX_PROGRESSIVE_TILE* tile) static void progressive_surface_context_free(void* ptr) { PROGRESSIVE_SURFACE_CONTEXT* surface = ptr; - UINT32 index = 0; if (!surface) return; if (surface->tiles) { - for (index = 0; index < surface->tilesSize; index++) + for (size_t index = 0; index < surface->tilesSize; index++) { RFX_PROGRESSIVE_TILE* tile = surface->tiles[index]; progressive_tile_free(tile); @@ -603,7 +602,6 @@ static INLINE void progressive_rfx_idwt_x(const INT16* pLowBand, size_t nLowStep size_t nDstStep, size_t nLowCount, size_t nHighCount, size_t nDstCount) { - size_t i = 0; INT16 L0 = 0; INT16 H0 = 0; INT16 H1 = 0; @@ -611,9 +609,8 @@ static INLINE void progressive_rfx_idwt_x(const INT16* pLowBand, size_t nLowStep INT16 X1 = 0; INT16 X2 = 0; - for (i = 0; i < nDstCount; i++) + for (size_t i = 0; i < nDstCount; i++) { - size_t j = 0; const INT16* pL = pLowBand; const INT16* pH = pHighBand; INT16* pX = pDstBand; @@ -622,7 +619,7 @@ static INLINE void progressive_rfx_idwt_x(const INT16* pLowBand, size_t nLowStep X0 = L0 - H0; X2 = L0 - H0; - for (j = 0; j < (nHighCount - 1); j++) + for (size_t j = 0; j < (nHighCount - 1); j++) { H1 = *pH; pH++; @@ -678,7 +675,6 @@ static INLINE void progressive_rfx_idwt_y(const INT16* pLowBand, size_t nLowStep size_t nDstStep, size_t nLowCount, size_t nHighCount, size_t nDstCount) { - size_t i = 0; INT16 L0 = 0; INT16 H0 = 0; INT16 H1 = 0; @@ -686,9 +682,8 @@ static INLINE void progressive_rfx_idwt_y(const INT16* pLowBand, size_t nLowStep INT16 X1 = 0; INT16 X2 = 0; - for (i = 0; i < nDstCount; i++) + for (size_t i = 0; i < nDstCount; i++) { - size_t j = 0; const INT16* pL = pLowBand; const INT16* pH = pHighBand; INT16* pX = pDstBand; @@ -699,7 +694,7 @@ static INLINE void progressive_rfx_idwt_y(const INT16* pLowBand, size_t nLowStep X0 = L0 - H0; X2 = L0 - H0; - for (j = 0; j < (nHighCount - 1); j++) + for (size_t j = 0; j < (nHighCount - 1); j++) { H1 = *pH; pH += nHighStep; @@ -1174,7 +1169,6 @@ static INLINE int progressive_rfx_upgrade_block(RFX_PROGRESSIVE_UPGRADE_STATE* s INT16* sign, UINT32 length, UINT32 shift, UINT32 bitPos, UINT32 numBits) { - UINT32 index = 0; INT16 input = 0; wBitStream* raw = NULL; @@ -1185,7 +1179,7 @@ static INLINE int progressive_rfx_upgrade_block(RFX_PROGRESSIVE_UPGRADE_STATE* s if (!state->nonLL) { - for (index = 0; index < length; index++) + for (UINT32 index = 0; index < length; index++) { raw->mask = ((1 << numBits) - 1); input = (INT16)((raw->accumulator >> (32 - numBits)) & raw->mask); @@ -1196,7 +1190,7 @@ static INLINE int progressive_rfx_upgrade_block(RFX_PROGRESSIVE_UPGRADE_STATE* s return 1; } - for (index = 0; index < length; index++) + for (UINT32 index = 0; index < length; index++) { if (sign[index] > 0) { @@ -1785,7 +1779,7 @@ static INLINE SSIZE_T progressive_process_tiles(PROGRESSIVE_CONTEXT* progressive return -1; } - for (index = 0; index < region->numTiles; index++) + for (UINT32 index = 0; index < region->numTiles; index++) { RFX_PROGRESSIVE_TILE* tile = region->tiles[index]; PROGRESSIVE_TILE_PROCESS_WORK_PARAM* param = ¶ms[index]; @@ -1827,7 +1821,7 @@ static INLINE SSIZE_T progressive_process_tiles(PROGRESSIVE_CONTEXT* progressive if (progressive->rfx_context->priv->UseThreads) { - for (index = 0; index < close_cnt; index++) + for (UINT32 index = 0; index < close_cnt; index++) { WaitForThreadpoolWorkCallbacks(work_objects[index], FALSE); CloseThreadpoolWork(work_objects[index]); @@ -2472,7 +2466,6 @@ int progressive_compress(PROGRESSIVE_CONTEXT* progressive, const BYTE* pSrcData, BOOL rc = FALSE; int res = -6; wStream* s = NULL; - UINT32 i = 0; UINT32 numRects = 0; UINT32 x = 0; UINT32 y = 0; @@ -2523,7 +2516,7 @@ int progressive_compress(PROGRESSIVE_CONTEXT* progressive, const BYTE* pSrcData, if (invalidRegion) { const RECTANGLE_16* region_rects = region16_rects(invalidRegion, NULL); - for (x = 0; x < numRects; x++) + for (UINT32 x = 0; x < numRects; x++) { const RECTANGLE_16* r = ®ion_rects[x]; RFX_RECT* rect = &rects[x]; @@ -2538,7 +2531,7 @@ int progressive_compress(PROGRESSIVE_CONTEXT* progressive, const BYTE* pSrcData, { x = 0; y = 0; - for (i = 0; i < numRects; i++) + for (UINT32 i = 0; i < numRects; i++) { RFX_RECT* r = &rects[i]; r->x = x; diff --git a/libfreerdp/codec/region.c b/libfreerdp/codec/region.c index 4c5176eda..ba7f3d2a4 100644 --- a/libfreerdp/codec/region.c +++ b/libfreerdp/codec/region.c @@ -235,12 +235,11 @@ void region16_print(const REGION16* region) { const RECTANGLE_16* rects = NULL; UINT32 nbRects = 0; - UINT32 i = 0; int currentBandY = -1; rects = region16_rects(region, &nbRects); WLog_DBG(TAG, "nrects=%" PRIu32 "", nbRects); - for (i = 0; i < nbRects; i++, rects++) + for (UINT32 i = 0; i < nbRects; i++, rects++) { if (rects->top != currentBandY) { diff --git a/libfreerdp/codec/rfx.c b/libfreerdp/codec/rfx.c index 6a61d9d7b..c83cfd5c1 100644 --- a/libfreerdp/codec/rfx.c +++ b/libfreerdp/codec/rfx.c @@ -700,7 +700,6 @@ static BOOL rfx_resize_rects(RFX_MESSAGE* message) static BOOL rfx_process_message_region(RFX_CONTEXT* context, RFX_MESSAGE* message, wStream* s, UINT16* pExpectedBlockType) { - UINT16 i = 0; UINT16 regionType = 0; UINT16 numTileSets = 0; @@ -749,7 +748,7 @@ static BOOL rfx_process_message_region(RFX_CONTEXT* context, RFX_MESSAGE* messag return FALSE; /* rects */ - for (i = 0; i < message->numRects; i++) + for (UINT16 i = 0; i < message->numRects; i++) { RFX_RECT* rect = rfx_message_get_rect(message, i); /* RFX_RECT */ diff --git a/libfreerdp/codec/rfx_differential.h b/libfreerdp/codec/rfx_differential.h index f77796991..70a1a8cb8 100644 --- a/libfreerdp/codec/rfx_differential.h +++ b/libfreerdp/codec/rfx_differential.h @@ -37,12 +37,11 @@ static INLINE void rfx_differential_decode(INT16* buffer, int size) static INLINE void rfx_differential_encode(INT16* buffer, int size) { - INT16 n1, n2; - INT16* dst; - - for (n1 = *buffer, dst = buffer + 1; size > 1; dst++, size--) + INT16 n1 = buffer[0]; + for (int x = 0; x < size - 1; x++) { - n2 = *dst; + INT16* dst = &buffer[x + 1]; + const INT16 n2 = *dst; *dst -= n1; n1 = n2; } diff --git a/libfreerdp/codec/rfx_dwt.c b/libfreerdp/codec/rfx_dwt.c index 31dc83985..e79e9da23 100644 --- a/libfreerdp/codec/rfx_dwt.c +++ b/libfreerdp/codec/rfx_dwt.c @@ -67,7 +67,7 @@ static void rfx_dwt_2d_decode_block(INT16* buffer, INT16* idwt, size_t subband_w /* Odd coefficients */ size_t n = 0; - for (n = 0; n < subband_width - 1; n++) + for (; n < subband_width - 1; n++) { const size_t x = n << 1; l_dst[x + 1] = (hl[n] << 1) + ((l_dst[x] + l_dst[x + 2]) >> 1); diff --git a/libfreerdp/codec/rfx_encode.c b/libfreerdp/codec/rfx_encode.c index 5aeb60e0a..10d4a414a 100644 --- a/libfreerdp/codec/rfx_encode.c +++ b/libfreerdp/codec/rfx_encode.c @@ -43,8 +43,6 @@ static void rfx_encode_format_rgb(const BYTE* rgb_data, int width, int height, i UINT32 pixel_format, const BYTE* palette, INT16* r_buf, INT16* g_buf, INT16* b_buf) { - int x = 0; - int y = 0; int x_exceed = 0; int y_exceed = 0; const BYTE* src = NULL; @@ -59,7 +57,7 @@ static void rfx_encode_format_rgb(const BYTE* rgb_data, int width, int height, i x_exceed = 64 - width; y_exceed = 64 - height; - for (y = 0; y < height; y++) + for (int y = 0; y < height; y++) { src = rgb_data + y * rowstride; @@ -67,7 +65,7 @@ static void rfx_encode_format_rgb(const BYTE* rgb_data, int width, int height, i { case PIXEL_FORMAT_BGRX32: case PIXEL_FORMAT_BGRA32: - for (x = 0; x < width; x++) + for (int x = 0; x < width; x++) { *b_buf++ = (INT16)(*src++); *g_buf++ = (INT16)(*src++); @@ -79,7 +77,7 @@ static void rfx_encode_format_rgb(const BYTE* rgb_data, int width, int height, i case PIXEL_FORMAT_XBGR32: case PIXEL_FORMAT_ABGR32: - for (x = 0; x < width; x++) + for (int x = 0; x < width; x++) { src++; *b_buf++ = (INT16)(*src++); @@ -91,7 +89,7 @@ static void rfx_encode_format_rgb(const BYTE* rgb_data, int width, int height, i case PIXEL_FORMAT_RGBX32: case PIXEL_FORMAT_RGBA32: - for (x = 0; x < width; x++) + for (int x = 0; x < width; x++) { *r_buf++ = (INT16)(*src++); *g_buf++ = (INT16)(*src++); @@ -103,7 +101,7 @@ static void rfx_encode_format_rgb(const BYTE* rgb_data, int width, int height, i case PIXEL_FORMAT_XRGB32: case PIXEL_FORMAT_ARGB32: - for (x = 0; x < width; x++) + for (int x = 0; x < width; x++) { src++; *r_buf++ = (INT16)(*src++); @@ -114,7 +112,7 @@ static void rfx_encode_format_rgb(const BYTE* rgb_data, int width, int height, i break; case PIXEL_FORMAT_BGR24: - for (x = 0; x < width; x++) + for (int x = 0; x < width; x++) { *b_buf++ = (INT16)(*src++); *g_buf++ = (INT16)(*src++); @@ -124,7 +122,7 @@ static void rfx_encode_format_rgb(const BYTE* rgb_data, int width, int height, i break; case PIXEL_FORMAT_RGB24: - for (x = 0; x < width; x++) + for (int x = 0; x < width; x++) { *r_buf++ = (INT16)(*src++); *g_buf++ = (INT16)(*src++); @@ -134,7 +132,7 @@ static void rfx_encode_format_rgb(const BYTE* rgb_data, int width, int height, i break; case PIXEL_FORMAT_BGR16: - for (x = 0; x < width; x++) + for (int x = 0; x < width; x++) { *b_buf++ = (INT16)(((*(src + 1)) & 0xF8) | ((*(src + 1)) >> 5)); *g_buf++ = (INT16)((((*(src + 1)) & 0x07) << 5) | (((*src) & 0xE0) >> 3)); @@ -145,7 +143,7 @@ static void rfx_encode_format_rgb(const BYTE* rgb_data, int width, int height, i break; case PIXEL_FORMAT_RGB16: - for (x = 0; x < width; x++) + for (int x = 0; x < width; x++) { *r_buf++ = (INT16)(((*(src + 1)) & 0xF8) | ((*(src + 1)) >> 5)); *g_buf++ = (INT16)((((*(src + 1)) & 0x07) << 5) | (((*src) & 0xE0) >> 3)); @@ -159,7 +157,7 @@ static void rfx_encode_format_rgb(const BYTE* rgb_data, int width, int height, i if (!palette) break; - for (x = 0; x < width; x++) + for (int x = 0; x < width; x++) { int shift = 0; BYTE idx = 0; @@ -183,7 +181,7 @@ static void rfx_encode_format_rgb(const BYTE* rgb_data, int width, int height, i if (!palette) break; - for (x = 0; x < width; x++) + for (int x = 0; x < width; x++) { int idx = (*src) * 3; *r_buf++ = (INT16)palette[idx]; @@ -206,7 +204,7 @@ static void rfx_encode_format_rgb(const BYTE* rgb_data, int width, int height, i g = *(g_buf - 1); b = *(b_buf - 1); - for (x = 0; x < x_exceed; x++) + for (int x = 0; x < x_exceed; x++) { *r_buf++ = r; *g_buf++ = g; diff --git a/libfreerdp/codec/rfx_neon.c b/libfreerdp/codec/rfx_neon.c index 4c4ab9fe1..f723efdbd 100644 --- a/libfreerdp/codec/rfx_neon.c +++ b/libfreerdp/codec/rfx_neon.c @@ -239,7 +239,6 @@ static INLINE void rfx_idwt_extrapolate_horiz_neon(INT16* restrict pLowBand, siz WINPR_ASSERT(pHighBand); WINPR_ASSERT(pDstBand); - size_t n; INT16* l_ptr = pLowBand; const INT16* h_ptr = pHighBand; INT16* dst_ptr = pDstBand; @@ -248,7 +247,8 @@ static INLINE void rfx_idwt_extrapolate_horiz_neon(INT16* restrict pLowBand, siz for (size_t y = 0; y < nDstCount; y++) { /* Even coefficients */ - for (n = 0; n < batchSize; n += 8) + size_t n = 0; + for (; n < batchSize; n += 8) { // dst[2n] = l[n] - ((h[n-1] + h[n] + 1) >> 1); int16x8_t l_n = vld1q_s16(l_ptr); @@ -278,7 +278,8 @@ static INLINE void rfx_idwt_extrapolate_horiz_neon(INT16* restrict pLowBand, siz h_ptr -= batchSize; /* Odd coefficients */ - for (n = 0; n < batchSize; n += 8) + n = 0; + for (; n < batchSize; n += 8) { // dst[2n + 1] = (h[n] << 1) + ((dst[2n] + dst[2n + 2]) >> 1); int16x8_t h_n = vld1q_s16(h_ptr); diff --git a/libfreerdp/codec/rfx_quantization.c b/libfreerdp/codec/rfx_quantization.c index 97bd50d1e..fb871a23c 100644 --- a/libfreerdp/codec/rfx_quantization.c +++ b/libfreerdp/codec/rfx_quantization.c @@ -70,7 +70,6 @@ void rfx_quantization_decode(INT16* buffer, const UINT32* WINPR_RESTRICT quantVa static void rfx_quantization_encode_block(INT16* buffer, size_t buffer_size, UINT32 factor) { - INT16* dst = NULL; INT16 half = 0; if (factor == 0) @@ -78,7 +77,7 @@ static void rfx_quantization_encode_block(INT16* buffer, size_t buffer_size, UIN half = (1 << (factor - 1)); /* Could probably use prims->rShiftC_16s(dst+half, factor, dst, buffer_size); */ - for (dst = buffer; buffer_size > 0; dst++, buffer_size--) + for (INT16* dst = buffer; buffer_size > 0; dst++, buffer_size--) { *dst = (*dst + half) >> factor; } diff --git a/libfreerdp/codec/rfx_sse2.c b/libfreerdp/codec/rfx_sse2.c index b668b119e..06cf8f45d 100644 --- a/libfreerdp/codec/rfx_sse2.c +++ b/libfreerdp/codec/rfx_sse2.c @@ -52,9 +52,9 @@ static __inline void __attribute__((ATTRIBUTES)) _mm_prefetch_buffer(char* buffer, int num_bytes) { __m128i* buf = (__m128i*)buffer; - unsigned int i = 0; - for (i = 0; i < (num_bytes / sizeof(__m128i)); i += (CACHE_LINE_BYTES / sizeof(__m128i))) + for (unsigned int i = 0; i < (num_bytes / sizeof(__m128i)); + i += (CACHE_LINE_BYTES / sizeof(__m128i))) { _mm_prefetch((char*)(&buf[i]), _MM_HINT_NTA); } @@ -146,8 +146,6 @@ static void rfx_quantization_encode_sse2(INT16* buffer, static __inline void __attribute__((ATTRIBUTES)) rfx_dwt_2d_decode_block_horiz_sse2(INT16* l, INT16* h, INT16* dst, int subband_width) { - int y = 0; - int n = 0; INT16* l_ptr = l; INT16* h_ptr = h; INT16* dst_ptr = dst; @@ -162,10 +160,10 @@ rfx_dwt_2d_decode_block_horiz_sse2(INT16* l, INT16* h, INT16* dst, int subband_w __m128i dst1; __m128i dst2; - for (y = 0; y < subband_width; y++) + for (int y = 0; y < subband_width; y++) { /* Even coefficients */ - for (n = 0; n < subband_width; n += 8) + for (int n = 0; n < subband_width; n += 8) { /* dst[2n] = l[n] - ((h[n-1] + h[n] + 1) >> 1); */ l_n = _mm_load_si128((__m128i*)l_ptr); @@ -191,7 +189,7 @@ rfx_dwt_2d_decode_block_horiz_sse2(INT16* l, INT16* h, INT16* dst, int subband_w h_ptr -= subband_width; /* Odd coefficients */ - for (n = 0; n < subband_width; n += 8) + for (int n = 0; n < subband_width; n += 8) { /* dst[2n + 1] = (h[n] << 1) + ((dst[2n] + dst[2n + 2]) >> 1); */ h_n = _mm_load_si128((__m128i*)h_ptr); @@ -222,8 +220,6 @@ rfx_dwt_2d_decode_block_horiz_sse2(INT16* l, INT16* h, INT16* dst, int subband_w static __inline void __attribute__((ATTRIBUTES)) rfx_dwt_2d_decode_block_vert_sse2(INT16* l, INT16* h, INT16* dst, int subband_width) { - int x = 0; - int n = 0; INT16* l_ptr = l; INT16* h_ptr = h; INT16* dst_ptr = dst; @@ -237,9 +233,9 @@ rfx_dwt_2d_decode_block_vert_sse2(INT16* l, INT16* h, INT16* dst, int subband_wi int total_width = subband_width + subband_width; /* Even coefficients */ - for (n = 0; n < subband_width; n++) + for (int n = 0; n < subband_width; n++) { - for (x = 0; x < total_width; x += 8) + for (int x = 0; x < total_width; x += 8) { /* dst[2n] = l[n] - ((h[n-1] + h[n] + 1) >> 1); */ l_n = _mm_load_si128((__m128i*)l_ptr); @@ -269,9 +265,9 @@ rfx_dwt_2d_decode_block_vert_sse2(INT16* l, INT16* h, INT16* dst, int subband_wi dst_ptr = dst + total_width; /* Odd coefficients */ - for (n = 0; n < subband_width; n++) + for (int n = 0; n < subband_width; n++) { - for (x = 0; x < total_width; x += 8) + for (int x = 0; x < total_width; x += 8) { /* dst[2n + 1] = (h[n] << 1) + ((dst[2n] + dst[2n + 2]) >> 1); */ h_n = _mm_load_si128((__m128i*)h_ptr); @@ -340,8 +336,6 @@ static __inline void __attribute__((ATTRIBUTES)) rfx_dwt_2d_encode_block_vert_sse2(INT16* src, INT16* l, INT16* h, int subband_width) { int total_width = 0; - int x = 0; - int n = 0; __m128i src_2n; __m128i src_2n_1; __m128i src_2n_2; @@ -350,9 +344,9 @@ rfx_dwt_2d_encode_block_vert_sse2(INT16* src, INT16* l, INT16* h, int subband_wi __m128i l_n; total_width = subband_width << 1; - for (n = 0; n < subband_width; n++) + for (int n = 0; n < subband_width; n++) { - for (x = 0; x < total_width; x += 8) + for (int x = 0; x < total_width; x += 8) { src_2n = _mm_load_si128((__m128i*)src); src_2n_1 = _mm_load_si128((__m128i*)(src + total_width)); @@ -391,8 +385,6 @@ rfx_dwt_2d_encode_block_vert_sse2(INT16* src, INT16* l, INT16* h, int subband_wi static __inline void __attribute__((ATTRIBUTES)) rfx_dwt_2d_encode_block_horiz_sse2(INT16* src, INT16* l, INT16* h, int subband_width) { - int y = 0; - int n = 0; int first = 0; __m128i src_2n; __m128i src_2n_1; @@ -401,9 +393,9 @@ rfx_dwt_2d_encode_block_horiz_sse2(INT16* src, INT16* l, INT16* h, int subband_w __m128i h_n_m; __m128i l_n; - for (y = 0; y < subband_width; y++) + for (int y = 0; y < subband_width; y++) { - for (n = 0; n < subband_width; n += 8) + for (int n = 0; n < subband_width; n += 8) { /* The following 3 Set operations consumes more than half of the total DWT processing * time! */ diff --git a/libfreerdp/codec/test/TestFreeRDPCodecInterleaved.c b/libfreerdp/codec/test/TestFreeRDPCodecInterleaved.c index 17631d047..e8cbb6a24 100644 --- a/libfreerdp/codec/test/TestFreeRDPCodecInterleaved.c +++ b/libfreerdp/codec/test/TestFreeRDPCodecInterleaved.c @@ -23,8 +23,6 @@ static BOOL run_encode_decode_single(UINT16 bpp, BITMAP_INTERLEAVED_CONTEXT* enc { BOOL rc2 = FALSE; BOOL rc = 0; - UINT32 i = 0; - UINT32 j = 0; const UINT32 w = 64; const UINT32 h = 64; const UINT32 x = 0; @@ -63,12 +61,12 @@ static BOOL run_encode_decode_single(UINT16 bpp, BITMAP_INTERLEAVED_CONTEXT* enc if (!rc) goto fail; - for (i = 0; i < h; i++) + for (UINT32 i = 0; i < h; i++) { const BYTE* srcLine = &pSrcData[i * step]; const BYTE* dstLine = &pDstData[i * step]; - for (j = 0; j < w; j++) + for (UINT32 j = 0; j < w; j++) { BYTE r = 0; BYTE g = 0; @@ -131,13 +129,12 @@ static BOOL run_encode_decode(UINT16 bpp, BITMAP_INTERLEAVED_CONTEXT* encoder, BITMAP_INTERLEAVED_CONTEXT* decoder) { BOOL rc = FALSE; - UINT32 x = 0; PROFILER_DEFINE(profiler_comp) PROFILER_DEFINE(profiler_decomp) PROFILER_CREATE(profiler_comp, get_profiler_name(TRUE, bpp)) PROFILER_CREATE(profiler_decomp, get_profiler_name(FALSE, bpp)) - for (x = 0; x < 50; x++) + for (UINT32 x = 0; x < 50; x++) { if (!run_encode_decode_single(bpp, encoder, decoder #if defined(WITH_PROFILER) @@ -163,10 +160,9 @@ static BOOL TestColorConversion(void) { const UINT32 formats[] = { PIXEL_FORMAT_RGB15, PIXEL_FORMAT_BGR15, PIXEL_FORMAT_ABGR15, PIXEL_FORMAT_ARGB15, PIXEL_FORMAT_BGR16, PIXEL_FORMAT_RGB16 }; - UINT32 x = 0; /* Check color conversion 15/16 -> 32bit maps to proper values */ - for (x = 0; x < ARRAYSIZE(formats); x++) + for (UINT32 x = 0; x < ARRAYSIZE(formats); x++) { const UINT32 dstFormat = PIXEL_FORMAT_RGBA32; const UINT32 format = formats[x]; diff --git a/libfreerdp/codec/test/TestFreeRDPCodecPlanar.c b/libfreerdp/codec/test/TestFreeRDPCodecPlanar.c index 05fbef569..ba4c5c63f 100644 --- a/libfreerdp/codec/test/TestFreeRDPCodecPlanar.c +++ b/libfreerdp/codec/test/TestFreeRDPCodecPlanar.c @@ -5427,8 +5427,6 @@ static BOOL CompareBitmap(const BYTE* srcA, UINT32 srcAFormat, const BYTE* srcB, const UINT32 srcABits = FreeRDPGetBitsPerPixel(srcAFormat); const UINT32 srcBBits = FreeRDPGetBitsPerPixel(srcBFormat); UINT32 diff = fabs((double)srcABits - srcBBits); - UINT32 x = 0; - UINT32 y = 0; /* No support for 8bpp */ if ((srcABits < 15) || (srcBBits < 15)) @@ -5463,12 +5461,12 @@ static BOOL CompareBitmap(const BYTE* srcA, UINT32 srcAFormat, const BYTE* srcB, maxDiff = 0.0; } - for (y = 0; y < height; y++) + for (UINT32 y = 0; y < height; y++) { const BYTE* lineA = &srcA[width * FreeRDPGetBytesPerPixel(srcAFormat) * y]; const BYTE* lineB = &srcB[width * FreeRDPGetBytesPerPixel(srcBFormat) * y]; - for (x = 0; x < width; x++) + for (UINT32 x = 0; x < width; x++) { BYTE sR = 0; BYTE sG = 0; @@ -5549,18 +5547,14 @@ fail: static BOOL RunTestPlanarSingleColor(BITMAP_PLANAR_CONTEXT* planar, const UINT32 srcFormat, const UINT32 dstFormat) { - UINT32 i = 0; - UINT32 j = 0; - UINT32 x = 0; - UINT32 y = 0; BOOL rc = FALSE; printf("%s: [%s] --> [%s]: ", __func__, FreeRDPGetColorFormatName(srcFormat), FreeRDPGetColorFormatName(dstFormat)); fflush(stdout); - for (j = 0; j < 32; j += 8) + for (UINT32 j = 0; j < 32; j += 8) { - for (i = 4; i < 32; i += 8) + for (UINT32 i = 4; i < 32; i += 8) { UINT32 compressedSize = 0; const UINT32 fill = j; @@ -5578,11 +5572,11 @@ static BOOL RunTestPlanarSingleColor(BITMAP_PLANAR_CONTEXT* planar, const UINT32 if (!bmp || !decompressedBitmap) goto fail_loop; - for (y = 0; y < height; y++) + for (UINT32 y = 0; y < height; y++) { BYTE* line = &bmp[width * FreeRDPGetBytesPerPixel(srcFormat) * y]; - for (x = 0; x < width; x++) + for (UINT32 x = 0; x < width; x++) { FreeRDPWriteColor(line, srcFormat, color); line += FreeRDPGetBytesPerPixel(srcFormat); @@ -5626,7 +5620,6 @@ fail: static BOOL TestPlanar(const UINT32 format) { - UINT32 x = 0; BOOL rc = FALSE; const DWORD planarFlags = PLANAR_FORMAT_HEADER_NA | PLANAR_FORMAT_HEADER_RLE; BITMAP_PLANAR_CONTEXT* planar = freerdp_bitmap_planar_context_new(planarFlags, 64, 64); @@ -5650,7 +5643,7 @@ static BOOL TestPlanar(const UINT32 format) 32)) goto fail; - for (x = 0; x < colorFormatCount; x++) + for (UINT32 x = 0; x < colorFormatCount; x++) { if (!RunTestPlanarSingleColor(planar, format, colorFormatList[x])) goto fail; @@ -5673,7 +5666,6 @@ static UINT32 prand(UINT32 max) static BOOL FuzzPlanar(void) { - UINT32 x = 0; BOOL rc = FALSE; const DWORD planarFlags = PLANAR_FORMAT_HEADER_NA | PLANAR_FORMAT_HEADER_RLE; BITMAP_PLANAR_CONTEXT* planar = freerdp_bitmap_planar_context_new(planarFlags, 64, 64); @@ -5681,7 +5673,7 @@ static BOOL FuzzPlanar(void) if (!planar) goto fail; - for (x = 0; x < 100; x++) + for (UINT32 x = 0; x < 100; x++) { BYTE data[0x10000] = { 0 }; size_t dataSize = 0x10000; @@ -5777,14 +5769,13 @@ fail: int TestFreeRDPCodecPlanar(int argc, char* argv[]) { - UINT32 x = 0; WINPR_UNUSED(argc); WINPR_UNUSED(argv); if (!FuzzPlanar()) return -2; - for (x = 0; x < colorFormatCount; x++) + for (UINT32 x = 0; x < colorFormatCount; x++) { if (!TestPlanar(colorFormatList[x])) return -1; diff --git a/libfreerdp/codec/test/TestFreeRDPCodecProgressive.c b/libfreerdp/codec/test/TestFreeRDPCodecProgressive.c index 4767604b7..fb36595d7 100644 --- a/libfreerdp/codec/test/TestFreeRDPCodecProgressive.c +++ b/libfreerdp/codec/test/TestFreeRDPCodecProgressive.c @@ -150,13 +150,11 @@ static void sample_file_free(EGFX_SAMPLE_FILE* file) static void test_fill_image_alpha_channel(BYTE* data, int width, int height, BYTE value) { - int i = 0; - int j = 0; UINT32* pixel = NULL; - for (i = 0; i < height; i++) + for (int i = 0; i < height; i++) { - for (j = 0; j < width; j++) + for (int j = 0; j < width; j++) { pixel = (UINT32*)&data[((i * width) + j) * 4]; *pixel = ((*pixel & 0x00FFFFFF) | (value << 24)); @@ -177,13 +175,12 @@ static void* test_image_memset32(UINT32* ptr, UINT32 fill, size_t length) static int test_image_fill(BYTE* pDstData, int nDstStep, int nXDst, int nYDst, int nWidth, int nHeight, UINT32 color) { - int y = 0; UINT32* pDstPixel = NULL; if (nDstStep < 0) nDstStep = 4 * nWidth; - for (y = 0; y < nHeight; y++) + for (int y = 0; y < nHeight; y++) { pDstPixel = (UINT32*)&pDstData[((nYDst + y) * nDstStep) + (nXDst * 4)]; test_image_memset32(pDstPixel, color, nWidth); @@ -904,9 +901,6 @@ static int test_progressive_decode(PROGRESSIVE_CONTEXT* progressive, EGFX_SAMPLE static int test_progressive_ms_sample(char* ms_sample_path) { - int i = 0; - int j = 0; - int k = 0; int count = 0; int status = 0; EGFX_SAMPLE_FILE files[3][4][4] = { 0 }; @@ -919,11 +913,11 @@ static int test_progressive_ms_sample(char* ms_sample_path) if (status < 0) { - for (i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { - for (j = 0; j < 4; j++) + for (int j = 0; j < 4; j++) { - for (k = 0; k < 4; k++) + for (int k = 0; k < 4; k++) sample_file_free(&files[i][j][k]); } } @@ -935,11 +929,11 @@ static int test_progressive_ms_sample(char* ms_sample_path) if (status < 0) { - for (i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { - for (j = 0; j < 4; j++) + for (int j = 0; j < 4; j++) { - for (k = 0; k < 4; k++) + for (int k = 0; k < 4; k++) sample_file_free(&files[i][j][k]); } } @@ -990,11 +984,11 @@ static int test_progressive_ms_sample(char* ms_sample_path) progressive_context_free(progressive); - for (i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { - for (j = 0; j < 4; j++) + for (int j = 0; j < 4; j++) { - for (k = 0; k < 4; k++) + for (int k = 0; k < 4; k++) { sample_file_free(&bitmaps[i][j][k]); sample_file_free(&files[i][j][k]); diff --git a/libfreerdp/codec/test/TestFreeRDPCodecRemoteFX.c b/libfreerdp/codec/test/TestFreeRDPCodecRemoteFX.c index f15c07533..be67cea70 100644 --- a/libfreerdp/codec/test/TestFreeRDPCodecRemoteFX.c +++ b/libfreerdp/codec/test/TestFreeRDPCodecRemoteFX.c @@ -809,10 +809,9 @@ static INLINE size_t fuzzyCompare(BYTE b1, BYTE b2) static BOOL fuzzyCompareImage(const UINT32* crefImage, const BYTE* img, size_t npixels) { - size_t i = 0; size_t totalDelta = 0; - for (i = 0; i < npixels; i++, crefImage++) + for (size_t i = 0; i < npixels; i++, crefImage++) { BYTE A = *img++; BYTE R = *img++; diff --git a/libfreerdp/codec/test/TestFreeRDPCodecXCrush.c b/libfreerdp/codec/test/TestFreeRDPCodecXCrush.c index f7abfb1e7..5b13532c2 100644 --- a/libfreerdp/codec/test/TestFreeRDPCodecXCrush.c +++ b/libfreerdp/codec/test/TestFreeRDPCodecXCrush.c @@ -114,12 +114,11 @@ static const struct test_argument tests[] = { int TestFreeRDPCodecXCrush(int argc, char* argv[]) { int rc = 0; - size_t x = 0; WINPR_UNUSED(argc); WINPR_UNUSED(argv); - for (x = 0; x < ARRAYSIZE(tests); x++) + for (size_t x = 0; x < ARRAYSIZE(tests); x++) { const struct test_argument* arg = &tests[x]; diff --git a/libfreerdp/codec/test/TestFreeRDPRegion.c b/libfreerdp/codec/test/TestFreeRDPRegion.c index 625ee9760..6f753200d 100644 --- a/libfreerdp/codec/test/TestFreeRDPRegion.c +++ b/libfreerdp/codec/test/TestFreeRDPRegion.c @@ -24,9 +24,7 @@ static BOOL compareRectangles(const RECTANGLE_16* src1, const RECTANGLE_16* src2, int nb) { - int i = 0; - - for (i = 0; i < nb; i++, src1++, src2++) + for (int i = 0; i < nb; i++, src1++, src2++) { if (memcmp(src1, src2, sizeof(RECTANGLE_16))) { @@ -636,7 +634,6 @@ static int test_norbert_case(void) int retCode = -1; const RECTANGLE_16* rects = NULL; UINT32 nbRects = 0; - UINT32 i = 0; RECTANGLE_16 inRectangles[5] = { { 1680, 0, 1920, 242 }, { 294, 242, 971, 776 }, { 1680, 242, 1920, 776 }, @@ -673,7 +670,7 @@ static int test_norbert_case(void) * After intersected with the full screen rect, the * result should keep the same. */ - for (i = 0; i < 5; i++) + for (int i = 0; i < 5; i++) { if (!region16_union_rect(®ion, ®ion, &inRectangles[i])) goto out; @@ -777,7 +774,6 @@ static int test_empty_rectangle(void) REGION16 region; REGION16 intersection; int retCode = -1; - int i = 0; RECTANGLE_16 emptyRectangles[3] = { { 0, 0, 0, 0 }, { 10, 10, 10, 11 }, { 10, 10, 11, 10 } }; RECTANGLE_16 firstRect = { 0, 0, 100, 100 }; RECTANGLE_16 anotherRect = { 100, 100, 200, 200 }; @@ -786,7 +782,7 @@ static int test_empty_rectangle(void) region16_init(&intersection); /* Check for empty rectangles */ - for (i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { if (!rectangle_is_empty(&emptyRectangles[i])) goto out; @@ -845,13 +841,12 @@ static struct UnitaryTest tests[] = { { "Basic trivial tests", test_basic }, int TestFreeRDPRegion(int argc, char* argv[]) { - int i = 0; int testNb = 0; int retCode = -1; WINPR_UNUSED(argc); WINPR_UNUSED(argv); - for (i = 0; tests[i].func; i++) + for (int i = 0; tests[i].func; i++) { testNb++; fprintf(stderr, "%d: %s\n", testNb, tests[i].name); diff --git a/libfreerdp/codec/xcrush.c b/libfreerdp/codec/xcrush.c index 2b41c7ea4..eed2a8648 100644 --- a/libfreerdp/codec/xcrush.c +++ b/libfreerdp/codec/xcrush.c @@ -217,7 +217,6 @@ static int xcrush_append_chunk(XCRUSH_CONTEXT* xcrush, const BYTE* data, UINT32* static int xcrush_compute_chunks(XCRUSH_CONTEXT* xcrush, const BYTE* data, UINT32 size, UINT32* pIndex) { - UINT32 i = 0; UINT32 offset = 0; UINT32 rotation = 0; UINT32 accumulator = 0; @@ -232,13 +231,13 @@ static int xcrush_compute_chunks(XCRUSH_CONTEXT* xcrush, const BYTE* data, UINT3 if (size < 128) return 0; - for (i = 0; i < 32; i++) + for (UINT32 i = 0; i < 32; i++) { rotation = _rotl(accumulator, 1); accumulator = data[i] ^ rotation; } - for (i = 0; i < size - 64; i++) + for (UINT32 i = 0; i < size - 64; i++) { rotation = _rotl(accumulator, 1); accumulator = data[i + 32] ^ data[i] ^ rotation; @@ -301,11 +300,9 @@ static UINT32 xcrush_compute_signatures(XCRUSH_CONTEXT* xcrush, const BYTE* data static void xcrush_clear_hash_table_range(XCRUSH_CONTEXT* xcrush, UINT32 beg, UINT32 end) { - UINT32 index = 0; - WINPR_ASSERT(xcrush); - for (index = 0; index < 65536; index++) + for (UINT32 index = 0; index < 65536; index++) { if (xcrush->NextChunks[index] >= beg) { @@ -316,7 +313,7 @@ static void xcrush_clear_hash_table_range(XCRUSH_CONTEXT* xcrush, UINT32 beg, UI } } - for (index = 0; index < 65534; index++) + for (UINT32 index = 0; index < 65534; index++) { if (xcrush->Chunks[index].next >= beg) { @@ -503,7 +500,6 @@ static int xcrush_find_match_length(XCRUSH_CONTEXT* xcrush, UINT32 MatchOffset, static int xcrush_find_all_matches(XCRUSH_CONTEXT* xcrush, UINT32 SignatureIndex, UINT32 HistoryOffset, UINT32 SrcOffset, UINT32 SrcSize) { - UINT32 i = 0; UINT32 j = 0; int status = 0; UINT32 ChunkIndex = 0; @@ -519,7 +515,7 @@ static int xcrush_find_all_matches(XCRUSH_CONTEXT* xcrush, UINT32 SignatureIndex Signatures = xcrush->Signatures; - for (i = 0; i < SignatureIndex; i++) + for (UINT32 i = 0; i < SignatureIndex; i++) { XCRUSH_MATCH_INFO MatchInfo = { 0 }; UINT32 offset = SrcOffset + HistoryOffset; @@ -605,7 +601,6 @@ static int xcrush_find_all_matches(XCRUSH_CONTEXT* xcrush, UINT32 SignatureIndex static int xcrush_optimize_matches(XCRUSH_CONTEXT* xcrush) { - UINT32 i = 0; UINT32 j = 0; UINT32 MatchDiff = 0; UINT32 PrevMatchEnd = 0; @@ -623,7 +618,7 @@ static int xcrush_optimize_matches(XCRUSH_CONTEXT* xcrush) OriginalMatchCount = xcrush->OriginalMatchCount; OptimizedMatches = xcrush->OptimizedMatches; - for (i = 0; i < OriginalMatchCount; i++) + for (UINT32 i = 0; i < OriginalMatchCount; i++) { if (OriginalMatches[i].MatchOffset <= PrevMatchEnd) { diff --git a/libfreerdp/codec/yuv.c b/libfreerdp/codec/yuv.c index 8823ebb3d..c54656605 100644 --- a/libfreerdp/codec/yuv.c +++ b/libfreerdp/codec/yuv.c @@ -329,11 +329,9 @@ static BOOL submit_object(PTP_WORK* work_object, PTP_WORK_CALLBACK cb, const voi static void free_objects(PTP_WORK* work_objects, UINT32 waitCount) { - UINT32 i = 0; - WINPR_ASSERT(work_objects || (waitCount == 0)); - for (i = 0; i < waitCount; i++) + for (UINT32 i = 0; i < waitCount; i++) { PTP_WORK cur = work_objects[i]; work_objects[i] = NULL; @@ -348,11 +346,9 @@ static void free_objects(PTP_WORK* work_objects, UINT32 waitCount) static BOOL intersects(UINT32 pos, const RECTANGLE_16* regionRects, UINT32 numRegionRects) { - UINT32 x = 0; - WINPR_ASSERT(regionRects || (numRegionRects == 0)); - for (x = pos + 1; x < numRegionRects; x++) + for (UINT32 x = pos + 1; x < numRegionRects; x++) { const RECTANGLE_16* what = ®ionRects[pos]; const RECTANGLE_16* rect = ®ionRects[x]; @@ -386,7 +382,6 @@ static BOOL pool_decode(YUV_CONTEXT* context, PTP_WORK_CALLBACK cb, const BYTE* UINT32 nDstStep, const RECTANGLE_16* regionRects, UINT32 numRegionRects) { BOOL rc = FALSE; - UINT32 x = 0; UINT32 waitCount = 0; primitives_t* prims = primitives_get(); @@ -416,7 +411,7 @@ static BOOL pool_decode(YUV_CONTEXT* context, PTP_WORK_CALLBACK cb, const BYTE* } /* case where we use threads */ - for (x = 0; x < numRegionRects; x++) + for (UINT32 x = 0; x < numRegionRects; x++) { RECTANGLE_16 r = clamp(context, ®ionRects[x], yuvHeight); @@ -550,7 +545,6 @@ static BOOL pool_decode_rect(YUV_CONTEXT* context, BYTE type, const BYTE* pYUVDa UINT32 numRegionRects) { BOOL rc = FALSE; - UINT32 y = 0; UINT32 waitCount = 0; PTP_WORK_CALLBACK cb = yuv444_combine_work_callback; primitives_t* prims = primitives_get(); @@ -564,7 +558,7 @@ static BOOL pool_decode_rect(YUV_CONTEXT* context, BYTE type, const BYTE* pYUVDa if (!context->useThreads || (primitives_flags(prims) & PRIM_FLAGS_HAVE_EXTGPU)) { - for (y = 0; y < numRegionRects; y++) + for (UINT32 y = 0; y < numRegionRects; y++) { YUV_COMBINE_WORK_PARAM current = pool_decode_rect_param( ®ionRects[y], context, type, pYUVData, iStride, pYUVDstData, iDstStride); @@ -786,8 +780,6 @@ static BOOL pool_encode(YUV_CONTEXT* context, PTP_WORK_CALLBACK cb, const BYTE* { BOOL rc = FALSE; primitives_t* prims = primitives_get(); - UINT32 x = 0; - UINT32 y = 0; UINT32 waitCount = 0; WINPR_ASSERT(context); @@ -805,7 +797,7 @@ static BOOL pool_encode(YUV_CONTEXT* context, PTP_WORK_CALLBACK cb, const BYTE* if (!context->useThreads || (primitives_flags(prims) & PRIM_FLAGS_HAVE_EXTGPU)) { - for (x = 0; x < numRegionRects; x++) + for (UINT32 x = 0; x < numRegionRects; x++) { YUV_ENCODE_WORK_PARAM current = pool_encode_fill(®ionRects[x], context, pSrcData, nSrcStep, SrcFormat, iStride, @@ -816,7 +808,7 @@ static BOOL pool_encode(YUV_CONTEXT* context, PTP_WORK_CALLBACK cb, const BYTE* } /* case where we use threads */ - for (x = 0; x < numRegionRects; x++) + for (UINT32 x = 0; x < numRegionRects; x++) { const RECTANGLE_16* rect = ®ionRects[x]; const UINT32 height = rect->bottom - rect->top; @@ -825,13 +817,13 @@ static BOOL pool_encode(YUV_CONTEXT* context, PTP_WORK_CALLBACK cb, const BYTE* waitCount += steps; } - for (x = 0; x < numRegionRects; x++) + for (UINT32 x = 0; x < numRegionRects; x++) { const RECTANGLE_16* rect = ®ionRects[x]; const UINT32 height = rect->bottom - rect->top; const UINT32 steps = (height + context->heightStep / 2) / context->heightStep; - for (y = 0; y < steps; y++) + for (UINT32 y = 0; y < steps; y++) { RECTANGLE_16 r = *rect; YUV_ENCODE_WORK_PARAM* current = NULL; diff --git a/libfreerdp/codec/zgfx.c b/libfreerdp/codec/zgfx.c index 29cb720b4..881823ab3 100644 --- a/libfreerdp/codec/zgfx.c +++ b/libfreerdp/codec/zgfx.c @@ -496,7 +496,7 @@ int zgfx_compress_to_stream(ZGFX_CONTEXT* zgfx, wStream* sDst, const BYTE* pUnco totalLength = uncompressedSize; pSrcData = pUncompressed; - for (fragment = 0; (totalLength > 0) || (fragment == 0); fragment++) + for (; (totalLength > 0) || (fragment == 0); fragment++) { UINT32 SrcSize = 0; size_t posDstSize = 0; diff --git a/libfreerdp/common/settings.c b/libfreerdp/common/settings.c index 48f797134..34712c81a 100644 --- a/libfreerdp/common/settings.c +++ b/libfreerdp/common/settings.c @@ -73,10 +73,9 @@ BOOL freerdp_addin_argv_add_argument(ADDIN_ARGV* args, const char* argument) BOOL freerdp_addin_argv_del_argument(ADDIN_ARGV* args, const char* argument) { - int x = 0; if (!args || !argument) return FALSE; - for (x = 0; x < args->argc; x++) + for (int x = 0; x < args->argc; x++) { char* arg = args->argv[x]; if (strcmp(argument, arg) == 0) @@ -94,11 +93,10 @@ BOOL freerdp_addin_argv_del_argument(ADDIN_ARGV* args, const char* argument) int freerdp_addin_set_argument(ADDIN_ARGV* args, const char* argument) { - int i = 0; if (!args || !argument) return -2; - for (i = 0; i < args->argc; i++) + for (int i = 0; i < args->argc; i++) { if (strcmp(args->argv[i], argument) == 0) { @@ -113,12 +111,10 @@ int freerdp_addin_set_argument(ADDIN_ARGV* args, const char* argument) int freerdp_addin_replace_argument(ADDIN_ARGV* args, const char* previous, const char* argument) { - int i = 0; - if (!args || !previous || !argument) return -2; - for (i = 0; i < args->argc; i++) + for (int i = 0; i < args->argc; i++) { if (strcmp(args->argv[i], previous) == 0) { @@ -139,7 +135,6 @@ int freerdp_addin_replace_argument(ADDIN_ARGV* args, const char* previous, const int freerdp_addin_set_argument_value(ADDIN_ARGV* args, const char* option, const char* value) { BOOL rc = 0; - int i = 0; char* p = NULL; char* str = NULL; size_t length = 0; @@ -153,7 +148,7 @@ int freerdp_addin_set_argument_value(ADDIN_ARGV* args, const char* option, const sprintf_s(str, length + 1, "%s:%s", option, value); - for (i = 0; i < args->argc; i++) + for (int i = 0; i < args->argc; i++) { p = strchr(args->argv[i], ':'); @@ -178,7 +173,6 @@ int freerdp_addin_set_argument_value(ADDIN_ARGV* args, const char* option, const int freerdp_addin_replace_argument_value(ADDIN_ARGV* args, const char* previous, const char* option, const char* value) { - int i = 0; BOOL rc = 0; char* str = NULL; size_t length = 0; @@ -192,7 +186,7 @@ int freerdp_addin_replace_argument_value(ADDIN_ARGV* args, const char* previous, sprintf_s(str, length + 1, "%s:%s", option, value); - for (i = 0; i < args->argc; i++) + for (int i = 0; i < args->argc; i++) { if (strcmp(args->argv[i], previous) == 0) { @@ -245,12 +239,11 @@ BOOL freerdp_device_collection_add(rdpSettings* settings, RDPDR_DEVICE* device) RDPDR_DEVICE* freerdp_device_collection_find(rdpSettings* settings, const char* name) { - UINT32 index = 0; RDPDR_DEVICE* device = NULL; WINPR_ASSERT(settings); WINPR_ASSERT(name); - for (index = 0; index < settings->DeviceCount; index++) + for (UINT32 index = 0; index < settings->DeviceCount; index++) { device = (RDPDR_DEVICE*)settings->DeviceArray[index]; @@ -266,11 +259,10 @@ RDPDR_DEVICE* freerdp_device_collection_find(rdpSettings* settings, const char* RDPDR_DEVICE* freerdp_device_collection_find_type(rdpSettings* settings, UINT32 type) { - UINT32 index = 0; RDPDR_DEVICE* device = NULL; WINPR_ASSERT(settings); - for (index = 0; index < settings->DeviceCount; index++) + for (UINT32 index = 0; index < settings->DeviceCount; index++) { device = (RDPDR_DEVICE*)settings->DeviceArray[index]; @@ -539,13 +531,11 @@ RDPDR_DEVICE* freerdp_device_clone(const RDPDR_DEVICE* device) void freerdp_device_collection_free(rdpSettings* settings) { - UINT32 index = 0; - WINPR_ASSERT(settings); if (settings->DeviceArray) { - for (index = 0; index < settings->DeviceArraySize; index++) + for (UINT32 index = 0; index < settings->DeviceArraySize; index++) freerdp_settings_set_pointer_array(settings, FreeRDP_DeviceArray, index, NULL); } @@ -558,12 +548,11 @@ void freerdp_device_collection_free(rdpSettings* settings) BOOL freerdp_static_channel_collection_del(rdpSettings* settings, const char* name) { - UINT32 x = 0; const UINT32 count = freerdp_settings_get_uint32(settings, FreeRDP_StaticChannelCount); if (!settings || !settings->StaticChannelArray) return FALSE; - for (x = 0; x < count; x++) + for (UINT32 x = 0; x < count; x++) { ADDIN_ARGV* cur = settings->StaticChannelArray[x]; if (cur && (cur->argc > 0)) @@ -630,14 +619,13 @@ BOOL freerdp_static_channel_collection_add(rdpSettings* settings, ADDIN_ARGV* ch ADDIN_ARGV* freerdp_static_channel_collection_find(rdpSettings* settings, const char* name) { - UINT32 index = 0; ADDIN_ARGV* channel = NULL; WINPR_ASSERT(settings); WINPR_ASSERT(name); - for (index = 0; index < freerdp_settings_get_uint32(settings, FreeRDP_StaticChannelCount); - index++) + for (UINT32 index = 0; + index < freerdp_settings_get_uint32(settings, FreeRDP_StaticChannelCount); index++) { channel = settings->StaticChannelArray[index]; @@ -650,14 +638,13 @@ ADDIN_ARGV* freerdp_static_channel_collection_find(rdpSettings* settings, const void freerdp_static_channel_collection_free(rdpSettings* settings) { - UINT32 i = 0; - if (!settings) return; if (settings->StaticChannelArray) { - for (i = 0; i < freerdp_settings_get_uint32(settings, FreeRDP_StaticChannelArraySize); i++) + for (UINT32 i = 0; + i < freerdp_settings_get_uint32(settings, FreeRDP_StaticChannelArraySize); i++) freerdp_addin_argv_free(settings->StaticChannelArray[i]); } @@ -669,12 +656,11 @@ void freerdp_static_channel_collection_free(rdpSettings* settings) BOOL freerdp_dynamic_channel_collection_del(rdpSettings* settings, const char* name) { - UINT32 x = 0; const UINT32 count = freerdp_settings_get_uint32(settings, FreeRDP_DynamicChannelCount); if (!settings || !settings->DynamicChannelArray) return FALSE; - for (x = 0; x < count; x++) + for (UINT32 x = 0; x < count; x++) { ADDIN_ARGV* cur = settings->DynamicChannelArray[x]; if (cur && (cur->argc > 0)) @@ -735,16 +721,13 @@ BOOL freerdp_dynamic_channel_collection_add(rdpSettings* settings, ADDIN_ARGV* c ADDIN_ARGV* freerdp_dynamic_channel_collection_find(const rdpSettings* settings, const char* name) { - UINT32 index = 0; - ADDIN_ARGV* channel = NULL; - WINPR_ASSERT(settings); WINPR_ASSERT(name); - for (index = 0; index < freerdp_settings_get_uint32(settings, FreeRDP_DynamicChannelCount); - index++) + for (UINT32 index = 0; + index < freerdp_settings_get_uint32(settings, FreeRDP_DynamicChannelCount); index++) { - channel = settings->DynamicChannelArray[index]; + ADDIN_ARGV* channel = settings->DynamicChannelArray[index]; if (strcmp(channel->argv[0], name) == 0) return channel; @@ -755,13 +738,12 @@ ADDIN_ARGV* freerdp_dynamic_channel_collection_find(const rdpSettings* settings, void freerdp_addin_argv_free(ADDIN_ARGV* args) { - int index = 0; if (!args) return; if (args->argv) { - for (index = 0; index < args->argc; index++) + for (int index = 0; index < args->argc; index++) free(args->argv[index]); free(args->argv); } @@ -784,8 +766,7 @@ ADDIN_ARGV* freerdp_addin_argv_new(size_t argc, const char* argv[]) if (argv) { - size_t x = 0; - for (x = 0; x < argc; x++) + for (size_t x = 0; x < argc; x++) { args->argv[x] = _strdup(argv[x]); if (!args->argv[x]) @@ -814,13 +795,12 @@ ADDIN_ARGV* freerdp_addin_argv_clone(const ADDIN_ARGV* args) void freerdp_dynamic_channel_collection_free(rdpSettings* settings) { - UINT32 i = 0; - WINPR_ASSERT(settings); if (settings->DynamicChannelArray) { - for (i = 0; i < freerdp_settings_get_uint32(settings, FreeRDP_DynamicChannelArraySize); i++) + for (UINT32 i = 0; + i < freerdp_settings_get_uint32(settings, FreeRDP_DynamicChannelArraySize); i++) freerdp_addin_argv_free(settings->DynamicChannelArray[i]); } @@ -832,13 +812,11 @@ void freerdp_dynamic_channel_collection_free(rdpSettings* settings) void freerdp_capability_buffer_free(rdpSettings* settings) { - UINT32 x = 0; - WINPR_ASSERT(settings); if (settings->ReceivedCapabilityData) { - for (x = 0; x < settings->ReceivedCapabilitiesSize; x++) + for (UINT32 x = 0; x < settings->ReceivedCapabilitiesSize; x++) { free(settings->ReceivedCapabilityData[x]); settings->ReceivedCapabilityData[x] = NULL; @@ -909,12 +887,11 @@ void freerdp_target_net_addresses_free(rdpSettings* settings) void freerdp_server_license_issuers_free(rdpSettings* settings) { - UINT32 x = 0; WINPR_ASSERT(settings); if (settings->ServerLicenseProductIssuers) { - for (x = 0; x < settings->ServerLicenseProductIssuersCount; x++) + for (UINT32 x = 0; x < settings->ServerLicenseProductIssuersCount; x++) free(settings->ServerLicenseProductIssuers[x]); } free(settings->ServerLicenseProductIssuers); @@ -924,8 +901,6 @@ void freerdp_server_license_issuers_free(rdpSettings* settings) BOOL freerdp_server_license_issuers_copy(rdpSettings* settings, char** issuers, UINT32 count) { - UINT32 x = 0; - WINPR_ASSERT(settings); WINPR_ASSERT(issuers || (count == 0)); @@ -933,7 +908,7 @@ BOOL freerdp_server_license_issuers_copy(rdpSettings* settings, char** issuers, count)) return FALSE; - for (x = 0; x < count; x++) + for (UINT32 x = 0; x < count; x++) { char* issuer = _strdup(issuers[x]); if (!issuer) @@ -1982,14 +1957,13 @@ BOOL freerdp_settings_update_from_caps(rdpSettings* settings, const BYTE* capsFl const BYTE** capsData, const UINT32* capsSizes, UINT32 capsCount, BOOL serverReceivedCaps) { - UINT32 x = 0; WINPR_ASSERT(settings); WINPR_ASSERT(capsFlags || (capsCount == 0)); WINPR_ASSERT(capsData || (capsCount == 0)); WINPR_ASSERT(capsSizes || (capsCount == 0)); WINPR_ASSERT(capsCount <= UINT16_MAX); - for (x = 0; x < capsCount; x++) + for (UINT32 x = 0; x < capsCount; x++) { if (capsFlags[x]) { diff --git a/libfreerdp/common/test/TestAddinArgv.c b/libfreerdp/common/test/TestAddinArgv.c index 2e057fbe8..f9a1f8bc5 100644 --- a/libfreerdp/common/test/TestAddinArgv.c +++ b/libfreerdp/common/test/TestAddinArgv.c @@ -7,7 +7,6 @@ static BOOL test_alloc(void) { BOOL rc = FALSE; int rng = 0; - int x = 0; const char* param[] = { "foo:", "bar", "bla", "rdp", NULL }; ADDIN_ARGV* arg1 = NULL; ADDIN_ARGV* arg2 = NULL; @@ -26,7 +25,7 @@ static BOOL test_alloc(void) arg2 = freerdp_addin_argv_new(rng, NULL); if (!arg2 || (arg2->argc != rng) || (!arg2->argv)) goto fail; - for (x = 0; x < arg2->argc; x++) + for (int x = 0; x < arg2->argc; x++) { if (arg2->argv[x]) goto fail; @@ -37,7 +36,7 @@ static BOOL test_alloc(void) if (!arg3 || (arg3->argc != ARRAYSIZE(param) - 1) || (!arg3->argv)) goto fail; - for (x = 0; x < arg3->argc; x++) + for (int x = 0; x < arg3->argc; x++) { if (strcmp(arg3->argv[x], param[x]) != 0) goto fail; @@ -59,7 +58,6 @@ fail: static BOOL test_clone(void) { - int x = 0; BOOL rc = FALSE; const char* param[] = { "foo:", "bar", "bla", "rdp" }; ADDIN_ARGV* arg = NULL; @@ -73,7 +71,7 @@ static BOOL test_clone(void) if (!clone || (clone->argc != arg->argc)) goto fail; - for (x = 0; x < arg->argc; x++) + for (int x = 0; x < arg->argc; x++) { if (strcmp(param[x], arg->argv[x]) != 0) goto fail; @@ -95,16 +93,13 @@ fail: static BOOL test_add_remove(void) { - size_t x = 0; - size_t y = 0; const char* args[] = { "foo", "bar", "bla", "gaga" }; BOOL rc = FALSE; - ADDIN_ARGV* arg = NULL; + ADDIN_ARGV* arg = freerdp_addin_argv_new(0, NULL); - arg = freerdp_addin_argv_new(0, NULL); if (!arg || (arg->argc != 0) || arg->argv) goto fail; - for (y = 0; y < ARRAYSIZE(args); y++) + for (size_t y = 0; y < ARRAYSIZE(args); y++) { const char* param = args[y]; if (!freerdp_addin_argv_add_argument(arg, param)) @@ -130,12 +125,12 @@ static BOOL test_add_remove(void) goto fail; /* Remove elements one by one to test argument index move */ - for (y = 0; y < ARRAYSIZE(args); y++) + for (size_t y = 0; y < ARRAYSIZE(args); y++) { const char* param = args[y]; if (!freerdp_addin_argv_del_argument(arg, param)) goto fail; - for (x = y + 1; x < ARRAYSIZE(args); x++) + for (size_t x = y + 1; x < ARRAYSIZE(args); x++) { if (strcmp(arg->argv[x - y - 1], args[x]) != 0) goto fail; diff --git a/libfreerdp/core/activation.c b/libfreerdp/core/activation.c index 77e91814f..562853393 100644 --- a/libfreerdp/core/activation.c +++ b/libfreerdp/core/activation.c @@ -277,7 +277,6 @@ static BOOL rdp_write_client_persistent_key_list_pdu(wStream* s, static UINT32 rdp_load_persistent_key_list(rdpRdp* rdp, UINT64** pKeyList) { - int index = 0; int count = 0; int status = 0; UINT32 keyCount = 0; @@ -311,7 +310,7 @@ static UINT32 rdp_load_persistent_key_list(rdpRdp* rdp, UINT64** pKeyList) if (!keyList) goto error; - for (index = 0; index < count; index++) + for (int index = 0; index < count; index++) { PERSISTENT_CACHE_ENTRY cacheEntry = { 0 }; @@ -431,7 +430,6 @@ BOOL rdp_recv_client_persistent_key_list_pdu(wStream* s) size_t count = 0; size_t total = 0; UINT16 cache = 0; - UINT16 x = 0; WINPR_ASSERT(s); @@ -443,14 +441,14 @@ BOOL rdp_recv_client_persistent_key_list_pdu(wStream* s) return FALSE; } /* Read numEntriesCacheX for variable length data in PDU */ - for (x = 0; x < 5; x++) + for (size_t x = 0; x < 5; x++) { Stream_Read_UINT16(s, cache); count += cache; } /* Skip totalEntriesCacheX */ - for (x = 0; x < 5; x++) + for (size_t x = 0; x < 5; x++) { UINT16 tmp = 0; Stream_Read_UINT16(s, tmp); diff --git a/libfreerdp/core/capabilities.c b/libfreerdp/core/capabilities.c index a56e16f59..427e43410 100644 --- a/libfreerdp/core/capabilities.c +++ b/libfreerdp/core/capabilities.c @@ -519,11 +519,10 @@ static BOOL rdp_apply_order_capability_set(rdpSettings* settings, const rdpSetti WINPR_ASSERT(settings); WINPR_ASSERT(src); - int i = 0; BOOL BitmapCacheV3Enabled = FALSE; BOOL FrameMarkerCommandEnabled = FALSE; - for (i = 0; i < 32; i++) + for (size_t i = 0; i < 32; i++) { if (!src->OrderSupport[i]) settings->OrderSupport[i] = FALSE; @@ -559,7 +558,6 @@ static BOOL rdp_apply_order_capability_set(rdpSettings* settings, const rdpSetti static BOOL rdp_read_order_capability_set(wStream* s, rdpSettings* settings) { - size_t i = 0; char terminalDescriptor[17] = { 0 }; BYTE orderSupport[32] = { 0 }; BOOL BitmapCacheV3Enabled = FALSE; @@ -590,7 +588,7 @@ static BOOL rdp_read_order_capability_set(wStream* s, rdpSettings* settings) if (!freerdp_settings_set_string(settings, FreeRDP_TerminalDescriptor, terminalDescriptor)) return FALSE; - for (i = 0; i < ARRAYSIZE(orderSupport); i++) + for (size_t i = 0; i < ARRAYSIZE(orderSupport); i++) settings->OrderSupport[i] = orderSupport[i]; if (settings->OrderSupportFlags & ORDER_FLAGS_EXTRA_SUPPORT) @@ -1644,13 +1642,12 @@ static void rdp_write_cache_definition(wStream* s, GLYPH_CACHE_DEFINITION* cache static BOOL rdp_apply_glyph_cache_capability_set(rdpSettings* settings, const rdpSettings* src) { - size_t x = 0; WINPR_ASSERT(settings); WINPR_ASSERT(src); WINPR_ASSERT(src->GlyphCache); WINPR_ASSERT(settings->GlyphCache); - for (x = 0; x < 10; x++) + for (size_t x = 0; x < 10; x++) settings->GlyphCache[x] = src->GlyphCache[x]; WINPR_ASSERT(src->FragCache); @@ -1668,14 +1665,12 @@ static BOOL rdp_apply_glyph_cache_capability_set(rdpSettings* settings, const rd static BOOL rdp_read_glyph_cache_capability_set(wStream* s, rdpSettings* settings) { - - size_t x = 0; WINPR_ASSERT(settings); if (!Stream_CheckAndLogRequiredLength(TAG, s, 48)) return FALSE; /* glyphCache (40 bytes) */ - for (x = 0; x < 10; x++) + for (size_t x = 0; x < 10; x++) rdp_read_cache_definition(s, &(settings->GlyphCache[x])); /* glyphCache0 (4 bytes) */ rdp_read_cache_definition(s, settings->FragCache); /* fragCache (4 bytes) */ Stream_Read_UINT16(s, settings->GlyphSupportLevel); /* glyphSupportLevel (2 bytes) */ @@ -1988,7 +1983,6 @@ static BOOL rdp_apply_bitmap_cache_v2_capability_set(rdpSettings* settings, cons static BOOL rdp_read_bitmap_cache_v2_capability_set(wStream* s, rdpSettings* settings) { - size_t x = 0; UINT16 cacheFlags = 0; WINPR_UNUSED(settings); WINPR_ASSERT(settings); @@ -2006,7 +2000,7 @@ static BOOL rdp_read_bitmap_cache_v2_capability_set(wStream* s, rdpSettings* set Stream_Seek_UINT8(s); /* pad2 (1 byte) */ Stream_Read_UINT8(s, settings->BitmapCacheV2NumCells); /* numCellCaches (1 byte) */ - for (x = 0; x < 5; x++) + for (size_t x = 0; x < 5; x++) { BITMAP_CACHE_V2_CELL_INFO* info = freerdp_settings_get_pointer_array_writable(settings, FreeRDP_BitmapCacheV2CellInfo, x); diff --git a/libfreerdp/core/channels.c b/libfreerdp/core/channels.c index ad88169ea..0c2ad9851 100644 --- a/libfreerdp/core/channels.c +++ b/libfreerdp/core/channels.c @@ -52,7 +52,6 @@ BOOL freerdp_channel_send(rdpRdp* rdp, UINT16 channelId, const BYTE* data, size_t size) { - DWORD i = 0; size_t left = 0; UINT32 flags = 0; size_t chunkSize = 0; @@ -64,7 +63,7 @@ BOOL freerdp_channel_send(rdpRdp* rdp, UINT16 channelId, const BYTE* data, size_ mcs = rdp->mcs; WINPR_ASSERT(mcs); - for (i = 0; i < mcs->channelCount; i++) + for (UINT32 i = 0; i < mcs->channelCount; i++) { const rdpMcsChannel* cur = &mcs->channels[i]; if (cur->ChannelId == channelId) @@ -175,13 +174,12 @@ BOOL freerdp_channel_peer_process(freerdp_peer* client, wStream* s, UINT16 chann if (client->VirtualChannelRead) { int rc = 0; - UINT32 index = 0; BOOL found = FALSE; HANDLE hChannel = 0; rdpContext* context = client->context; rdpMcs* mcs = context->rdp->mcs; - for (index = 0; index < mcs->channelCount; index++) + for (UINT32 index = 0; index < mcs->channelCount; index++) { const rdpMcsChannel* mcsChannel = &(mcs->channels[index]); diff --git a/libfreerdp/core/client.c b/libfreerdp/core/client.c index 722bb8c95..1bfc61704 100644 --- a/libfreerdp/core/client.c +++ b/libfreerdp/core/client.c @@ -50,12 +50,9 @@ static BOOL freerdp_channels_process_message_free(wMessage* message, DWORD type) static CHANNEL_OPEN_DATA* freerdp_channels_find_channel_open_data_by_name(rdpChannels* channels, const char* name) { - int index = 0; - CHANNEL_OPEN_DATA* pChannelOpenData = NULL; - - for (index = 0; index < channels->openDataCount; index++) + for (int index = 0; index < channels->openDataCount; index++) { - pChannelOpenData = &channels->openDataList[index]; + CHANNEL_OPEN_DATA* pChannelOpenData = &channels->openDataList[index]; if (strncmp(name, pChannelOpenData->name, CHANNEL_NAME_LEN + 1) == 0) return pChannelOpenData; @@ -67,7 +64,6 @@ static CHANNEL_OPEN_DATA* freerdp_channels_find_channel_open_data_by_name(rdpCha /* returns rdpChannel for the channel name passed in */ static rdpMcsChannel* freerdp_channels_find_channel_by_name(rdpRdp* rdp, const char* name) { - UINT32 index = 0; rdpMcs* mcs = NULL; if (!rdp) @@ -75,7 +71,7 @@ static rdpMcsChannel* freerdp_channels_find_channel_by_name(rdpRdp* rdp, const c mcs = rdp->mcs; - for (index = 0; index < mcs->channelCount; index++) + for (UINT32 index = 0; index < mcs->channelCount; index++) { rdpMcsChannel* channel = &mcs->channels[index]; @@ -90,7 +86,6 @@ static rdpMcsChannel* freerdp_channels_find_channel_by_name(rdpRdp* rdp, const c static rdpMcsChannel* freerdp_channels_find_channel_by_id(rdpRdp* rdp, UINT16 channel_id) { - UINT32 index = 0; rdpMcsChannel* channel = NULL; rdpMcs* mcs = NULL; @@ -99,7 +94,7 @@ static rdpMcsChannel* freerdp_channels_find_channel_by_id(rdpRdp* rdp, UINT16 ch mcs = rdp->mcs; - for (index = 0; index < mcs->channelCount; index++) + for (UINT32 index = 0; index < mcs->channelCount; index++) { channel = &mcs->channels[index]; @@ -265,12 +260,11 @@ void freerdp_channels_register_instance(rdpChannels* channels, freerdp* instance UINT freerdp_channels_pre_connect(rdpChannels* channels, freerdp* instance) { UINT error = CHANNEL_RC_OK; - int index = 0; CHANNEL_CLIENT_DATA* pChannelClientData = NULL; MessageQueue_Clear(channels->queue); - for (index = 0; index < channels->clientDataCount; index++) + for (int index = 0; index < channels->clientDataCount; index++) { pChannelClientData = &channels->clientDataList[index]; @@ -296,7 +290,6 @@ UINT freerdp_channels_pre_connect(rdpChannels* channels, freerdp* instance) UINT freerdp_channels_attach(freerdp* instance) { UINT error = CHANNEL_RC_OK; - int index = 0; const char* hostname = NULL; size_t hostnameLength = 0; rdpChannels* channels = NULL; @@ -311,7 +304,7 @@ UINT freerdp_channels_attach(freerdp* instance) WINPR_ASSERT(hostname); hostnameLength = strnlen(hostname, MAX_PATH); - for (index = 0; index < channels->clientDataCount; index++) + for (int index = 0; index < channels->clientDataCount; index++) { union { @@ -355,7 +348,6 @@ fail: UINT freerdp_channels_detach(freerdp* instance) { UINT error = CHANNEL_RC_OK; - int index = 0; const char* hostname = NULL; size_t hostnameLength = 0; rdpChannels* channels = NULL; @@ -375,7 +367,7 @@ UINT freerdp_channels_detach(freerdp* instance) WINPR_ASSERT(hostname); hostnameLength = strnlen(hostname, MAX_PATH); - for (index = 0; index < channels->clientDataCount; index++) + for (int index = 0; index < channels->clientDataCount; index++) { union { @@ -424,7 +416,6 @@ fail: UINT freerdp_channels_post_connect(rdpChannels* channels, freerdp* instance) { UINT error = CHANNEL_RC_OK; - int index = 0; const char* hostname = NULL; size_t hostnameLength = 0; CHANNEL_CLIENT_DATA* pChannelClientData = NULL; @@ -439,7 +430,7 @@ UINT freerdp_channels_post_connect(rdpChannels* channels, freerdp* instance) WINPR_ASSERT(hostname); hostnameLength = strnlen(hostname, MAX_PATH); - for (index = 0; index < channels->clientDataCount; index++) + for (int index = 0; index < channels->clientDataCount; index++) { union { @@ -494,7 +485,6 @@ fail: BOOL freerdp_channels_data(freerdp* instance, UINT16 channelId, const BYTE* cdata, size_t dataSize, UINT32 flags, size_t totalSize) { - UINT32 index = 0; rdpMcs* mcs = NULL; rdpChannels* channels = NULL; rdpMcsChannel* channel = NULL; @@ -521,7 +511,7 @@ BOOL freerdp_channels_data(freerdp* instance, UINT16 channelId, const BYTE* cdat return FALSE; } - for (index = 0; index < mcs->channelCount; index++) + for (int index = 0; index < mcs->channelCount; index++) { rdpMcsChannel* cur = &mcs->channels[index]; @@ -749,7 +739,6 @@ BOOL freerdp_channels_check_fds(rdpChannels* channels, freerdp* instance) UINT freerdp_channels_disconnect(rdpChannels* channels, freerdp* instance) { UINT error = CHANNEL_RC_OK; - int index = 0; CHANNEL_OPEN_DATA* pChannelOpenData = NULL; CHANNEL_CLIENT_DATA* pChannelClientData = NULL; @@ -759,7 +748,7 @@ UINT freerdp_channels_disconnect(rdpChannels* channels, freerdp* instance) freerdp_channels_check_fds(channels, instance); /* tell all libraries we are shutting down */ - for (index = 0; index < channels->clientDataCount; index++) + for (int index = 0; index < channels->clientDataCount; index++) { ChannelDisconnectedEventArgs e; pChannelClientData = &channels->clientDataList[index]; @@ -792,7 +781,6 @@ UINT freerdp_channels_disconnect(rdpChannels* channels, freerdp* instance) void freerdp_channels_close(rdpChannels* channels, freerdp* instance) { - int index = 0; CHANNEL_OPEN_DATA* pChannelOpenData = NULL; CHANNEL_CLIENT_DATA* pChannelClientData = NULL; @@ -803,7 +791,7 @@ void freerdp_channels_close(rdpChannels* channels, freerdp* instance) freerdp_channels_check_fds(channels, instance); /* tell all libraries we are shutting down */ - for (index = 0; index < channels->clientDataCount; index++) + for (int index = 0; index < channels->clientDataCount; index++) { pChannelClientData = &channels->clientDataList[index]; @@ -822,7 +810,7 @@ void freerdp_channels_close(rdpChannels* channels, freerdp* instance) channels->clientDataCount = 0; - for (index = 0; index < channels->openDataCount; index++) + for (int index = 0; index < channels->openDataCount; index++) { pChannelOpenData = &channels->openDataList[index]; HashTable_Remove(g_ChannelHandles, (void*)(UINT_PTR)pChannelOpenData->OpenHandle); @@ -841,7 +829,6 @@ static UINT VCAPITYPE FreeRDP_VirtualChannelInitEx( LPVOID lpUserParam, LPVOID clientContext, LPVOID pInitHandle, PCHANNEL_DEF pChannel, INT channelCount, ULONG versionRequested, PCHANNEL_INIT_EVENT_EX_FN pChannelInitEventProcEx) { - INT index = 0; rdpSettings* settings = NULL; CHANNEL_INIT_DATA* pChannelInitData = NULL; CHANNEL_CLIENT_DATA* pChannelClientData = NULL; @@ -875,7 +862,7 @@ static UINT VCAPITYPE FreeRDP_VirtualChannelInitEx( { } - for (index = 0; index < channelCount; index++) + for (int index = 0; index < channelCount; index++) { const PCHANNEL_DEF pChannelDef = &pChannel[index]; @@ -897,7 +884,7 @@ static UINT VCAPITYPE FreeRDP_VirtualChannelInitEx( settings = channels->instance->context->settings; WINPR_ASSERT(settings); - for (index = 0; index < channelCount; index++) + for (int index = 0; index < channelCount; index++) { const PCHANNEL_DEF pChannelDef = &pChannel[index]; CHANNEL_OPEN_DATA* pChannelOpenData = &channels->openDataList[channels->openDataCount]; @@ -940,7 +927,6 @@ static UINT VCAPITYPE FreeRDP_VirtualChannelInit(LPVOID* ppInitHandle, PCHANNEL_ INT channelCount, ULONG versionRequested, PCHANNEL_INIT_EVENT_FN pChannelInitEventProc) { - INT index = 0; CHANNEL_DEF* channel = NULL; rdpSettings* settings = NULL; PCHANNEL_DEF pChannelDef = NULL; @@ -984,7 +970,7 @@ static UINT VCAPITYPE FreeRDP_VirtualChannelInit(LPVOID* ppInitHandle, PCHANNEL_ { } - for (index = 0; index < channelCount; index++) + for (int index = 0; index < channelCount; index++) { pChannelDef = &pChannel[index]; @@ -1000,7 +986,7 @@ static UINT VCAPITYPE FreeRDP_VirtualChannelInit(LPVOID* ppInitHandle, PCHANNEL_ channels->clientDataCount++; settings = channels->instance->context->settings; - for (index = 0; index < channelCount; index++) + for (int index = 0; index < channelCount; index++) { UINT32 ChannelCount = freerdp_settings_get_uint32(settings, FreeRDP_ChannelCount); @@ -1253,9 +1239,7 @@ static UINT VCAPITYPE FreeRDP_VirtualChannelWrite(DWORD openHandle, LPVOID pData static BOOL freerdp_channels_is_loaded(rdpChannels* channels, PVIRTUALCHANNELENTRY entry) { - int i = 0; - - for (i = 0; i < channels->clientDataCount; i++) + for (int i = 0; i < channels->clientDataCount; i++) { CHANNEL_CLIENT_DATA* pChannelClientData = &channels->clientDataList[i]; @@ -1268,9 +1252,7 @@ static BOOL freerdp_channels_is_loaded(rdpChannels* channels, PVIRTUALCHANNELENT static BOOL freerdp_channels_is_loaded_ex(rdpChannels* channels, PVIRTUALCHANNELENTRYEX entryEx) { - int i = 0; - - for (i = 0; i < channels->clientDataCount; i++) + for (int i = 0; i < channels->clientDataCount; i++) { CHANNEL_CLIENT_DATA* pChannelClientData = &channels->clientDataList[i]; diff --git a/libfreerdp/core/connection.c b/libfreerdp/core/connection.c index 7e45a9034..3abfa932b 100644 --- a/libfreerdp/core/connection.c +++ b/libfreerdp/core/connection.c @@ -1023,7 +1023,6 @@ static BOOL rdp_client_join_channel(rdpRdp* rdp, UINT16 ChannelId) BOOL rdp_client_connect_mcs_channel_join_confirm(rdpRdp* rdp, wStream* s) { - UINT32 i = 0; UINT16 channelId = 0; BOOL allJoined = TRUE; @@ -1094,7 +1093,8 @@ BOOL rdp_client_connect_mcs_channel_join_confirm(rdpRdp* rdp, wStream* s) } else { - for (i = 0; i < mcs->channelCount; i++) + UINT32 i = 0; + for (; i < mcs->channelCount; i++) { rdpMcsChannel* cur = &mcs->channels[i]; if (cur->joined) @@ -1738,7 +1738,6 @@ BOOL rdp_server_accept_mcs_attach_user_request(rdpRdp* rdp, wStream* s) BOOL rdp_server_accept_mcs_channel_join_request(rdpRdp* rdp, wStream* s) { - UINT32 i = 0; UINT16 channelId = 0; BOOL allJoined = TRUE; rdpMcs* mcs = NULL; @@ -1767,7 +1766,7 @@ BOOL rdp_server_accept_mcs_channel_join_request(rdpRdp* rdp, wStream* s) if (channelId == mcs->messageChannelId) mcs->messageChannelJoined = TRUE; - for (i = 0; i < mcs->channelCount; i++) + for (UINT32 i = 0; i < mcs->channelCount; i++) { rdpMcsChannel* cur = &mcs->channels[i]; WLog_DBG(TAG, " %s [%" PRIu16 "]", cur->Name, cur->ChannelId); @@ -2053,7 +2052,6 @@ const char* rdp_get_state_string(const rdpRdp* rdp) BOOL rdp_channels_from_mcs(rdpSettings* settings, const rdpRdp* rdp) { - size_t x = 0; const rdpMcs* mcs = NULL; WINPR_ASSERT(rdp); @@ -2065,7 +2063,7 @@ BOOL rdp_channels_from_mcs(rdpSettings* settings, const rdpRdp* rdp) CHANNEL_MAX_COUNT)) return FALSE; - for (x = 0; x < mcs->channelCount; x++) + for (UINT32 x = 0; x < mcs->channelCount; x++) { const rdpMcsChannel* mchannel = &mcs->channels[x]; CHANNEL_DEF cur = { 0 }; diff --git a/libfreerdp/core/display.c b/libfreerdp/core/display.c index f9de85a33..cda250a1c 100644 --- a/libfreerdp/core/display.c +++ b/libfreerdp/core/display.c @@ -22,14 +22,12 @@ static BOOL display_write_monitor_layout_pdu(wStream* s, UINT32 monitorCount, const MONITOR_DEF* monitorDefArray) { - UINT32 index = 0; - if (!Stream_EnsureRemainingCapacity(s, 4 + (monitorCount * 20))) return FALSE; Stream_Write_UINT32(s, monitorCount); /* monitorCount (4 bytes) */ - for (index = 0; index < monitorCount; index++) + for (UINT32 index = 0; index < monitorCount; index++) { const MONITOR_DEF* monitor = &monitorDefArray[index]; @@ -47,7 +45,6 @@ BOOL display_convert_rdp_monitor_to_monitor_def(UINT32 monitorCount, const rdpMonitor* monitorDefArray, MONITOR_DEF** result) { - UINT32 index = 0; MONITOR_DEF* mdef = NULL; if (!monitorDefArray || !result || (*result)) @@ -58,7 +55,7 @@ BOOL display_convert_rdp_monitor_to_monitor_def(UINT32 monitorCount, if (!mdef) return FALSE; - for (index = 0; index < monitorCount; index++) + for (UINT32 index = 0; index < monitorCount; index++) { const rdpMonitor* monitor = &monitorDefArray[index]; MONITOR_DEF* current = &mdef[index]; diff --git a/libfreerdp/core/fastpath.c b/libfreerdp/core/fastpath.c index 3069b401e..5809a6f6e 100644 --- a/libfreerdp/core/fastpath.c +++ b/libfreerdp/core/fastpath.c @@ -925,8 +925,6 @@ static BOOL fastpath_recv_input_event(rdpFastPath* fastpath, wStream* s) state_run_t fastpath_recv_inputs(rdpFastPath* fastpath, wStream* s) { - BYTE i = 0; - WINPR_ASSERT(fastpath); WINPR_ASSERT(s); @@ -942,7 +940,7 @@ state_run_t fastpath_recv_inputs(rdpFastPath* fastpath, wStream* s) Stream_Read_UINT8(s, fastpath->numberEvents); /* eventHeader (1 byte) */ } - for (i = 0; i < fastpath->numberEvents; i++) + for (BYTE i = 0; i < fastpath->numberEvents; i++) { if (!fastpath_recv_input_event(fastpath, s)) return STATE_RUN_FAILED; @@ -1165,7 +1163,6 @@ wStream* fastpath_update_pdu_init_new(rdpFastPath* fastpath) BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s, BOOL skipCompression) { - int fragment = 0; UINT16 maxLength = 0; UINT32 totalLength = 0; BOOL status = TRUE; @@ -1226,7 +1223,7 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s rdp->sec_flags |= SEC_SECURE_CHECKSUM; } - for (fragment = 0; (totalLength > 0) || (fragment == 0); fragment++) + for (int fragment = 0; (totalLength > 0) || (fragment == 0); fragment++) { const BYTE* pSrcData = NULL; UINT32 SrcSize = 0; diff --git a/libfreerdp/core/gateway/http.c b/libfreerdp/core/gateway/http.c index 8d3094550..cf70b3bf1 100644 --- a/libfreerdp/core/gateway/http.c +++ b/libfreerdp/core/gateway/http.c @@ -963,10 +963,8 @@ static BOOL http_response_parse_header(HttpResponse* response) { BOOL rc = FALSE; char c = 0; - size_t count = 0; char* line = NULL; char* name = NULL; - char* value = NULL; char* colon_pos = NULL; char* end_of_header = NULL; char end_of_header_char = 0; @@ -980,7 +978,7 @@ static BOOL http_response_parse_header(HttpResponse* response) if (!http_response_parse_header_status_line(response, response->lines[0])) goto fail; - for (count = 1; count < response->count; count++) + for (size_t count = 1; count < response->count; count++) { line = response->lines[count]; @@ -1018,7 +1016,8 @@ static BOOL http_response_parse_header(HttpResponse* response) name = line; /* eat space and tabs before header value */ - for (value = colon_pos + 1; *value; value++) + char* value = colon_pos + 1; + for (; *value; value++) { if ((*value != ' ') && (*value != '\t')) break; diff --git a/libfreerdp/core/gateway/rdg.c b/libfreerdp/core/gateway/rdg.c index ea3da6aa9..c6d952b83 100644 --- a/libfreerdp/core/gateway/rdg.c +++ b/libfreerdp/core/gateway/rdg.c @@ -214,11 +214,10 @@ static const t_flag_mapping capabilities_enum[] = { static const char* flags_to_string(UINT32 flags, const t_flag_mapping* map, size_t elements) { - size_t x = 0; static char buffer[1024] = { 0 }; char fields[12] = { 0 }; - for (x = 0; x < elements; x++) + for (size_t x = 0; x < elements; x++) { const t_flag_mapping* cur = &map[x]; diff --git a/libfreerdp/core/gateway/rpc_client.c b/libfreerdp/core/gateway/rpc_client.c index 36942fa5e..9a11c8453 100644 --- a/libfreerdp/core/gateway/rpc_client.c +++ b/libfreerdp/core/gateway/rpc_client.c @@ -143,7 +143,6 @@ static int rpc_client_receive_pipe_write(RpcClient* client, const BYTE* buffer, int rpc_client_receive_pipe_read(RpcClient* client, BYTE* buffer, size_t length) { - int index = 0; size_t status = 0; int nchunks = 0; DataChunk chunks[2]; @@ -154,7 +153,7 @@ int rpc_client_receive_pipe_read(RpcClient* client, BYTE* buffer, size_t length) EnterCriticalSection(&(client->PipeLock)); nchunks = ringbuffer_peek(&(client->ReceivePipe), chunks, length); - for (index = 0; index < nchunks; index++) + for (int index = 0; index < nchunks; index++) { CopyMemory(&buffer[status], chunks[index].data, chunks[index].size); status += chunks[index].size; @@ -927,17 +926,15 @@ int rpc_client_in_channel_recv(rdpRpc* rpc) RpcClientCall* rpc_client_call_find_by_id(RpcClient* client, UINT32 CallId) { - size_t index = 0; - size_t count = 0; RpcClientCall* clientCall = NULL; if (!client) return NULL; ArrayList_Lock(client->ClientCallList); - count = ArrayList_Count(client->ClientCallList); + const size_t count = ArrayList_Count(client->ClientCallList); - for (index = 0; index < count; index++) + for (size_t index = 0; index < count; index++) { clientCall = (RpcClientCall*)ArrayList_GetItem(client->ClientCallList, index); diff --git a/libfreerdp/core/gateway/rpc_fault.c b/libfreerdp/core/gateway/rpc_fault.c index 8f51854e1..adf6a0907 100644 --- a/libfreerdp/core/gateway/rpc_fault.c +++ b/libfreerdp/core/gateway/rpc_fault.c @@ -354,10 +354,9 @@ static UINT32 rpc_map_status_code_to_win32_error_code(UINT32 code) const char* rpc_error_to_string(UINT32 code) { - size_t index = 0; static char buffer[1024]; - for (index = 0; index < ARRAYSIZE(RPC_FAULT_CODES); index++) + for (size_t index = 0; index < ARRAYSIZE(RPC_FAULT_CODES); index++) { const RPC_FAULT_CODE* const current = &RPC_FAULT_CODES[index]; if (current->code == code) @@ -367,7 +366,7 @@ const char* rpc_error_to_string(UINT32 code) } } - for (index = 0; index < ARRAYSIZE(RPC_TSG_FAULT_CODES); index++) + for (size_t index = 0; index < ARRAYSIZE(RPC_TSG_FAULT_CODES); index++) { const RPC_FAULT_CODE* const current = &RPC_TSG_FAULT_CODES[index]; if (current->code == code) @@ -377,7 +376,7 @@ const char* rpc_error_to_string(UINT32 code) } } - for (index = 0; index < ARRAYSIZE(RPC_TSG_FAULT_CODES); index++) + for (size_t index = 0; index < ARRAYSIZE(RPC_TSG_FAULT_CODES); index++) { const RPC_FAULT_CODE* const current = &RPC_TSG_FAULT_CODES[index]; if (current->code == HRESULT_CODE(code)) @@ -394,23 +393,21 @@ out: const char* rpc_error_to_category(UINT32 code) { - size_t index = 0; - - for (index = 0; index < ARRAYSIZE(RPC_FAULT_CODES); index++) + for (size_t index = 0; index < ARRAYSIZE(RPC_FAULT_CODES); index++) { const RPC_FAULT_CODE* const current = &RPC_FAULT_CODES[index]; if (current->code == code) return current->category; } - for (index = 0; index < ARRAYSIZE(RPC_TSG_FAULT_CODES); index++) + for (size_t index = 0; index < ARRAYSIZE(RPC_TSG_FAULT_CODES); index++) { const RPC_FAULT_CODE* const current = &RPC_TSG_FAULT_CODES[index]; if (current->code == code) return current->category; } - for (index = 0; index < ARRAYSIZE(RPC_TSG_FAULT_CODES); index++) + for (size_t index = 0; index < ARRAYSIZE(RPC_TSG_FAULT_CODES); index++) { const RPC_FAULT_CODE* const current = &RPC_TSG_FAULT_CODES[index]; if (current->code == HRESULT_CODE(code)) diff --git a/libfreerdp/core/gateway/rts.c b/libfreerdp/core/gateway/rts.c index 5a13a39d0..2ba757815 100644 --- a/libfreerdp/core/gateway/rts.c +++ b/libfreerdp/core/gateway/rts.c @@ -460,8 +460,6 @@ static void rts_free_supported_versions(p_rt_versions_supported_t* versions) static BOOL rts_read_supported_versions(wStream* s, p_rt_versions_supported_t* versions, BOOL silent) { - BYTE x = 0; - WINPR_ASSERT(s); WINPR_ASSERT(versions); @@ -476,7 +474,7 @@ static BOOL rts_read_supported_versions(wStream* s, p_rt_versions_supported_t* v if (!versions->p_protocols) return FALSE; } - for (x = 0; x < versions->n_protocols; x++) + for (BYTE x = 0; x < versions->n_protocols; x++) { p_rt_version_t* version = &versions->p_protocols[x]; if (!rts_read_version(s, version, silent)) /* size_is(n_protocols) */ @@ -605,7 +603,6 @@ static void rts_context_elem_free(p_cont_elem_t* ptr) static BOOL rts_read_context_elem(wStream* s, p_cont_elem_t* element, BOOL silent) { - BYTE x = 0; WINPR_ASSERT(s); WINPR_ASSERT(element); @@ -624,7 +621,7 @@ static BOOL rts_read_context_elem(wStream* s, p_cont_elem_t* element, BOOL silen element->transfer_syntaxes = rts_syntax_id_new(element->n_transfer_syn); if (!element->transfer_syntaxes) return FALSE; - for (x = 0; x < element->n_transfer_syn; x++) + for (BYTE x = 0; x < element->n_transfer_syn; x++) { p_syntax_id_t* syn = &element->transfer_syntaxes[x]; if (!rts_read_syntax_id(s, syn, silent)) /* size_is(n_transfer_syn) */ @@ -637,7 +634,6 @@ static BOOL rts_read_context_elem(wStream* s, p_cont_elem_t* element, BOOL silen static BOOL rts_write_context_elem(wStream* s, const p_cont_elem_t* element) { - BYTE x = 0; WINPR_ASSERT(s); WINPR_ASSERT(element); @@ -649,7 +645,7 @@ static BOOL rts_write_context_elem(wStream* s, const p_cont_elem_t* element) if (!rts_write_syntax_id(s, &element->abstract_syntax)) /* transfer syntax list */ return FALSE; - for (x = 0; x < element->n_transfer_syn; x++) + for (BYTE x = 0; x < element->n_transfer_syn; x++) { const p_syntax_id_t* syn = &element->transfer_syntaxes[x]; if (!rts_write_syntax_id(s, syn)) /* size_is(n_transfer_syn) */ @@ -661,8 +657,6 @@ static BOOL rts_write_context_elem(wStream* s, const p_cont_elem_t* element) static BOOL rts_read_context_list(wStream* s, p_cont_list_t* list, BOOL silent) { - BYTE x = 0; - WINPR_ASSERT(s); WINPR_ASSERT(list); @@ -677,7 +671,7 @@ static BOOL rts_read_context_list(wStream* s, p_cont_list_t* list, BOOL silent) list->p_cont_elem = rts_context_elem_new(list->n_context_elem); if (!list->p_cont_elem) return FALSE; - for (x = 0; x < list->n_context_elem; x++) + for (BYTE x = 0; x < list->n_context_elem; x++) { p_cont_elem_t* element = &list->p_cont_elem[x]; if (!rts_read_context_elem(s, element, silent)) @@ -696,8 +690,6 @@ static void rts_free_context_list(p_cont_list_t* list) static BOOL rts_write_context_list(wStream* s, const p_cont_list_t* list) { - BYTE x = 0; - WINPR_ASSERT(s); WINPR_ASSERT(list); @@ -707,7 +699,7 @@ static BOOL rts_write_context_list(wStream* s, const p_cont_list_t* list) Stream_Write_UINT8(s, 0); /* alignment pad, m.b.z. */ Stream_Write_UINT16(s, 0); /* alignment pad, m.b.z. */ - for (x = 0; x < list->n_context_elem; x++) + for (BYTE x = 0; x < list->n_context_elem; x++) { const p_cont_elem_t* element = &list->p_cont_elem[x]; if (!rts_write_context_elem(s, element)) @@ -749,8 +741,6 @@ static void rts_free_result(p_result_t* result) static BOOL rts_read_result_list(wStream* s, p_result_list_t* list, BOOL silent) { - BYTE x = 0; - WINPR_ASSERT(s); WINPR_ASSERT(list); @@ -766,7 +756,7 @@ static BOOL rts_read_result_list(wStream* s, p_result_list_t* list, BOOL silent) if (!list->p_results) return FALSE; - for (x = 0; x < list->n_results; x++) + for (BYTE x = 0; x < list->n_results; x++) { p_result_t* result = &list->p_results[x]; /* size_is(n_results) */ if (!rts_read_result(s, result, silent)) @@ -779,11 +769,9 @@ static BOOL rts_read_result_list(wStream* s, p_result_list_t* list, BOOL silent) static void rts_free_result_list(p_result_list_t* list) { - BYTE x = 0; - if (!list) return; - for (x = 0; x < list->n_results; x++) + for (BYTE x = 0; x < list->n_results; x++) { p_result_t* result = &list->p_results[x]; rts_free_result(result); diff --git a/libfreerdp/core/gateway/rts_signature.c b/libfreerdp/core/gateway/rts_signature.c index 2a1e15a16..f549130dc 100644 --- a/libfreerdp/core/gateway/rts_signature.c +++ b/libfreerdp/core/gateway/rts_signature.c @@ -315,7 +315,6 @@ BOOL rts_extract_pdu_signature_ex(RtsPduSignature* signature, wStream* src, const rpcconn_hdr_t* header, BOOL silent) { BOOL rc = FALSE; - UINT16 i = 0; wStream sbuffer = { 0 }; rpcconn_hdr_t rheader = { 0 }; const rpcconn_rts_hdr_t* rts = NULL; @@ -337,7 +336,7 @@ BOOL rts_extract_pdu_signature_ex(RtsPduSignature* signature, wStream* src, signature->Flags = rts->Flags; signature->NumberOfCommands = rts->NumberOfCommands; - for (i = 0; i < rts->NumberOfCommands; i++) + for (UINT16 i = 0; i < rts->NumberOfCommands; i++) { UINT32 CommandType = 0; size_t CommandLength = 0; @@ -366,13 +365,10 @@ fail: UINT32 rts_identify_pdu_signature(const RtsPduSignature* signature, const RTS_PDU_SIGNATURE_ENTRY** entry) { - size_t i = 0; - size_t j = 0; - if (entry) *entry = NULL; - for (i = 0; i < ARRAYSIZE(RTS_PDU_SIGNATURE_TABLE); i++) + for (size_t i = 0; i < ARRAYSIZE(RTS_PDU_SIGNATURE_TABLE); i++) { const RTS_PDU_SIGNATURE_ENTRY* current = &RTS_PDU_SIGNATURE_TABLE[i]; const RtsPduSignature* pSignature = current->Signature; @@ -386,7 +382,7 @@ UINT32 rts_identify_pdu_signature(const RtsPduSignature* signature, if (signature->NumberOfCommands != pSignature->NumberOfCommands) continue; - for (j = 0; j < signature->NumberOfCommands; j++) + for (size_t j = 0; j < signature->NumberOfCommands; j++) { if (signature->CommandTypes[j] != pSignature->CommandTypes[j]) continue; diff --git a/libfreerdp/core/gateway/tsg.c b/libfreerdp/core/gateway/tsg.c index 22f04659d..3ab833a0b 100644 --- a/libfreerdp/core/gateway/tsg.c +++ b/libfreerdp/core/gateway/tsg.c @@ -799,8 +799,6 @@ static BOOL tsg_type_capability_nap_to_string(char** buffer, size_t* length, static BOOL tsg_packet_capabilities_to_string(char** buffer, size_t* length, const TSG_PACKET_CAPABILITIES* caps, UINT32 numCaps) { - UINT32 x = 0; - WINPR_ASSERT(buffer); WINPR_ASSERT(length); WINPR_ASSERT(caps); @@ -808,7 +806,7 @@ static BOOL tsg_packet_capabilities_to_string(char** buffer, size_t* length, if (!tsg_print(buffer, length, "capabilities { ")) return FALSE; - for (x = 0; x < numCaps; x++) + for (UINT32 x = 0; x < numCaps; x++) { const TSG_PACKET_CAPABILITIES* cur = &caps[x]; switch (cur->capabilityType) diff --git a/libfreerdp/core/gcc.c b/libfreerdp/core/gcc.c index 30f955ac1..d99ee86f6 100644 --- a/libfreerdp/core/gcc.c +++ b/libfreerdp/core/gcc.c @@ -1810,8 +1810,6 @@ BOOL gcc_write_server_security_data(wStream* s, rdpMcs* mcs) BOOL gcc_read_client_network_data(wStream* s, rdpMcs* mcs) { - UINT32 i = 0; - WINPR_ASSERT(s); WINPR_ASSERT(mcs); @@ -1828,7 +1826,7 @@ BOOL gcc_read_client_network_data(wStream* s, rdpMcs* mcs) return FALSE; /* channelDefArray */ - for (i = 0; i < mcs->channelCount; i++) + for (UINT32 i = 0; i < mcs->channelCount; i++) { /** * CHANNEL_DEF @@ -1865,7 +1863,6 @@ BOOL gcc_read_client_network_data(wStream* s, rdpMcs* mcs) BOOL gcc_write_client_network_data(wStream* s, const rdpMcs* mcs) { - UINT32 i = 0; UINT16 length = 0; WINPR_ASSERT(s); WINPR_ASSERT(mcs); @@ -1877,7 +1874,7 @@ BOOL gcc_write_client_network_data(wStream* s, const rdpMcs* mcs) Stream_Write_UINT32(s, mcs->channelCount); /* channelCount */ /* channelDefArray */ - for (i = 0; i < mcs->channelCount; i++) + for (UINT32 i = 0; i < mcs->channelCount; i++) { /* CHANNEL_DEF */ rdpMcsChannel* channel = &mcs->channels[i]; @@ -1931,7 +1928,6 @@ BOOL gcc_read_server_network_data(wStream* s, rdpMcs* mcs) BOOL gcc_write_server_network_data(wStream* s, const rdpMcs* mcs) { - UINT32 i = 0; WINPR_ASSERT(s); WINPR_ASSERT(mcs); const size_t payloadLen = 8 + mcs->channelCount * 2 + (mcs->channelCount % 2 == 1 ? 2 : 0); @@ -1942,7 +1938,7 @@ BOOL gcc_write_server_network_data(wStream* s, const rdpMcs* mcs) Stream_Write_UINT16(s, MCS_GLOBAL_CHANNEL_ID); /* MCSChannelId */ Stream_Write_UINT16(s, mcs->channelCount); /* channelCount */ - for (i = 0; i < mcs->channelCount; i++) + for (UINT32 i = 0; i < mcs->channelCount; i++) { const rdpMcsChannel* channel = &mcs->channels[i]; Stream_Write_UINT16(s, channel->ChannelId); @@ -2059,7 +2055,6 @@ BOOL gcc_write_client_cluster_data(wStream* s, const rdpMcs* mcs) BOOL gcc_read_client_monitor_data(wStream* s, rdpMcs* mcs) { - UINT32 index = 0; UINT32 monitorCount = 0; rdpSettings* settings = mcs_get_settings(mcs); @@ -2095,7 +2090,7 @@ BOOL gcc_read_client_monitor_data(wStream* s, rdpMcs* mcs) settings->MonitorCount = monitorCount; - for (index = 0; index < monitorCount; index++) + for (UINT32 index = 0; index < monitorCount; index++) { UINT32 left = 0; UINT32 top = 0; @@ -2130,7 +2125,6 @@ BOOL gcc_read_client_monitor_data(wStream* s, rdpMcs* mcs) BOOL gcc_write_client_monitor_data(wStream* s, const rdpMcs* mcs) { - UINT32 i = 0; UINT16 length = 0; INT32 baseX = 0; INT32 baseY = 0; @@ -2150,7 +2144,7 @@ BOOL gcc_write_client_monitor_data(wStream* s, const rdpMcs* mcs) /* first pass to get the primary monitor coordinates (it is supposed to be * in (0,0) */ - for (i = 0; i < settings->MonitorCount; i++) + for (UINT32 i = 0; i < settings->MonitorCount; i++) { const rdpMonitor* current = &settings->MonitorDefArray[i]; if (current->is_primary) @@ -2161,7 +2155,7 @@ BOOL gcc_write_client_monitor_data(wStream* s, const rdpMcs* mcs) } } - for (i = 0; i < settings->MonitorCount; i++) + for (UINT32 i = 0; i < settings->MonitorCount; i++) { const rdpMonitor* current = &settings->MonitorDefArray[i]; const UINT32 left = current->x - baseX; @@ -2186,7 +2180,6 @@ BOOL gcc_write_client_monitor_data(wStream* s, const rdpMcs* mcs) BOOL gcc_read_client_monitor_extended_data(wStream* s, rdpMcs* mcs) { - UINT32 index = 0; UINT32 monitorCount = 0; UINT32 monitorAttributeSize = 0; rdpSettings* settings = mcs_get_settings(mcs); @@ -2213,7 +2206,7 @@ BOOL gcc_read_client_monitor_extended_data(wStream* s, rdpMcs* mcs) settings->HasMonitorAttributes = TRUE; - for (index = 0; index < monitorCount; index++) + for (UINT32 index = 0; index < monitorCount; index++) { rdpMonitor* current = &settings->MonitorDefArray[index]; Stream_Read_UINT32(s, current->attributes.physicalWidth); /* physicalWidth */ @@ -2228,7 +2221,6 @@ BOOL gcc_read_client_monitor_extended_data(wStream* s, rdpMcs* mcs) BOOL gcc_write_client_monitor_extended_data(wStream* s, const rdpMcs* mcs) { - UINT32 i = 0; UINT16 length = 0; const rdpSettings* settings = mcs_get_const_settings(mcs); @@ -2244,7 +2236,7 @@ BOOL gcc_write_client_monitor_extended_data(wStream* s, const rdpMcs* mcs) Stream_Write_UINT32(s, 20); /* monitorAttributeSize */ Stream_Write_UINT32(s, settings->MonitorCount); /* monitorCount */ - for (i = 0; i < settings->MonitorCount; i++) + for (UINT32 i = 0; i < settings->MonitorCount; i++) { const rdpMonitor* current = &settings->MonitorDefArray[i]; Stream_Write_UINT32(s, current->attributes.physicalWidth); /* physicalWidth */ diff --git a/libfreerdp/core/info.c b/libfreerdp/core/info.c index a46b357d4..0d8e90ee2 100644 --- a/libfreerdp/core/info.c +++ b/libfreerdp/core/info.c @@ -122,14 +122,13 @@ static char* rdp_info_package_flags_description(UINT32 flags) { char* result = NULL; size_t maximum_size = 1 + MAX_LABEL_LENGTH * ARRAYSIZE(info_flags); - size_t i = 0; result = calloc(maximum_size, sizeof(char)); if (!result) return 0; - for (i = 0; i < ARRAYSIZE(info_flags); i++) + for (size_t i = 0; i < ARRAYSIZE(info_flags); i++) { const struct info_flags_t* cur = &info_flags[i]; if (cur->flag & flags) diff --git a/libfreerdp/core/input.c b/libfreerdp/core/input.c index fd6b7a0d5..45dc05481 100644 --- a/libfreerdp/core/input.c +++ b/libfreerdp/core/input.c @@ -829,7 +829,6 @@ static BOOL input_recv_event(rdpInput* input, wStream* s) BOOL input_recv(rdpInput* input, wStream* s) { - UINT16 i = 0; UINT16 numberEvents = 0; WINPR_ASSERT(input); @@ -845,7 +844,7 @@ BOOL input_recv(rdpInput* input, wStream* s) if (!Stream_CheckAndLogRequiredLengthOfSize(TAG, s, numberEvents, 6ull)) return FALSE; - for (i = 0; i < numberEvents; i++) + for (UINT16 i = 0; i < numberEvents; i++) { if (!input_recv_event(input, s)) return FALSE; diff --git a/libfreerdp/core/listener.c b/libfreerdp/core/listener.c index 9fa16cd43..5a9c1e2d0 100644 --- a/libfreerdp/core/listener.c +++ b/libfreerdp/core/listener.c @@ -133,7 +133,6 @@ static BOOL freerdp_listener_open(freerdp_listener* instance, const char* bind_a char addr[64]; void* sin_addr = NULL; int option_value = 0; - struct addrinfo* ai = NULL; struct addrinfo* res = NULL; rdpListener* listener = (rdpListener*)instance->listener; #ifdef _WIN32 @@ -154,7 +153,7 @@ static BOOL freerdp_listener_open(freerdp_listener* instance, const char* bind_a if (!res) return FALSE; - for (ai = res; ai && (listener->num_sockfds < 5); ai = ai->ai_next) + for (struct addrinfo* ai = res; ai && (listener->num_sockfds < 5); ai = ai->ai_next) { if ((ai->ai_family != AF_INET) && (ai->ai_family != AF_INET6)) continue; @@ -330,10 +329,9 @@ static BOOL freerdp_listener_open_from_socket(freerdp_listener* instance, int fd static void freerdp_listener_close(freerdp_listener* instance) { - int i = 0; rdpListener* listener = (rdpListener*)instance->listener; - for (i = 0; i < listener->num_sockfds; i++) + for (int i = 0; i < listener->num_sockfds; i++) { closesocket((SOCKET)listener->sockfds[i]); CloseHandle(listener->events[i]); @@ -345,13 +343,12 @@ static void freerdp_listener_close(freerdp_listener* instance) #if defined(WITH_FREERDP_DEPRECATED) static BOOL freerdp_listener_get_fds(freerdp_listener* instance, void** rfds, int* rcount) { - int index = 0; rdpListener* listener = (rdpListener*)instance->listener; if (listener->num_sockfds < 1) return FALSE; - for (index = 0; index < listener->num_sockfds; index++) + for (int index = 0; index < listener->num_sockfds; index++) { rfds[*rcount] = (void*)(long)(listener->sockfds[index]); (*rcount)++; @@ -364,7 +361,6 @@ static BOOL freerdp_listener_get_fds(freerdp_listener* instance, void** rfds, in static DWORD freerdp_listener_get_event_handles(freerdp_listener* instance, HANDLE* events, DWORD nCount) { - int index = 0; rdpListener* listener = (rdpListener*)instance->listener; if (listener->num_sockfds < 1) @@ -373,7 +369,7 @@ static DWORD freerdp_listener_get_event_handles(freerdp_listener* instance, HAND if (listener->num_sockfds > (INT64)nCount) return 0; - for (index = 0; index < listener->num_sockfds; index++) + for (int index = 0; index < listener->num_sockfds; index++) { events[index] = listener->events[index]; } diff --git a/libfreerdp/core/mcs.c b/libfreerdp/core/mcs.c index e45fe001c..45625bd5a 100644 --- a/libfreerdp/core/mcs.c +++ b/libfreerdp/core/mcs.c @@ -300,8 +300,6 @@ static BOOL mcs_read_domain_mcspdu_header(wStream* s, DomainMCSPDU domainMCSPDU, static int mcs_initialize_client_channels(rdpMcs* mcs, const rdpSettings* settings) { - UINT32 index = 0; - if (!mcs || !settings) return -1; @@ -312,7 +310,7 @@ static int mcs_initialize_client_channels(rdpMcs* mcs, const rdpSettings* settin ZeroMemory(mcs->channels, sizeof(rdpMcsChannel) * mcs->channelMaxCount); - for (index = 0; index < mcs->channelCount; index++) + for (UINT32 index = 0; index < mcs->channelCount; index++) { const CHANNEL_DEF* defchannel = freerdp_settings_get_pointer_array(settings, FreeRDP_ChannelDefArray, index); diff --git a/libfreerdp/core/nego.c b/libfreerdp/core/nego.c index 610f2b099..52543cf95 100644 --- a/libfreerdp/core/nego.c +++ b/libfreerdp/core/nego.c @@ -1155,7 +1155,6 @@ static BOOL nego_process_correlation_info(rdpNego* nego, wStream* s) { UINT8 type = 0; UINT8 flags = 0; - UINT8 x = 0; UINT16 length = 0; BYTE correlationId[16] = { 0 }; @@ -1191,12 +1190,12 @@ static BOOL nego_process_correlation_info(rdpNego* nego, wStream* s) correlationId[0]); return FALSE; } - for (x = 0; x < ARRAYSIZE(correlationId); x++) + for (size_t x = 0; x < ARRAYSIZE(correlationId); x++) { if (correlationId[x] == 0x0D) { WLog_ERR(TAG, - "(RDP_NEG_CORRELATION_INFO::correlationId[%" PRIu8 + "(RDP_NEG_CORRELATION_INFO::correlationId[%" PRIuz "] has invalid value 0x%02" PRIx8, x, correlationId[x]); return FALSE; diff --git a/libfreerdp/core/orders.c b/libfreerdp/core/orders.c index 97aaf5470..855b700ac 100644 --- a/libfreerdp/core/orders.c +++ b/libfreerdp/core/orders.c @@ -956,7 +956,6 @@ static INLINE BOOL update_write_brush(wStream* s, rdpBrush* brush, BYTE fieldFla static INLINE BOOL update_read_delta_rects(wStream* s, DELTA_RECT* rectangles, UINT32* nr) { UINT32 number = *nr; - UINT32 i = 0; BYTE flags = 0; BYTE* zeroBits = NULL; UINT32 zeroBitsSize = 0; @@ -976,7 +975,7 @@ static INLINE BOOL update_read_delta_rects(wStream* s, DELTA_RECT* rectangles, U Stream_Seek(s, zeroBitsSize); ZeroMemory(rectangles, sizeof(DELTA_RECT) * number); - for (i = 0; i < number; i++) + for (UINT32 i = 0; i < number; i++) { if (i % 2 == 0) flags = zeroBits[i / 2]; @@ -2575,7 +2574,6 @@ BOOL update_write_cache_bitmap_v3_order(wStream* s, CACHE_BITMAP_V3_ORDER* cache static CACHE_COLOR_TABLE_ORDER* update_read_cache_color_table_order(rdpUpdate* update, wStream* s, UINT16 flags) { - int i = 0; UINT32* colorTable = NULL; CACHE_COLOR_TABLE_ORDER* cache_color_table = calloc(1, sizeof(CACHE_COLOR_TABLE_ORDER)); @@ -2599,7 +2597,7 @@ static CACHE_COLOR_TABLE_ORDER* update_read_cache_color_table_order(rdpUpdate* u colorTable = (UINT32*)&cache_color_table->colorTable; - for (i = 0; i < (int)cache_color_table->numberColors; i++) + for (UINT32 i = 0; i < cache_color_table->numberColors; i++) update_read_color_quad(s, &colorTable[i]); return cache_color_table; @@ -2624,7 +2622,6 @@ BOOL update_write_cache_color_table_order(wStream* s, const CACHE_COLOR_TABLE_ORDER* cache_color_table, UINT16* flags) { - size_t i = 0; size_t inf = 0; const UINT32* colorTable = NULL; @@ -2640,7 +2637,7 @@ BOOL update_write_cache_color_table_order(wStream* s, Stream_Write_UINT16(s, cache_color_table->numberColors); /* numberColors (2 bytes) */ colorTable = (const UINT32*)&cache_color_table->colorTable; - for (i = 0; i < cache_color_table->numberColors; i++) + for (size_t i = 0; i < cache_color_table->numberColors; i++) { update_write_color_quad(s, colorTable[i]); } @@ -2649,7 +2646,6 @@ BOOL update_write_cache_color_table_order(wStream* s, } static CACHE_GLYPH_ORDER* update_read_cache_glyph_order(rdpUpdate* update, wStream* s, UINT16 flags) { - UINT32 i = 0; CACHE_GLYPH_ORDER* cache_glyph_order = calloc(1, sizeof(CACHE_GLYPH_ORDER)); WINPR_ASSERT(update); @@ -2664,7 +2660,7 @@ static CACHE_GLYPH_ORDER* update_read_cache_glyph_order(rdpUpdate* update, wStre Stream_Read_UINT8(s, cache_glyph_order->cacheId); /* cacheId (1 byte) */ Stream_Read_UINT8(s, cache_glyph_order->cGlyphs); /* cGlyphs (1 byte) */ - for (i = 0; i < cache_glyph_order->cGlyphs; i++) + for (UINT32 i = 0; i < cache_glyph_order->cGlyphs; i++) { GLYPH_DATA* glyph = &cache_glyph_order->glyphData[i]; @@ -2720,7 +2716,6 @@ size_t update_approximate_cache_glyph_order(const CACHE_GLYPH_ORDER* cache_glyph BOOL update_write_cache_glyph_order(wStream* s, const CACHE_GLYPH_ORDER* cache_glyph, UINT16* flags) { - UINT32 i = 0; INT16 lsi16 = 0; const GLYPH_DATA* glyph = NULL; size_t inf = update_approximate_cache_glyph_order(cache_glyph, flags); @@ -2731,7 +2726,7 @@ BOOL update_write_cache_glyph_order(wStream* s, const CACHE_GLYPH_ORDER* cache_g Stream_Write_UINT8(s, cache_glyph->cacheId); /* cacheId (1 byte) */ Stream_Write_UINT8(s, cache_glyph->cGlyphs); /* cGlyphs (1 byte) */ - for (i = 0; i < cache_glyph->cGlyphs; i++) + for (UINT32 i = 0; i < cache_glyph->cGlyphs; i++) { UINT32 cb = 0; glyph = &cache_glyph->glyphData[i]; @@ -2758,7 +2753,6 @@ BOOL update_write_cache_glyph_order(wStream* s, const CACHE_GLYPH_ORDER* cache_g static CACHE_GLYPH_V2_ORDER* update_read_cache_glyph_v2_order(rdpUpdate* update, wStream* s, UINT16 flags) { - UINT32 i = 0; CACHE_GLYPH_V2_ORDER* cache_glyph_v2 = calloc(1, sizeof(CACHE_GLYPH_V2_ORDER)); if (!cache_glyph_v2) @@ -2768,7 +2762,7 @@ static CACHE_GLYPH_V2_ORDER* update_read_cache_glyph_v2_order(rdpUpdate* update, cache_glyph_v2->flags = (flags & 0x00F0) >> 4; cache_glyph_v2->cGlyphs = (flags & 0xFF00) >> 8; - for (i = 0; i < cache_glyph_v2->cGlyphs; i++) + for (UINT32 i = 0; i < cache_glyph_v2->cGlyphs; i++) { GLYPH_DATA_V2* glyph = &cache_glyph_v2->glyphData[i]; @@ -2828,7 +2822,6 @@ size_t update_approximate_cache_glyph_v2_order(const CACHE_GLYPH_V2_ORDER* cache BOOL update_write_cache_glyph_v2_order(wStream* s, const CACHE_GLYPH_V2_ORDER* cache_glyph_v2, UINT16* flags) { - UINT32 i = 0; size_t inf = update_approximate_cache_glyph_v2_order(cache_glyph_v2, flags); if (!Stream_EnsureRemainingCapacity(s, inf)) @@ -2837,7 +2830,7 @@ BOOL update_write_cache_glyph_v2_order(wStream* s, const CACHE_GLYPH_V2_ORDER* c *flags = (cache_glyph_v2->cacheId & 0x000F) | ((cache_glyph_v2->flags & 0x000F) << 4) | ((cache_glyph_v2->cGlyphs & 0x00FF) << 8); - for (i = 0; i < cache_glyph_v2->cGlyphs; i++) + for (UINT32 i = 0; i < cache_glyph_v2->cGlyphs; i++) { UINT32 cb = 0; const GLYPH_DATA_V2* glyph = &cache_glyph_v2->glyphData[i]; @@ -2864,9 +2857,6 @@ BOOL update_write_cache_glyph_v2_order(wStream* s, const CACHE_GLYPH_V2_ORDER* c } static BOOL update_decompress_brush(wStream* s, BYTE* output, size_t outSize, BYTE bpp) { - size_t x = 0; - size_t k = 0; - INT8 y = 0; BYTE byte = 0; const BYTE* palette = Stream_PointerAs(s, const BYTE) + 16; const size_t bytesPerPixel = ((bpp + 1) / 8); @@ -2874,9 +2864,9 @@ static BOOL update_decompress_brush(wStream* s, BYTE* output, size_t outSize, BY if (!Stream_CheckAndLogRequiredLengthOfSize(TAG, s, 4ULL + bytesPerPixel, 4ULL)) return FALSE; - for (y = 7; y >= 0; y--) + for (INT8 y = 7; y >= 0; y--) { - for (x = 0; x < 8; x++) + for (size_t x = 0; x < 8; x++) { UINT32 index = 0; if ((x % 4) == 0) @@ -2884,7 +2874,7 @@ static BOOL update_decompress_brush(wStream* s, BYTE* output, size_t outSize, BY index = ((byte >> ((3 - (x % 4)) * 2)) & 0x03); - for (k = 0; k < bytesPerPixel; k++) + for (size_t k = 0; k < bytesPerPixel; k++) { const size_t dstIndex = ((y * 8 + x) * bytesPerPixel) + k; const size_t srcIndex = (index * bytesPerPixel) + k; @@ -2903,7 +2893,6 @@ static BOOL update_compress_brush(wStream* s, const BYTE* input, BYTE bpp) } static CACHE_BRUSH_ORDER* update_read_cache_brush_order(rdpUpdate* update, wStream* s, UINT16 flags) { - int i = 0; BOOL rc = 0; BYTE iBitmapFormat = 0; BOOL compressed = FALSE; @@ -2945,7 +2934,7 @@ static CACHE_BRUSH_ORDER* update_read_cache_brush_order(rdpUpdate* update, wStre goto fail; /* rows are encoded in reverse order */ - for (i = 7; i >= 0; i--) + for (int i = 7; i >= 0; i--) Stream_Read_UINT8(s, cache_brush->data[i]); } else @@ -2974,7 +2963,7 @@ static CACHE_BRUSH_ORDER* update_read_cache_brush_order(rdpUpdate* update, wStre if (!Stream_CheckAndLogRequiredLengthOfSize(TAG, s, scanline, 8ull)) goto fail; - for (i = 7; i >= 0; i--) + for (int i = 7; i >= 0; i--) { Stream_Read(s, &cache_brush->data[i * scanline], scanline); } @@ -2998,7 +2987,6 @@ size_t update_approximate_cache_brush_order(const CACHE_BRUSH_ORDER* cache_brush BOOL update_write_cache_brush_order(wStream* s, const CACHE_BRUSH_ORDER* cache_brush, UINT16* flags) { - int i = 0; BYTE iBitmapFormat = 0; BOOL rc = 0; BOOL compressed = FALSE; @@ -3027,7 +3015,7 @@ BOOL update_write_cache_brush_order(wStream* s, const CACHE_BRUSH_ORDER* cache_b return FALSE; } - for (i = 7; i >= 0; i--) + for (int i = 7; i >= 0; i--) { Stream_Write_UINT8(s, cache_brush->data[i]); } @@ -3052,7 +3040,7 @@ BOOL update_write_cache_brush_order(wStream* s, const CACHE_BRUSH_ORDER* cache_b /* uncompressed brush */ int scanline = (cache_brush->bpp / 8) * 8; - for (i = 7; i >= 0; i--) + for (int i = 7; i >= 0; i--) { Stream_Write(s, &cache_brush->data[i * scanline], scanline); } @@ -3090,8 +3078,6 @@ update_read_create_offscreen_bitmap_order(wStream* s, if (deleteListPresent) { - UINT32 i = 0; - if (!Stream_CheckAndLogRequiredLength(TAG, s, 2)) return FALSE; @@ -3112,7 +3098,7 @@ update_read_create_offscreen_bitmap_order(wStream* s, if (!Stream_CheckAndLogRequiredLengthOfSize(TAG, s, deleteList->cIndices, 2ull)) return FALSE; - for (i = 0; i < deleteList->cIndices; i++) + for (UINT32 i = 0; i < deleteList->cIndices; i++) { Stream_Read_UINT16(s, deleteList->indices[i]); } @@ -3162,10 +3148,9 @@ BOOL update_write_create_offscreen_bitmap_order( if (deleteListPresent) { - int i = 0; Stream_Write_UINT16(s, deleteList->cIndices); - for (i = 0; i < (int)deleteList->cIndices; i++) + for (size_t i = 0; i < deleteList->cIndices; i++) { Stream_Write_UINT16(s, deleteList->indices[i]); } @@ -3356,7 +3341,6 @@ update_read_draw_gdiplus_cache_end_order(wStream* s, } static BOOL update_read_field_flags(wStream* s, UINT32* fieldFlags, BYTE flags, BYTE fieldBytes) { - int i = 0; BYTE byte = 0; if (flags & ORDER_ZERO_FIELD_BYTE_BIT0) @@ -3375,7 +3359,7 @@ static BOOL update_read_field_flags(wStream* s, UINT32* fieldFlags, BYTE flags, *fieldFlags = 0; - for (i = 0; i < fieldBytes; i++) + for (int i = 0; i < fieldBytes; i++) { Stream_Read_UINT8(s, byte); *fieldFlags |= byte << (i * 8); diff --git a/libfreerdp/core/peer.c b/libfreerdp/core/peer.c index 2c4bf228c..9d00c661d 100644 --- a/libfreerdp/core/peer.c +++ b/libfreerdp/core/peer.c @@ -68,7 +68,7 @@ static HANDLE freerdp_peer_virtual_channel_open(freerdp_peer* client, const char if (length > 8) return NULL; /* SVC maximum name length is 8 */ - for (index = 0; index < mcs->channelCount; index++) + for (; index < mcs->channelCount; index++) { mcsChannel = &(mcs->channels[index]); diff --git a/libfreerdp/core/rdp.c b/libfreerdp/core/rdp.c index 16b48a280..ae3a4648b 100644 --- a/libfreerdp/core/rdp.c +++ b/libfreerdp/core/rdp.c @@ -1028,9 +1028,7 @@ static BOOL rdp_recv_server_status_info_pdu(rdpRdp* rdp, wStream* s) static BOOL rdp_recv_monitor_layout_pdu(rdpRdp* rdp, wStream* s) { - UINT32 index = 0; UINT32 monitorCount = 0; - MONITOR_DEF* monitor = NULL; MONITOR_DEF* monitorDefArray = NULL; BOOL ret = TRUE; @@ -1048,8 +1046,9 @@ static BOOL rdp_recv_monitor_layout_pdu(rdpRdp* rdp, wStream* s) if (!monitorDefArray) return FALSE; - for (monitor = monitorDefArray, index = 0; index < monitorCount; index++, monitor++) + for (UINT32 index = 0; index < monitorCount; index++) { + MONITOR_DEF* monitor = &monitorDefArray[index]; Stream_Read_INT32(s, monitor->left); /* left (4 bytes) */ Stream_Read_INT32(s, monitor->top); /* top (4 bytes) */ Stream_Read_INT32(s, monitor->right); /* right (4 bytes) */ diff --git a/libfreerdp/core/server.c b/libfreerdp/core/server.c index 015aa3088..e675e0a11 100644 --- a/libfreerdp/core/server.c +++ b/libfreerdp/core/server.c @@ -483,7 +483,6 @@ static BOOL WTSProcessChannelData(rdpPeerChannel* channel, UINT16 channelId, con static BOOL WTSReceiveChannelData(freerdp_peer* client, UINT16 channelId, const BYTE* data, size_t size, UINT32 flags, size_t totalSize) { - UINT32 i = 0; rdpMcs* mcs = NULL; WINPR_ASSERT(client); @@ -493,7 +492,7 @@ static BOOL WTSReceiveChannelData(freerdp_peer* client, UINT16 channelId, const mcs = client->context->rdp->mcs; WINPR_ASSERT(mcs); - for (i = 0; i < mcs->channelCount; i++) + for (UINT32 i = 0; i < mcs->channelCount; i++) { rdpMcsChannel* cur = &mcs->channels[i]; if (cur->ChannelId == channelId) @@ -640,12 +639,10 @@ HANDLE WTSVirtualChannelManagerGetEventHandle(HANDLE hServer) static rdpMcsChannel* wts_get_joined_channel_by_name(rdpMcs* mcs, const char* channel_name) { - UINT32 index = 0; - if (!mcs || !channel_name || !strnlen(channel_name, CHANNEL_NAME_LEN + 1)) return NULL; - for (index = 0; index < mcs->channelCount; index++) + for (UINT32 index = 0; index < mcs->channelCount; index++) { rdpMcsChannel* mchannel = &mcs->channels[index]; if (mchannel->joined) @@ -660,13 +657,11 @@ static rdpMcsChannel* wts_get_joined_channel_by_name(rdpMcs* mcs, const char* ch static rdpMcsChannel* wts_get_joined_channel_by_id(rdpMcs* mcs, const UINT16 channel_id) { - UINT32 index = 0; - if (!mcs || !channel_id) return NULL; WINPR_ASSERT(mcs->channels); - for (index = 0; index < mcs->channelCount; index++) + for (UINT32 index = 0; index < mcs->channelCount; index++) { rdpMcsChannel* mchannel = &mcs->channels[index]; if (mchannel->joined) @@ -833,7 +828,6 @@ char** WTSGetAcceptedChannelNames(freerdp_peer* client, size_t* count) { rdpMcs* mcs = NULL; char** names = NULL; - UINT32 index = 0; if (!client || !client->context || !count) return NULL; @@ -847,7 +841,7 @@ char** WTSGetAcceptedChannelNames(freerdp_peer* client, size_t* count) if (!names) return NULL; - for (index = 0; index < mcs->channelCount; index++) + for (UINT32 index = 0; index < mcs->channelCount; index++) { rdpMcsChannel* mchannel = &mcs->channels[index]; names[index] = mchannel->Name; @@ -1263,7 +1257,6 @@ fail: HANDLE WINAPI FreeRDP_WTSVirtualChannelOpen(HANDLE hServer, DWORD SessionId, LPSTR pVirtualName) { size_t length = 0; - UINT32 index = 0; rdpMcs* mcs = NULL; rdpMcsChannel* joined_channel = NULL; freerdp_peer* client = NULL; @@ -1298,7 +1291,8 @@ HANDLE WINAPI FreeRDP_WTSVirtualChannelOpen(HANDLE hServer, DWORD SessionId, LPS return NULL; } - for (index = 0; index < mcs->channelCount; index++) + UINT32 index = 0; + for (; index < mcs->channelCount; index++) { rdpMcsChannel* mchannel = &mcs->channels[index]; if (mchannel->joined && (strncmp(mchannel->Name, pVirtualName, length) == 0)) @@ -1339,7 +1333,6 @@ fail: HANDLE WINAPI FreeRDP_WTSVirtualChannelOpenEx(DWORD SessionId, LPSTR pVirtualName, DWORD flags) { - UINT32 index = 0; wStream* s = NULL; rdpMcs* mcs = NULL; BOOL joined = FALSE; @@ -1365,7 +1358,7 @@ HANDLE WINAPI FreeRDP_WTSVirtualChannelOpenEx(DWORD SessionId, LPSTR pVirtualNam client = vcm->client; mcs = client->context->rdp->mcs; - for (index = 0; index < mcs->channelCount; index++) + for (UINT32 index = 0; index < mcs->channelCount; index++) { rdpMcsChannel* mchannel = &mcs->channels[index]; if (mchannel->joined && diff --git a/libfreerdp/core/settings.c b/libfreerdp/core/settings.c index e57ea6821..7fde0a481 100644 --- a/libfreerdp/core/settings.c +++ b/libfreerdp/core/settings.c @@ -154,10 +154,8 @@ static void settings_client_load_hkey_local_machine(rdpSettings* settings) if (status == ERROR_SUCCESS) { - unsigned x = 0; - settings_reg_query_dword(settings, FreeRDP_BitmapCacheV2NumCells, hKey, _T("NumCells")); - for (x = 0; x < 5; x++) + for (unsigned x = 0; x < 5; x++) { DWORD val = 0; TCHAR numentries[64] = { 0 }; @@ -186,7 +184,7 @@ static void settings_client_load_hkey_local_machine(rdpSettings* settings) unsigned x = 0; UINT32 GlyphSupportLevel = 0; settings_reg_query_dword(settings, FreeRDP_GlyphSupportLevel, hKey, _T("SupportLevel")); - for (x = 0; x < 10; x++) + for (; x < 10; x++) { GLYPH_CACHE_DEFINITION cache = { 0 }; TCHAR numentries[64] = { 0 }; @@ -739,11 +737,10 @@ rdpSettings* freerdp_settings_new(DWORD flags) else { BOOL res = 0; - size_t i = 0; char* cpath = NULL; char product[sizeof(FREERDP_PRODUCT_STRING)] = { 0 }; - for (i = 0; i < sizeof(product); i++) + for (size_t i = 0; i < sizeof(product); i++) product[i] = tolower(FREERDP_PRODUCT_STRING[i]); cpath = GetKnownSubPath(KNOWN_PATH_XDG_CONFIG_HOME, product); @@ -825,7 +822,6 @@ void freerdp_settings_free(rdpSettings* settings) static BOOL freerdp_settings_int_buffer_copy(rdpSettings* _settings, const rdpSettings* settings) { BOOL rc = FALSE; - UINT32 index = 0; if (!_settings || !settings) return FALSE; @@ -1007,7 +1003,7 @@ static BOOL freerdp_settings_int_buffer_copy(rdpSettings* _settings, const rdpSe if (!freerdp_settings_set_uint32(_settings, FreeRDP_DeviceCount, count)) goto out_fail; - for (index = 0; index < count; index++) + for (size_t index = 0; index < count; index++) { const RDPDR_DEVICE* argv = freerdp_settings_get_pointer_array(settings, FreeRDP_DeviceArray, index); @@ -1026,7 +1022,7 @@ static BOOL freerdp_settings_int_buffer_copy(rdpSettings* _settings, const rdpSe if (!freerdp_settings_set_uint32(_settings, FreeRDP_StaticChannelCount, count)) goto out_fail; - for (index = 0; index < count; index++) + for (size_t index = 0; index < count; index++) { const ADDIN_ARGV* argv = freerdp_settings_get_pointer_array(settings, FreeRDP_StaticChannelArray, index); @@ -1046,7 +1042,7 @@ static BOOL freerdp_settings_int_buffer_copy(rdpSettings* _settings, const rdpSe if (!freerdp_settings_set_uint32(_settings, FreeRDP_DynamicChannelCount, count)) goto out_fail; - for (index = 0; index < count; index++) + for (size_t index = 0; index < count; index++) { const ADDIN_ARGV* argv = freerdp_settings_get_pointer_array(settings, FreeRDP_DynamicChannelArray, index); diff --git a/libfreerdp/core/smartcardlogon.c b/libfreerdp/core/smartcardlogon.c index db09e7541..d5907cf0c 100644 --- a/libfreerdp/core/smartcardlogon.c +++ b/libfreerdp/core/smartcardlogon.c @@ -611,12 +611,11 @@ static BOOL smartcard_hw_enumerateCerts(const rdpSettings* settings, LPCWSTR csp { NCryptProviderName* names = NULL; DWORD nproviders = 0; - DWORD i = 0; #ifdef _WIN32 /* On Windows, mstsc first enumerates the legacy CAPI providers for usable certificates. */ DWORD provType, cbProvName = 0; - for (i = 0; CryptEnumProvidersW(i, NULL, 0, &provType, NULL, &cbProvName); ++i) + for (DWORD i = 0; CryptEnumProvidersW(i, NULL, 0, &provType, NULL, &cbProvName); ++i) { char providerNameStr[256] = { 0 }; LPWSTR szProvName = malloc(cbProvName * sizeof(WCHAR)); @@ -656,7 +655,7 @@ static BOOL smartcard_hw_enumerateCerts(const rdpSettings* settings, LPCWSTR csp goto out; } - for (i = 0; i < nproviders; i++) + for (DWORD i = 0; i < nproviders; i++) { char providerNameStr[256] = { 0 }; const NCryptProviderName* name = &names[i]; diff --git a/libfreerdp/core/streamdump.c b/libfreerdp/core/streamdump.c index ec54f1fe5..7db763265 100644 --- a/libfreerdp/core/streamdump.c +++ b/libfreerdp/core/streamdump.c @@ -44,10 +44,9 @@ struct stream_dump_context static UINT32 crc32b(const BYTE* data, size_t length) { - size_t x = 0; UINT32 crc = 0xFFFFFFFF; - for (x = 0; x < length; x++) + for (size_t x = 0; x < length; x++) { const UINT32 d = data[x] & 0xFF; crc = crc ^ d; diff --git a/libfreerdp/core/tcp.c b/libfreerdp/core/tcp.c index 48545075a..f9e216fe2 100644 --- a/libfreerdp/core/tcp.c +++ b/libfreerdp/core/tcp.c @@ -899,7 +899,6 @@ static void peer_free(t_peer* peer) static int freerdp_tcp_connect_multi(rdpContext* context, char** hostnames, UINT32* ports, UINT32 count, UINT16 port, UINT32 timeout) { - UINT32 index = 0; UINT32 sindex = count; int status = -1; SOCKET sockfd = INVALID_SOCKET; @@ -917,7 +916,7 @@ static int freerdp_tcp_connect_multi(rdpContext* context, char** hostnames, UINT return -1; } - for (index = 0; index < count; index++) + for (UINT32 index = 0; index < count; index++) { int curPort = port; @@ -955,7 +954,7 @@ static int freerdp_tcp_connect_multi(rdpContext* context, char** hostnames, UINT peers[index].result = result; } - for (index = 0; index < count; index++) + for (UINT32 index = 0; index < count; index++) { sockfd = peers[index].s; addr = peers[index].addr; @@ -982,7 +981,7 @@ static int freerdp_tcp_connect_multi(rdpContext* context, char** hostnames, UINT else freerdp_set_last_error_log(context, FREERDP_ERROR_CONNECT_CANCELLED); - for (index = 0; index < count; index++) + for (UINT32 index = 0; index < count; index++) peer_free(&peers[index]); free(peers); diff --git a/libfreerdp/core/test/TestConnect.c b/libfreerdp/core/test/TestConnect.c index 7fd42ddc3..17e73c939 100644 --- a/libfreerdp/core/test/TestConnect.c +++ b/libfreerdp/core/test/TestConnect.c @@ -185,12 +185,11 @@ static int testAbort(int port) static char* concatenate(size_t count, ...) { - size_t x = 0; char* rc = NULL; va_list ap; va_start(ap, count); rc = _strdup(va_arg(ap, char*)); - for (x = 1; x < count; x++) + for (size_t x = 1; x < count; x++) { const char* cur = va_arg(ap, const char*); char* tmp = GetCombinedPath(rc, cur); diff --git a/libfreerdp/core/test/TestSettings.c b/libfreerdp/core/test/TestSettings.c index 5896ac810..ea21cb3e5 100644 --- a/libfreerdp/core/test/TestSettings.c +++ b/libfreerdp/core/test/TestSettings.c @@ -15,7 +15,6 @@ static BOOL log_result(BOOL value, const char* fkt) static BOOL compare(const ADDIN_ARGV* got, const ADDIN_ARGV* expect) { - int x = 0; BOOL rc = TRUE; if (!got && !expect) return FALSE; @@ -26,7 +25,7 @@ static BOOL compare(const ADDIN_ARGV* got, const ADDIN_ARGV* expect) if (got->argc != expect->argc) return FALSE; - for (x = 0; x < expect->argc; x++) + for (int x = 0; x < expect->argc; x++) { if (strcmp(got->argv[x], expect->argv[x]) != 0) rc = FALSE; @@ -447,7 +446,6 @@ static BOOL check_key_helpers(size_t key, const char* stype) SSIZE_T rc = 0; SSIZE_T tkey = 0; SSIZE_T type = 0; - size_t x = 0; const size_t clear_keys[] = { FreeRDP_RdpServerCertificate, FreeRDP_RdpServerRsaKey, FreeRDP_RedirectionPassword, @@ -518,7 +516,7 @@ static BOOL check_key_helpers(size_t key, const char* stype) printf("[%s] freerdp_settings_new failed\n", stype); goto fail; } - for (x = 0; x < ARRAYSIZE(clear_keys); x++) + for (size_t x = 0; x < ARRAYSIZE(clear_keys); x++) { const size_t id = clear_keys[x]; const char* foo = freerdp_settings_get_name_for_key(id); @@ -722,7 +720,6 @@ fail: static BOOL check_device_type(void) { - size_t x = 0; struct test_entry { int expect; @@ -770,7 +767,7 @@ static BOOL check_device_type(void) { -3, 0x123, 4, args }, }; BOOL rc = TRUE; - for (x = 0; x < ARRAYSIZE(tests); x++) + for (size_t x = 0; x < ARRAYSIZE(tests); x++) { const struct test_entry* cur = &tests[x]; int got = check_device_type_arg(cur->type, cur->count, cur->args); @@ -782,7 +779,6 @@ static BOOL check_device_type(void) static BOOL check_offsets(rdpSettings* settings, size_t id, size_t min, size_t max, BOOL checkPtr) { - size_t x = 0; BOOL rc = TRUE; WINPR_ASSERT(settings); @@ -790,7 +786,7 @@ static BOOL check_offsets(rdpSettings* settings, size_t id, size_t min, size_t m if (!freerdp_settings_get_pointer(settings, id)) return FALSE; - for (x = min; x < max; x++) + for (size_t x = min; x < max; x++) { const void* ptr = freerdp_settings_get_pointer_array(settings, id, x); if (!ptr && checkPtr) @@ -802,11 +798,9 @@ static BOOL check_offsets(rdpSettings* settings, size_t id, size_t min, size_t m static BOOL test_write_offsets(rdpSettings* settings, size_t id, size_t elementSize, size_t min, size_t max) { - size_t x = 0; - WINPR_ASSERT(settings); - for (x = min; x < max; x++) + for (size_t x = min; x < max; x++) { const void* ptr = NULL; char buffer[8192] = { 0 }; @@ -834,7 +828,6 @@ static BOOL test_pointer_array(void) size_t size; size_t elementSize; }; - size_t x = 0; const struct pointer_test_case tests[] = { { FALSE, FALSE, FreeRDP_DeviceArray, FreeRDP_DeviceArraySize, 32, sizeof(RDPDR_DEVICE*) }, { FALSE, FALSE, FreeRDP_StaticChannelArray, FreeRDP_StaticChannelArraySize, 32, @@ -872,7 +865,7 @@ static BOOL test_pointer_array(void) if (!settings) goto fail; - for (x = 0; x < ARRAYSIZE(tests); x++) + for (size_t x = 0; x < ARRAYSIZE(tests); x++) { const struct pointer_test_case* cur = &tests[x]; if (!freerdp_settings_set_pointer_len(settings, cur->id, NULL, cur->size)) @@ -939,7 +932,6 @@ fail: int TestSettings(int argc, char* argv[]) { int rc = -1; - size_t x = 0; rdpSettings* settings = NULL; rdpSettings* cloned = NULL; rdpSettings* cloned2 = NULL; @@ -979,7 +971,7 @@ int TestSettings(int argc, char* argv[]) #if defined(have_bool_list_indices) - for (x = 0; x < ARRAYSIZE(bool_list_indices); x++) + for (size_t x = 0; x < ARRAYSIZE(bool_list_indices); x++) { const size_t key = bool_list_indices[x]; const char* name = freerdp_settings_get_name_for_key(key); @@ -999,7 +991,7 @@ int TestSettings(int argc, char* argv[]) #endif #if defined(have_int16_list_indices) - for (x = 0; x < ARRAYSIZE(int16_list_indices); x++) + for (size_t x = 0; x < ARRAYSIZE(int16_list_indices); x++) { const size_t key = int16_list_indices[x]; const char* name = freerdp_settings_get_name_for_key(key); @@ -1019,7 +1011,7 @@ int TestSettings(int argc, char* argv[]) #endif #if defined(have_uint16_list_indices) - for (x = 0; x < ARRAYSIZE(uint16_list_indices); x++) + for (size_t x = 0; x < ARRAYSIZE(uint16_list_indices); x++) { const size_t key = uint16_list_indices[x]; const char* name = freerdp_settings_get_name_for_key(key); @@ -1039,7 +1031,7 @@ int TestSettings(int argc, char* argv[]) #endif #if defined(have_uint32_list_indices) - for (x = 0; x < ARRAYSIZE(uint32_list_indices); x++) + for (size_t x = 0; x < ARRAYSIZE(uint32_list_indices); x++) { const size_t key = uint32_list_indices[x]; const char* name = freerdp_settings_get_name_for_key(key); @@ -1059,7 +1051,7 @@ int TestSettings(int argc, char* argv[]) #endif #if defined(have_int32_list_indices) - for (x = 0; x < ARRAYSIZE(int32_list_indices); x++) + for (size_t x = 0; x < ARRAYSIZE(int32_list_indices); x++) { const size_t key = int32_list_indices[x]; const char* name = freerdp_settings_get_name_for_key(key); @@ -1079,7 +1071,7 @@ int TestSettings(int argc, char* argv[]) #endif #if defined(have_uint64_list_indices) - for (x = 0; x < ARRAYSIZE(uint64_list_indices); x++) + for (size_t x = 0; x < ARRAYSIZE(uint64_list_indices); x++) { const size_t key = uint64_list_indices[x]; const char* name = freerdp_settings_get_name_for_key(key); @@ -1099,7 +1091,7 @@ int TestSettings(int argc, char* argv[]) #endif #if defined(have_int64_list_indices) - for (x = 0; x < ARRAYSIZE(int64_list_indices); x++) + for (size_t x = 0; x < ARRAYSIZE(int64_list_indices); x++) { const size_t key = int64_list_indices[x]; const char* name = freerdp_settings_get_name_for_key(key); @@ -1119,7 +1111,7 @@ int TestSettings(int argc, char* argv[]) #endif #if defined(have_string_list_indices) - for (x = 0; x < ARRAYSIZE(string_list_indices); x++) + for (size_t x = 0; x < ARRAYSIZE(string_list_indices); x++) { const size_t key = string_list_indices[x]; const char val[] = "test-string"; @@ -1144,7 +1136,7 @@ int TestSettings(int argc, char* argv[]) #endif #if defined(have_pointer_list_indices) - for (x = 0; x < ARRAYSIZE(pointer_list_indices); x++) + for (size_t x = 0; x < ARRAYSIZE(pointer_list_indices); x++) { const size_t key = pointer_list_indices[x]; const void* val = freerdp_settings_get_pointer(settings, key); diff --git a/libfreerdp/core/test/TestStreamDump.c b/libfreerdp/core/test/TestStreamDump.c index 912cc335f..9124a84ac 100644 --- a/libfreerdp/core/test/TestStreamDump.c +++ b/libfreerdp/core/test/TestStreamDump.c @@ -16,7 +16,6 @@ static BOOL test_entry_read_write(void) wStream* sw = NULL; wStream* sr = NULL; size_t offset = 0; - size_t x = 0; UINT64 ts = 0; UINT32 flags = 0; BYTE tmp[16] = { 0 }; @@ -27,7 +26,7 @@ static BOOL test_entry_read_write(void) winpr_RAND(tmp, sizeof(tmp)); - for (x = 0; x < sizeof(tmp); x++) + for (size_t x = 0; x < sizeof(tmp); x++) _snprintf(&tmp2[x * 2], sizeof(tmp2) - 2 * x, "%02" PRIx8, tmp[x]); name = GetKnownSubPath(KNOWN_PATH_TEMP, tmp2); if (!name) diff --git a/libfreerdp/core/transport.c b/libfreerdp/core/transport.c index 2ad2228ec..e4cc57000 100644 --- a/libfreerdp/core/transport.c +++ b/libfreerdp/core/transport.c @@ -1328,7 +1328,6 @@ DWORD transport_get_event_handles(rdpTransport* transport, HANDLE* events, DWORD #if defined(WITH_FREERDP_DEPRECATED) void transport_get_fds(rdpTransport* transport, void** rfds, int* rcount) { - DWORD index = 0; DWORD nCount = 0; HANDLE events[MAXIMUM_WAIT_OBJECTS] = { 0 }; @@ -1339,7 +1338,7 @@ void transport_get_fds(rdpTransport* transport, void** rfds, int* rcount) nCount = transport_get_event_handles(transport, events, ARRAYSIZE(events)); *rcount = nCount + 1; - for (index = 0; index < nCount; index++) + for (DWORD index = 0; index < nCount; index++) { rfds[index] = GetEventWaitObject(events[index]); } diff --git a/libfreerdp/core/update.c b/libfreerdp/core/update.c index d95132bb8..db8ddef1b 100644 --- a/libfreerdp/core/update.c +++ b/libfreerdp/core/update.c @@ -204,7 +204,6 @@ static BOOL update_write_bitmap_data(rdpUpdate* update_pub, wStream* s, BITMAP_D BITMAP_UPDATE* update_read_bitmap_update(rdpUpdate* update, wStream* s) { - UINT32 i = 0; BITMAP_UPDATE* bitmapUpdate = calloc(1, sizeof(BITMAP_UPDATE)); rdp_update_internal* up = update_cast(update); @@ -223,7 +222,7 @@ BITMAP_UPDATE* update_read_bitmap_update(rdpUpdate* update, wStream* s) goto fail; /* rectangles */ - for (i = 0; i < bitmapUpdate->number; i++) + for (UINT32 i = 0; i < bitmapUpdate->number; i++) { if (!update_read_bitmap_data(update, s, &bitmapUpdate->rectangles[i])) goto fail; @@ -262,8 +261,6 @@ static BOOL update_write_bitmap_update(rdpUpdate* update, wStream* s, PALETTE_UPDATE* update_read_palette(rdpUpdate* update, wStream* s) { - int i = 0; - PALETTE_ENTRY* entry = NULL; PALETTE_UPDATE* palette_update = calloc(1, sizeof(PALETTE_UPDATE)); if (!palette_update) @@ -282,9 +279,9 @@ PALETTE_UPDATE* update_read_palette(rdpUpdate* update, wStream* s) goto fail; /* paletteEntries */ - for (i = 0; i < (int)palette_update->number; i++) + for (UINT32 i = 0; i < palette_update->number; i++) { - entry = &palette_update->entries[i]; + PALETTE_ENTRY* entry = &palette_update->entries[i]; Stream_Read_UINT8(s, entry->red); Stream_Read_UINT8(s, entry->green); Stream_Read_UINT8(s, entry->blue); @@ -3044,7 +3041,6 @@ static UINT16 update_calculate_monitored_desktop(const WINDOW_ORDER_INFO* orderI static BOOL update_send_monitored_desktop(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo, const MONITORED_DESKTOP_ORDER* monitoredDesktop) { - UINT32 i = 0; wStream* s = NULL; BYTE controlFlags = ORDER_SECONDARY | (ORDER_TYPE_WINDOW << 2); UINT16 orderSize = update_calculate_monitored_desktop(orderInfo, monitoredDesktop); @@ -3077,7 +3073,7 @@ static BOOL update_send_monitored_desktop(rdpContext* context, const WINDOW_ORDE Stream_Write_UINT8(s, monitoredDesktop->numWindowIds); /* numWindowIds (1 byte) */ /* windowIds */ - for (i = 0; i < monitoredDesktop->numWindowIds; i++) + for (UINT32 i = 0; i < monitoredDesktop->numWindowIds; i++) { Stream_Write_UINT32(s, monitoredDesktop->windowIds[i]); } diff --git a/libfreerdp/core/window.c b/libfreerdp/core/window.c index 33900d20b..cd1e2151c 100644 --- a/libfreerdp/core/window.c +++ b/libfreerdp/core/window.c @@ -239,7 +239,6 @@ static BOOL update_read_notify_icon_infotip(wStream* s, NOTIFY_ICON_INFOTIP* not static BOOL update_read_window_state_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, WINDOW_STATE_ORDER* windowState) { - UINT32 i = 0; size_t size = 0; RECTANGLE_16* newRect = NULL; @@ -378,7 +377,7 @@ static BOOL update_read_window_state_order(wStream* s, WINDOW_ORDER_INFO* orderI return FALSE; /* windowRects */ - for (i = 0; i < windowState->numWindowRects; i++) + for (UINT32 i = 0; i < windowState->numWindowRects; i++) { Stream_Read_UINT16(s, windowState->windowRects[i].left); /* left (2 bytes) */ Stream_Read_UINT16(s, windowState->windowRects[i].top); /* top (2 bytes) */ @@ -423,7 +422,7 @@ static BOOL update_read_window_state_order(wStream* s, WINDOW_ORDER_INFO* orderI return FALSE; /* visibilityRects */ - for (i = 0; i < windowState->numVisibilityRects; i++) + for (UINT32 i = 0; i < windowState->numVisibilityRects; i++) { Stream_Read_UINT16(s, windowState->visibilityRects[i].left); /* left (2 bytes) */ Stream_Read_UINT16(s, windowState->visibilityRects[i].top); /* top (2 bytes) */ @@ -633,9 +632,8 @@ static void dump_window_state_order(wLog* log, const char* msg, const WINDOW_ORD if (order->fieldFlags & WINDOW_ORDER_FIELD_WND_RECTS) { - UINT32 i = 0; DUMP_APPEND(buffer, bufferSize, " windowRects=("); - for (i = 0; i < state->numWindowRects; i++) + for (UINT32 i = 0; i < state->numWindowRects; i++) { DUMP_APPEND(buffer, bufferSize, "(%" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16 ")", state->windowRects[i].left, state->windowRects[i].top, @@ -650,9 +648,8 @@ static void dump_window_state_order(wLog* log, const char* msg, const WINDOW_ORD if (order->fieldFlags & WINDOW_ORDER_FIELD_VISIBILITY) { - UINT32 i = 0; DUMP_APPEND(buffer, bufferSize, " visibilityRects=("); - for (i = 0; i < state->numVisibilityRects; i++) + for (UINT32 i = 0; i < state->numVisibilityRects; i++) { DUMP_APPEND(buffer, bufferSize, "(%" PRIu16 ",%" PRIu16 ",%" PRIu16 ",%" PRIu16 ")", state->visibilityRects[i].left, state->visibilityRects[i].top, @@ -895,7 +892,6 @@ static BOOL update_recv_notification_icon_info_order(rdpUpdate* update, wStream* static BOOL update_read_desktop_actively_monitored_order(wStream* s, WINDOW_ORDER_INFO* orderInfo, MONITORED_DESKTOP_ORDER* monitored_desktop) { - int i = 0; int size = 0; if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_DESKTOP_ACTIVE_WND) @@ -933,7 +929,7 @@ static BOOL update_read_desktop_actively_monitored_order(wStream* s, WINDOW_ORDE monitored_desktop->windowIds = newid; /* windowIds */ - for (i = 0; i < (int)monitored_desktop->numWindowIds; i++) + for (UINT32 i = 0; i < (int)monitored_desktop->numWindowIds; i++) { Stream_Read_UINT32(s, monitored_desktop->windowIds[i]); } @@ -961,10 +957,8 @@ static void dump_monitored_desktop(wLog* log, const char* msg, const WINDOW_ORDE if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_DESKTOP_ZORDER) { - UINT32 i = 0; - DUMP_APPEND(buffer, bufferSize, " windows=("); - for (i = 0; i < monitored->numWindowIds; i++) + for (UINT32 i = 0; i < monitored->numWindowIds; i++) { DUMP_APPEND(buffer, bufferSize, "0x%" PRIx32 ",", monitored->windowIds[i]); } diff --git a/libfreerdp/crypto/base64.c b/libfreerdp/crypto/base64.c index fce8ba34c..683d29703 100644 --- a/libfreerdp/crypto/base64.c +++ b/libfreerdp/crypto/base64.c @@ -33,7 +33,6 @@ static char* base64_encode_ex(const char* alphabet, const BYTE* data, size_t len const BYTE* q = NULL; char* p = NULL; char* ret = NULL; - int i = 0; int blocks = 0; size_t outLen = (length + 3) * 4 / 3; size_t extra = 0; @@ -63,7 +62,7 @@ static char* base64_encode_ex(const char* alphabet, const BYTE* data, size_t len /* first treat complete blocks */ blocks = length - (length % 3); - for (i = 0; i < blocks; i += 3, q += 3) + for (int i = 0; i < blocks; i += 3, q += 3) { c = (q[0] << 16) + (q[1] << 8) + q[2]; @@ -140,7 +139,6 @@ static void* base64_decode(const char* alphabet, const char* s, size_t length, s BYTE* q = NULL; BYTE* data = NULL; size_t nBlocks = 0; - size_t i = 0; size_t outputLen = 0; int remainder = length % 4; @@ -164,7 +162,7 @@ static void* base64_decode(const char* alphabet, const char* s, size_t length, s return NULL; } - for (i = 0; i < nBlocks - 1; i++, q += 3) + for (size_t i = 0; i < nBlocks - 1; i++, q += 3) { n[0] = base64_decode_char(alphabet, *s++); n[1] = base64_decode_char(alphabet, *s++); diff --git a/libfreerdp/crypto/certificate.c b/libfreerdp/crypto/certificate.c index 5cabec712..ddfe77665 100644 --- a/libfreerdp/crypto/certificate.c +++ b/libfreerdp/crypto/certificate.c @@ -632,9 +632,6 @@ static BOOL certificate_process_server_public_signature(rdpCertificate* certific wStream* s, UINT32 siglen) { WINPR_ASSERT(certificate); -#if defined(CERT_VALIDATE_PADDING) || defined(CERT_VALIDATE_RSA) - size_t i, sum; -#endif #if defined(CERT_VALIDATE_RSA) BYTE sig[TSSK_KEY_LENGTH]; #endif @@ -666,16 +663,17 @@ static BOOL certificate_process_server_public_signature(rdpCertificate* certific /* Last 8 bytes shall be all zero. */ #if defined(CERT_VALIDATE_PADDING) - - for (sum = 0, i = sizeof(encsig) - 8; i < sizeof(encsig); i++) - sum += encsig[i]; - - if (sum != 0) { - WLog_ERR(TAG, "invalid signature"); - return FALSE; - } + size_t sum = 0; + for (size_t i = sizeof(encsig) - 8; i < sizeof(encsig); i++) + sum += encsig[i]; + if (sum != 0) + { + WLog_ERR(TAG, "invalid signature"); + return FALSE; + } + } #endif #if defined(CERT_VALIDATE_RSA) @@ -703,16 +701,17 @@ static BOOL certificate_process_server_public_signature(rdpCertificate* certific * The 18th through 62nd bytes are each 0xFF. * The 63rd byte is 0x01. */ - - for (sum = 0, i = 17; i < 62; i++) - sum += sig[i]; - - if (sig[16] != 0x00 || sum != 0xFF * (62 - 17) || sig[62] != 0x01) { - WLog_ERR(TAG, "invalid signature"); - return FALSE; - } + size_t sum = 0; + for (size_t i = 17; i < 62; i++) + sum += sig[i]; + if (sig[16] != 0x00 || sum != 0xFF * (62 - 17) || sig[62] != 0x01) + { + WLog_ERR(TAG, "invalid signature"); + return FALSE; + } + } #endif return TRUE; } @@ -1335,7 +1334,7 @@ char* freerdp_certificate_get_fingerprint_by_hash_ex(const rdpCertificate* cert, pos = 0; size_t i = 0; - for (i = 0; i < (fp_len - 1); i++) + for (; i < (fp_len - 1); i++) { int rc = 0; char* p = &fp_buffer[pos]; @@ -1436,8 +1435,8 @@ char* freerdp_certificate_get_pem(const rdpCertificate* cert, size_t* pLength) #if 0 if (chain) { - count = sk_X509_num(chain); - for (x = 0; x < count; x++) + int count = sk_X509_num(chain); + for (int x = 0; x < count; x++) { X509* c = sk_X509_value(chain, x); status = PEM_write_bio_X509(bio, c); diff --git a/libfreerdp/crypto/certificate_data.c b/libfreerdp/crypto/certificate_data.c index fb13a0711..a48beb448 100644 --- a/libfreerdp/crypto/certificate_data.c +++ b/libfreerdp/crypto/certificate_data.c @@ -93,7 +93,6 @@ fail: static rdpCertificateData* freerdp_certificate_data_new_nocopy(const char* hostname, UINT16 port, rdpCertificate* xcert) { - size_t i = 0; rdpCertificateData* certdata = NULL; if (!hostname || !xcert) @@ -108,7 +107,7 @@ static rdpCertificateData* freerdp_certificate_data_new_nocopy(const char* hostn certdata->hostname = _strdup(hostname); if (!certdata->hostname) goto fail; - for (i = 0; i < strlen(hostname); i++) + for (size_t i = 0; i < strlen(hostname); i++) certdata->hostname[i] = tolower(certdata->hostname[i]); certdata->cert = xcert; diff --git a/libfreerdp/crypto/crypto.c b/libfreerdp/crypto/crypto.c index 98f85c004..37ddaa12c 100644 --- a/libfreerdp/crypto/crypto.c +++ b/libfreerdp/crypto/crypto.c @@ -175,13 +175,10 @@ SSIZE_T crypto_rsa_private_decrypt(const BYTE* input, size_t length, const rdpPr void crypto_reverse(BYTE* data, size_t length) { - size_t i = 0; - size_t j = 0; - if (length < 1) return; - for (i = 0, j = length - 1; i < j; i++, j--) + for (size_t i = 0, j = length - 1; i < j; i++, j--) { const BYTE temp = data[i]; data[i] = data[j]; diff --git a/libfreerdp/crypto/per.c b/libfreerdp/crypto/per.c index 9e4ad8575..8ccfa4d02 100644 --- a/libfreerdp/crypto/per.c +++ b/libfreerdp/crypto/per.c @@ -475,9 +475,7 @@ BOOL per_write_object_identifier(wStream* s, const BYTE oid[6]) static void per_write_string(wStream* s, BYTE* str, int length) { - int i = 0; - - for (i = 0; i < length; i++) + for (int i = 0; i < length; i++) Stream_Write_UINT8(s, str[i]); } @@ -526,7 +524,6 @@ BOOL per_read_octet_string(wStream* s, const BYTE* oct_str, UINT16 length, UINT1 BOOL per_write_octet_string(wStream* s, const BYTE* oct_str, UINT16 length, UINT16 min) { - UINT16 i = 0; UINT16 mlength = 0; mlength = (length >= min) ? length - min : min; @@ -536,7 +533,7 @@ BOOL per_write_octet_string(wStream* s, const BYTE* oct_str, UINT16 length, UINT if (!Stream_EnsureRemainingCapacity(s, length)) return FALSE; - for (i = 0; i < length; i++) + for (UINT16 i = 0; i < length; i++) Stream_Write_UINT8(s, oct_str[i]); return TRUE; } @@ -578,7 +575,6 @@ BOOL per_read_numeric_string(wStream* s, UINT16 min) BOOL per_write_numeric_string(wStream* s, const BYTE* num_str, UINT16 length, UINT16 min) { - UINT16 i = 0; UINT16 mlength = 0; BYTE num = 0; BYTE c1 = 0; @@ -591,7 +587,7 @@ BOOL per_write_numeric_string(wStream* s, const BYTE* num_str, UINT16 length, UI if (!Stream_EnsureRemainingCapacity(s, length)) return FALSE; - for (i = 0; i < length; i += 2) + for (UINT16 i = 0; i < length; i += 2) { c1 = num_str[i]; c2 = ((i + 1) < length) ? num_str[i + 1] : 0x30; diff --git a/libfreerdp/crypto/test/TestBase64.c b/libfreerdp/crypto/test/TestBase64.c index 4ea055957..d13363756 100644 --- a/libfreerdp/crypto/test/TestBase64.c +++ b/libfreerdp/crypto/test/TestBase64.c @@ -52,7 +52,6 @@ static const struct Encode64test encodeTests_base64url[] = { int TestBase64(int argc, char* argv[]) { - int i = 0; int testNb = 0; size_t outLen = 0; BYTE* decoded = NULL; @@ -61,7 +60,7 @@ int TestBase64(int argc, char* argv[]) testNb++; fprintf(stderr, "%d:encode base64...", testNb); - for (i = 0; encodeTests_base64[i].input; i++) + for (int i = 0; encodeTests_base64[i].input; i++) { char* encoded = crypto_base64_encode((const BYTE*)encodeTests_base64[i].input, encodeTests_base64[i].len); @@ -79,7 +78,7 @@ int TestBase64(int argc, char* argv[]) testNb++; fprintf(stderr, "%d:encode base64url...", testNb); - for (i = 0; encodeTests_base64url[i].input; i++) + for (int i = 0; encodeTests_base64url[i].input; i++) { char* encoded = crypto_base64url_encode((const BYTE*)encodeTests_base64url[i].input, encodeTests_base64url[i].len); @@ -97,7 +96,7 @@ int TestBase64(int argc, char* argv[]) testNb++; fprintf(stderr, "%d:decode base64...", testNb); - for (i = 0; encodeTests_base64[i].input; i++) + for (int i = 0; encodeTests_base64[i].input; i++) { crypto_base64_decode(encodeTests_base64[i].output, strlen(encodeTests_base64[i].output), &decoded, &outLen); @@ -116,7 +115,7 @@ int TestBase64(int argc, char* argv[]) testNb++; fprintf(stderr, "%d:decode base64url...", testNb); - for (i = 0; encodeTests_base64url[i].input; i++) + for (int i = 0; encodeTests_base64url[i].input; i++) { crypto_base64url_decode(encodeTests_base64url[i].output, strlen(encodeTests_base64url[i].output), &decoded, &outLen); diff --git a/libfreerdp/crypto/test/TestKnownHosts.c b/libfreerdp/crypto/test/TestKnownHosts.c index c1b700638..e3a4264fb 100644 --- a/libfreerdp/crypto/test/TestKnownHosts.c +++ b/libfreerdp/crypto/test/TestKnownHosts.c @@ -124,13 +124,12 @@ static int prepare(const char* currentFileV2) " \t#anothercomment\r\n" "otherurl\t3389\taa:bb:cc:dd\tsubject2\tissuer2\r" }; FILE* fc = NULL; - size_t i = 0; fc = winpr_fopen(currentFileV2, "w+"); if (!fc) goto finish; - for (i = 0; i < ARRAYSIZE(hosts); i++) + for (size_t i = 0; i < ARRAYSIZE(hosts); i++) { if (fwrite(hosts[i], strlen(hosts[i]), 1, fc) != 1) goto finish; diff --git a/libfreerdp/crypto/x509_utils.c b/libfreerdp/crypto/x509_utils.c index b0a1ae2bd..dc388e87a 100644 --- a/libfreerdp/crypto/x509_utils.c +++ b/libfreerdp/crypto/x509_utils.c @@ -178,7 +178,6 @@ typedef int (*general_name_mapper_pr)(GENERAL_NAME* name, void* data, int index, static void map_subject_alt_name(const X509* x509, int general_name_type, general_name_mapper_pr mapper, void* data) { - int i = 0; int num = 0; STACK_OF(GENERAL_NAME)* gens = NULL; gens = X509_get_ext_d2i(x509, NID_subject_alt_name, NULL, NULL); @@ -190,7 +189,7 @@ static void map_subject_alt_name(const X509* x509, int general_name_type, num = sk_GENERAL_NAME_num(gens); - for (i = 0; (i < num); i++) + for (int i = 0; (i < num); i++) { GENERAL_NAME* name = sk_GENERAL_NAME_value(gens, i); @@ -586,7 +585,6 @@ static BYTE* x509_utils_get_pem(const X509* xcert, const STACK_OF(X509) * chain, BIO* bio = NULL; int status = 0; int count = 0; - int x = 0; size_t offset = 0; size_t length = 0; BOOL rc = FALSE; @@ -618,7 +616,7 @@ static BYTE* x509_utils_get_pem(const X509* xcert, const STACK_OF(X509) * chain, if (chain) { count = sk_X509_num(chain); - for (x = 0; x < count; x++) + for (int x = 0; x < count; x++) { X509* c = sk_X509_value(chain, x); status = PEM_write_bio_X509(bio, c); diff --git a/libfreerdp/emu/scard/smartcard_emulate.c b/libfreerdp/emu/scard/smartcard_emulate.c index 9824399d6..b2809c34f 100644 --- a/libfreerdp/emu/scard/smartcard_emulate.c +++ b/libfreerdp/emu/scard/smartcard_emulate.c @@ -345,7 +345,6 @@ static LONG scard_handle_valid(SmartcardEmulationContext* smartcard, SCARDHANDLE static LONG scard_reader_name_valid_a(SmartcardEmulationContext* smartcard, SCARDCONTEXT context, const char* name) { - size_t x = 0; SCardContext* ctx = NULL; WINPR_ASSERT(smartcard); @@ -354,7 +353,7 @@ static LONG scard_reader_name_valid_a(SmartcardEmulationContext* smartcard, SCAR WINPR_ASSERT(name); WINPR_ASSERT(ctx); - for (x = 0; x < MAX_EMULATED_READERS; x++) + for (size_t x = 0; x < MAX_EMULATED_READERS; x++) { const SCARD_READERSTATEA* reader = &ctx->readerStateA[x]; if (strcmp(reader->szReader, name) == 0) @@ -367,7 +366,6 @@ static LONG scard_reader_name_valid_a(SmartcardEmulationContext* smartcard, SCAR static LONG scard_reader_name_valid_w(SmartcardEmulationContext* smartcard, SCARDCONTEXT context, const WCHAR* name) { - size_t x = 0; SCardContext* ctx = NULL; WINPR_ASSERT(smartcard); @@ -376,7 +374,7 @@ static LONG scard_reader_name_valid_w(SmartcardEmulationContext* smartcard, SCAR WINPR_ASSERT(name); WINPR_ASSERT(ctx); - for (x = 0; x < MAX_EMULATED_READERS; x++) + for (size_t x = 0; x < MAX_EMULATED_READERS; x++) { const SCARD_READERSTATEW* reader = &ctx->readerStateW[x]; if (_wcscmp(reader->szReader, name) == 0) @@ -1360,7 +1358,6 @@ LONG WINAPI Emulate_SCardGetStatusChangeA(SmartcardEmulationContext* smartcard, if (status == SCARD_S_SUCCESS) { const DWORD diff = 100; - size_t x = 0; size_t eventCount = 0; SCardContext* value = HashTable_GetItemValue(smartcard->contexts, (const void*)hContext); WINPR_ASSERT(value); /* Must be valid after Emulate_SCardIsValidContext */ @@ -1368,12 +1365,11 @@ LONG WINAPI Emulate_SCardGetStatusChangeA(SmartcardEmulationContext* smartcard, status = SCARD_E_TIMEOUT; do { - for (x = 0; x < cReaders; x++) + for (size_t x = 0; x < cReaders; x++) { - size_t y = 0; LPSCARD_READERSTATEA out = &rgReaderStates[x]; - for (y = 0; y < MAX_EMULATED_READERS; y++) + for (size_t y = 0; y < MAX_EMULATED_READERS; y++) { const LPSCARD_READERSTATEA in = &value->readerStateA[y]; if (strcmp(out->szReader, in->szReader) == 0) @@ -1436,7 +1432,6 @@ LONG WINAPI Emulate_SCardGetStatusChangeW(SmartcardEmulationContext* smartcard, if (status == SCARD_S_SUCCESS) { const DWORD diff = 100; - size_t x = 0; size_t eventCount = 0; SCardContext* value = HashTable_GetItemValue(smartcard->contexts, (const void*)hContext); WINPR_ASSERT(value); /* Must be valid after Emulate_SCardIsValidContext */ @@ -1444,12 +1439,11 @@ LONG WINAPI Emulate_SCardGetStatusChangeW(SmartcardEmulationContext* smartcard, status = SCARD_E_TIMEOUT; do { - for (x = 0; x < cReaders; x++) + for (size_t x = 0; x < cReaders; x++) { - size_t y = 0; LPSCARD_READERSTATEW out = &rgReaderStates[x]; - for (y = 0; y < MAX_EMULATED_READERS; y++) + for (size_t y = 0; y < MAX_EMULATED_READERS; y++) { const LPSCARD_READERSTATEW in = &value->readerStateW[y]; if (_wcscmp(out->szReader, in->szReader) == 0) @@ -1523,12 +1517,11 @@ SCardHandle* find_reader(SmartcardEmulationContext* smartcard, const void* szRea { SCardHandle* hdl = NULL; UINT_PTR* keys = NULL; - size_t x = 0; size_t count = 0; WINPR_ASSERT(smartcard); count = HashTable_GetKeys(smartcard->handles, &keys); - for (x = 0; x < count; x++) + for (size_t x = 0; x < count; x++) { SCardHandle* cur = HashTable_GetItemValue(smartcard->handles, (const void*)keys[x]); WINPR_ASSERT(cur); @@ -1801,12 +1794,11 @@ LONG WINAPI Emulate_SCardState(SmartcardEmulationContext* smartcard, SCARDHANDLE if (pcbAtrLen) { - size_t x = 0; SCardContext* ctx = HashTable_GetItemValue(smartcard->contexts, (const void*)hdl->hContext); WINPR_ASSERT(ctx); - for (x = 0; x < MAX_EMULATED_READERS; x++) + for (size_t x = 0; x < MAX_EMULATED_READERS; x++) { const SCARD_READERSTATEA* readerA = &ctx->readerStateA[x]; const SCARD_READERSTATEW* readerW = &ctx->readerStateW[x]; @@ -1866,9 +1858,7 @@ LONG WINAPI Emulate_SCardStatusA(SmartcardEmulationContext* smartcard, SCARDHAND if (pcbAtrLen) { - size_t x = 0; - - for (x = 0; x < MAX_EMULATED_READERS; x++) + for (size_t x = 0; x < MAX_EMULATED_READERS; x++) { const SCARD_READERSTATEA* reader = &ctx->readerStateA[x]; if (strcmp(reader->szReader, hdl->szReader.pc) == 0) @@ -1917,9 +1907,7 @@ LONG WINAPI Emulate_SCardStatusW(SmartcardEmulationContext* smartcard, SCARDHAND if (pcbAtrLen) { - size_t x = 0; - - for (x = 0; x < MAX_EMULATED_READERS; x++) + for (size_t x = 0; x < MAX_EMULATED_READERS; x++) { const SCARD_READERSTATEW* reader = &ctx->readerStateW[x]; if (_wcscmp(reader->szReader, hdl->szReader.pw) == 0) diff --git a/libfreerdp/emu/scard/smartcard_virtual_gids.c b/libfreerdp/emu/scard/smartcard_virtual_gids.c index 178d56123..3d4dda375 100644 --- a/libfreerdp/emu/scard/smartcard_virtual_gids.c +++ b/libfreerdp/emu/scard/smartcard_virtual_gids.c @@ -425,7 +425,6 @@ static BOOL vgids_prepare_fstable(const vgidsFilesysTableEntry* fstable, DWORD n BYTE unkonwn: 0x01 Array of vgidsFilesysTableEntry */ - DWORD i = 0; BYTE* data = malloc(sizeof(vgidsFilesysTableEntry) * numEntries + 1); if (!data) { @@ -434,7 +433,7 @@ static BOOL vgids_prepare_fstable(const vgidsFilesysTableEntry* fstable, DWORD n } *data = 0x01; - for (i = 0; i < numEntries; ++i) + for (UINT32 i = 0; i < numEntries; ++i) memcpy(data + 1 + (sizeof(vgidsFilesysTableEntry) * i), &fstable[i], sizeof(vgidsFilesysTableEntry)); diff --git a/libfreerdp/gdi/bitmap.c b/libfreerdp/gdi/bitmap.c index 7808a54d2..915eb4023 100644 --- a/libfreerdp/gdi/bitmap.c +++ b/libfreerdp/gdi/bitmap.c @@ -459,8 +459,6 @@ static BOOL BitBlt_process(HGDI_DC hdcDest, INT32 nXDest, INT32 nYDest, INT32 nW HGDI_DC hdcSrc, INT32 nXSrc, INT32 nYSrc, const char* rop, const gdiPalette* palette) { - INT32 x = 0; - INT32 y = 0; UINT32 style = 0; BOOL useSrc = FALSE; BOOL usePat = FALSE; @@ -517,9 +515,9 @@ static BOOL BitBlt_process(HGDI_DC hdcDest, INT32 nXDest, INT32 nYDest, INT32 nW if ((nXDest > nXSrc) && (nYDest > nYSrc)) { - for (y = nHeight - 1; y >= 0; y--) + for (INT32 y = nHeight - 1; y >= 0; y--) { - for (x = nWidth - 1; x >= 0; x--) + for (INT32 x = nWidth - 1; x >= 0; x--) { if (!BitBlt_write(hdcDest, hdcSrc, nXDest, nYDest, nXSrc, nYSrc, x, y, useSrc, usePat, style, rop, palette)) @@ -529,9 +527,9 @@ static BOOL BitBlt_process(HGDI_DC hdcDest, INT32 nXDest, INT32 nYDest, INT32 nW } else if (nXDest > nXSrc) { - for (y = 0; y < nHeight; y++) + for (INT32 y = 0; y < nHeight; y++) { - for (x = nWidth - 1; x >= 0; x--) + for (INT32 x = nWidth - 1; x >= 0; x--) { if (!BitBlt_write(hdcDest, hdcSrc, nXDest, nYDest, nXSrc, nYSrc, x, y, useSrc, usePat, style, rop, palette)) @@ -541,9 +539,9 @@ static BOOL BitBlt_process(HGDI_DC hdcDest, INT32 nXDest, INT32 nYDest, INT32 nW } else if (nYDest > nYSrc) { - for (y = nHeight - 1; y >= 0; y--) + for (INT32 y = nHeight - 1; y >= 0; y--) { - for (x = 0; x < nWidth; x++) + for (INT32 x = 0; x < nWidth; x++) { if (!BitBlt_write(hdcDest, hdcSrc, nXDest, nYDest, nXSrc, nYSrc, x, y, useSrc, usePat, style, rop, palette)) @@ -553,9 +551,9 @@ static BOOL BitBlt_process(HGDI_DC hdcDest, INT32 nXDest, INT32 nYDest, INT32 nW } else { - for (y = 0; y < nHeight; y++) + for (INT32 y = 0; y < nHeight; y++) { - for (x = 0; x < nWidth; x++) + for (INT32 x = 0; x < nWidth; x++) { if (!BitBlt_write(hdcDest, hdcSrc, nXDest, nYDest, nXSrc, nYSrc, x, y, useSrc, usePat, style, rop, palette)) diff --git a/libfreerdp/gdi/gdi.c b/libfreerdp/gdi/gdi.c index 5290c44d6..832ae24e6 100644 --- a/libfreerdp/gdi/gdi.c +++ b/libfreerdp/gdi/gdi.c @@ -377,9 +377,8 @@ const char* gdi_rop3_code_string(BYTE code) const char* gdi_rop3_string(DWORD rop) { const size_t count = sizeof(rop3_code_table) / sizeof(rop3_code_table[0]); - size_t x = 0; - for (x = 0; x < count; x++) + for (size_t x = 0; x < count; x++) { if (rop3_code_table[x].code == rop) return rop3_code_table[x].name; @@ -469,8 +468,6 @@ void gdi_bitmap_free_ex(gdiBitmap* bitmap) BOOL gdi_bitmap_update(rdpContext* context, const BITMAP_UPDATE* bitmapUpdate) { - UINT32 index = 0; - if (!context || !bitmapUpdate || !context->gdi || !context->codecs) { WLog_ERR(TAG, @@ -481,7 +478,7 @@ BOOL gdi_bitmap_update(rdpContext* context, const BITMAP_UPDATE* bitmapUpdate) return FALSE; } - for (index = 0; index < bitmapUpdate->number; index++) + for (UINT32 index = 0; index < bitmapUpdate->number; index++) { const BITMAP_DATA* bitmap = &(bitmapUpdate->rectangles[index]); rdpBitmap* bmp = Bitmap_Alloc(context); @@ -527,7 +524,6 @@ BOOL gdi_bitmap_update(rdpContext* context, const BITMAP_UPDATE* bitmapUpdate) static BOOL gdi_palette_update(rdpContext* context, const PALETTE_UPDATE* palette) { - UINT32 index = 0; rdpGdi* gdi = NULL; if (!context || !palette) @@ -536,7 +532,7 @@ static BOOL gdi_palette_update(rdpContext* context, const PALETTE_UPDATE* palett gdi = context->gdi; gdi->palette.format = gdi->dstFormat; - for (index = 0; index < palette->number; index++) + for (UINT32 index = 0; index < palette->number; index++) { const PALETTE_ENTRY* pe = &(palette->entries[index]); gdi->palette.palette[index] = @@ -725,7 +721,6 @@ static BOOL gdi_opaque_rect(rdpContext* context, const OPAQUE_RECT_ORDER* opaque static BOOL gdi_multi_opaque_rect(rdpContext* context, const MULTI_OPAQUE_RECT_ORDER* multi_opaque_rect) { - UINT32 i = 0; GDI_RECT rect; HGDI_BRUSH hBrush = NULL; UINT32 brush_color = 0; @@ -740,7 +735,7 @@ static BOOL gdi_multi_opaque_rect(rdpContext* context, if (!hBrush) return FALSE; - for (i = 0; i < multi_opaque_rect->numRectangles; i++) + for (UINT32 i = 0; i < multi_opaque_rect->numRectangles; i++) { const DELTA_RECT* rectangle = &multi_opaque_rect->rectangles[i]; INT32 x = rectangle->left; @@ -790,7 +785,6 @@ static BOOL gdi_line_to(rdpContext* context, const LINE_TO_ORDER* lineTo) static BOOL gdi_polyline(rdpContext* context, const POLYLINE_ORDER* polyline) { - UINT32 i = 0; INT32 x = 0; INT32 y = 0; UINT32 color = 0; @@ -814,7 +808,7 @@ static BOOL gdi_polyline(rdpContext* context, const POLYLINE_ORDER* polyline) gdi_MoveToEx(gdi->drawing->hdc, x, y, NULL); points = polyline->points; - for (i = 0; i < polyline->numDeltaEntries; i++) + for (UINT32 i = 0; i < polyline->numDeltaEntries; i++) { x += points[i].x; y += points[i].y; diff --git a/libfreerdp/gdi/gfx.c b/libfreerdp/gdi/gfx.c index ef9046660..9d82ea4a1 100644 --- a/libfreerdp/gdi/gfx.c +++ b/libfreerdp/gdi/gfx.c @@ -85,7 +85,6 @@ static UINT gdi_ResetGraphics(RdpgfxClientContext* context, const RDPGFX_RESET_GRAPHICS_PDU* resetGraphics) { UINT rc = ERROR_INTERNAL_ERROR; - UINT32 index = 0; UINT16 count = 0; UINT32 DesktopWidth = 0; UINT32 DesktopHeight = 0; @@ -123,7 +122,7 @@ static UINT gdi_ResetGraphics(RdpgfxClientContext* context, WINPR_ASSERT(context->GetSurfaceIds); context->GetSurfaceIds(context, &pSurfaceIds, &count); - for (index = 0; index < count; index++) + for (UINT32 index = 0; index < count; index++) { WINPR_ASSERT(context->GetSurfaceData); gdiGfxSurface* surface = @@ -168,7 +167,6 @@ static UINT gdi_OutputUpdate(rdpGdi* gdi, gdiGfxSurface* surface) UINT32 surfaceY = 0; RECTANGLE_16 surfaceRect; const RECTANGLE_16* rects = NULL; - UINT32 i = 0; UINT32 nbRects = 0; double sx = NAN; double sy = NAN; @@ -200,7 +198,7 @@ static UINT gdi_OutputUpdate(rdpGdi* gdi, gdiGfxSurface* surface) if (!update_begin_paint(update)) goto fail; - for (i = 0; i < nbRects; i++) + for (UINT32 i = 0; i < nbRects; i++) { const UINT32 nXSrc = rects[i].left; const UINT32 nYSrc = rects[i].top; @@ -243,7 +241,6 @@ static UINT gdi_WindowUpdate(RdpgfxClientContext* context, gdiGfxSurface* surfac static UINT gdi_UpdateSurfaces(RdpgfxClientContext* context) { UINT16 count = 0; - UINT16 index = 0; UINT status = ERROR_INTERNAL_ERROR; UINT16* pSurfaceIds = NULL; rdpGdi* gdi = NULL; @@ -259,7 +256,7 @@ static UINT gdi_UpdateSurfaces(RdpgfxClientContext* context) context->GetSurfaceIds(context, &pSurfaceIds, &count); status = CHANNEL_RC_OK; - for (index = 0; index < count; index++) + for (UINT32 index = 0; index < count; index++) { WINPR_ASSERT(context->GetSurfaceData); gdiGfxSurface* surface = @@ -405,7 +402,6 @@ static UINT gdi_SurfaceCommand_RemoteFX(rdpGdi* gdi, RdpgfxClientContext* contex REGION16 invalidRegion; const RECTANGLE_16* rects = NULL; UINT32 nrRects = 0; - UINT32 x = 0; WINPR_ASSERT(gdi); WINPR_ASSERT(context); WINPR_ASSERT(cmd); @@ -439,7 +435,7 @@ static UINT gdi_SurfaceCommand_RemoteFX(rdpGdi* gdi, RdpgfxClientContext* contex if (status != CHANNEL_RC_OK) goto fail; - for (x = 0; x < nrRects; x++) + for (UINT32 x = 0; x < nrRects; x++) region16_union_rect(&surface->invalidRegion, &surface->invalidRegion, &rects[x]); if (!gdi->inGfxFrame) @@ -579,7 +575,6 @@ static UINT gdi_SurfaceCommand_AVC420(rdpGdi* gdi, RdpgfxClientContext* context, #ifdef WITH_GFX_H264 INT32 rc = 0; UINT status = CHANNEL_RC_OK; - UINT32 i = 0; gdiGfxSurface* surface = NULL; RDPGFX_H264_METABLOCK* meta = NULL; RDPGFX_AVC420_BITMAP_STREAM* bs = NULL; @@ -630,7 +625,7 @@ static UINT gdi_SurfaceCommand_AVC420(rdpGdi* gdi, RdpgfxClientContext* context, return CHANNEL_RC_OK; } - for (i = 0; i < meta->numRegionRects; i++) + for (UINT32 i = 0; i < meta->numRegionRects; i++) { region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion), (RECTANGLE_16*)&(meta->regionRects[i])); @@ -666,7 +661,6 @@ static UINT gdi_SurfaceCommand_AVC444(rdpGdi* gdi, RdpgfxClientContext* context, #ifdef WITH_GFX_H264 INT32 rc = 0; UINT status = CHANNEL_RC_OK; - UINT32 i = 0; gdiGfxSurface* surface = NULL; RDPGFX_AVC444_BITMAP_STREAM* bs = NULL; RDPGFX_AVC420_BITMAP_STREAM* avc1 = NULL; @@ -724,7 +718,7 @@ static UINT gdi_SurfaceCommand_AVC444(rdpGdi* gdi, RdpgfxClientContext* context, return CHANNEL_RC_OK; } - for (i = 0; i < meta1->numRegionRects; i++) + for (UINT32 i = 0; i < meta1->numRegionRects; i++) { region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion), &(meta1->regionRects[i])); @@ -736,7 +730,7 @@ static UINT gdi_SurfaceCommand_AVC444(rdpGdi* gdi, RdpgfxClientContext* context, if (status != CHANNEL_RC_OK) goto fail; - for (i = 0; i < meta2->numRegionRects; i++) + for (UINT32 i = 0; i < meta2->numRegionRects; i++) { region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion), &(meta2->regionRects[i])); @@ -948,7 +942,6 @@ static UINT gdi_SurfaceCommand_Progressive(rdpGdi* gdi, RdpgfxClientContext* con REGION16 invalidRegion; const RECTANGLE_16* rects = NULL; UINT32 nrRects = 0; - UINT32 x = 0; /** * Note: Since this comes via a Wire-To-Surface-2 PDU the * cmd's top/left/right/bottom/width/height members are always zero! @@ -1001,7 +994,7 @@ static UINT gdi_SurfaceCommand_Progressive(rdpGdi* gdi, RdpgfxClientContext* con if (status != CHANNEL_RC_OK) goto fail; - for (x = 0; x < nrRects; x++) + for (UINT32 x = 0; x < nrRects; x++) region16_union_rect(&surface->invalidRegion, &surface->invalidRegion, &rects[x]); region16_uninit(&invalidRegion); @@ -1325,7 +1318,6 @@ static UINT gdi_SurfaceToSurface(RdpgfxClientContext* context, const RDPGFX_SURFACE_TO_SURFACE_PDU* surfaceToSurface) { UINT status = ERROR_INTERNAL_ERROR; - UINT16 index = 0; BOOL sameSurface = 0; UINT32 nWidth = 0; UINT32 nHeight = 0; @@ -1357,7 +1349,7 @@ static UINT gdi_SurfaceToSurface(RdpgfxClientContext* context, nWidth = rectSrc->right - rectSrc->left; nHeight = rectSrc->bottom - rectSrc->top; - for (index = 0; index < surfaceToSurface->destPtsCount; index++) + for (UINT16 index = 0; index < surfaceToSurface->destPtsCount; index++) { const RDPGFX_POINT16* destPt = &surfaceToSurface->destPts[index]; const RECTANGLE_16 rect = { destPt->x, destPt->y, @@ -1489,7 +1481,6 @@ static UINT gdi_CacheToSurface(RdpgfxClientContext* context, const RDPGFX_CACHE_TO_SURFACE_PDU* cacheToSurface) { UINT status = ERROR_INTERNAL_ERROR; - UINT16 index = 0; gdiGfxSurface* surface = NULL; gdiGfxCacheEntry* cacheEntry = NULL; RECTANGLE_16 invalidRect; @@ -1506,7 +1497,7 @@ static UINT gdi_CacheToSurface(RdpgfxClientContext* context, if (!surface || !cacheEntry) goto fail; - for (index = 0; index < cacheToSurface->destPtsCount; index++) + for (UINT16 index = 0; index < cacheToSurface->destPtsCount; index++) { const RDPGFX_POINT16* destPt = &cacheToSurface->destPts[index]; const RECTANGLE_16 rect = { destPt->x, destPt->y, @@ -1556,7 +1547,6 @@ fail: static UINT gdi_CacheImportReply(RdpgfxClientContext* context, const RDPGFX_CACHE_IMPORT_REPLY_PDU* cacheImportReply) { - UINT16 index = 0; UINT16 count = 0; const UINT16* slots = NULL; UINT error = CHANNEL_RC_OK; @@ -1564,7 +1554,7 @@ static UINT gdi_CacheImportReply(RdpgfxClientContext* context, slots = cacheImportReply->cacheSlots; count = cacheImportReply->importedEntriesCount; - for (index = 0; index < count; index++) + for (UINT16 index = 0; index < count; index++) { UINT16 cacheSlot = slots[index]; diff --git a/libfreerdp/gdi/shape.c b/libfreerdp/gdi/shape.c index b2a4fff00..fdc05f120 100644 --- a/libfreerdp/gdi/shape.c +++ b/libfreerdp/gdi/shape.c @@ -130,8 +130,6 @@ BOOL gdi_Ellipse(HGDI_DC hdc, int nLeftRect, int nTopRect, int nRightRect, int n BOOL gdi_FillRect(HGDI_DC hdc, const HGDI_RECT rect, HGDI_BRUSH hbr) { - INT32 x = 0; - INT32 y = 0; UINT32 color = 0; UINT32 dstColor = 0; BOOL monochrome = FALSE; @@ -154,7 +152,7 @@ BOOL gdi_FillRect(HGDI_DC hdc, const HGDI_RECT rect, HGDI_BRUSH hbr) case GDI_BS_SOLID: color = hbr->color; - for (x = 0; x < nWidth; x++) + for (INT32 x = 0; x < nWidth; x++) { BYTE* dstp = gdi_get_bitmap_pointer(hdc, nXDest + x, nYDest); @@ -165,7 +163,7 @@ BOOL gdi_FillRect(HGDI_DC hdc, const HGDI_RECT rect, HGDI_BRUSH hbr) srcp = gdi_get_bitmap_pointer(hdc, nXDest, nYDest); formatSize = FreeRDPGetBytesPerPixel(hdc->format); - for (y = 1; y < nHeight; y++) + for (INT32 y = 1; y < nHeight; y++) { BYTE* dstp = gdi_get_bitmap_pointer(hdc, nXDest, nYDest + y); memcpy(dstp, srcp, 1ull * nWidth * formatSize); @@ -178,9 +176,9 @@ BOOL gdi_FillRect(HGDI_DC hdc, const HGDI_RECT rect, HGDI_BRUSH hbr) monochrome = (hbr->pattern->format == PIXEL_FORMAT_MONO); formatSize = FreeRDPGetBytesPerPixel(hbr->pattern->format); - for (y = 0; y < nHeight; y++) + for (INT32 y = 0; y < nHeight; y++) { - for (x = 0; x < nWidth; x++) + for (INT32 x = 0; x < nWidth; x++) { const UINT32 yOffset = ((nYDest + y) * hbr->pattern->width % hbr->pattern->height) * formatSize; @@ -253,8 +251,6 @@ BOOL gdi_PolyPolygon(HGDI_DC hdc, GDI_POINT* lpPoints, int* lpPolyCounts, int nC BOOL gdi_Rectangle(HGDI_DC hdc, INT32 nXDst, INT32 nYDst, INT32 nWidth, INT32 nHeight) { - INT32 x = 0; - INT32 y = 0; UINT32 color = 0; if (!gdi_ClipCoords(hdc, &nXDst, &nYDst, &nWidth, &nHeight, NULL, NULL)) @@ -262,7 +258,7 @@ BOOL gdi_Rectangle(HGDI_DC hdc, INT32 nXDst, INT32 nYDst, INT32 nWidth, INT32 nH color = hdc->textColor; - for (y = 0; y < nHeight; y++) + for (INT32 y = 0; y < nHeight; y++) { BYTE* dstLeft = gdi_get_bitmap_pointer(hdc, nXDst, nYDst + y); BYTE* dstRight = gdi_get_bitmap_pointer(hdc, nXDst + nWidth - 1, nYDst + y); @@ -274,7 +270,7 @@ BOOL gdi_Rectangle(HGDI_DC hdc, INT32 nXDst, INT32 nYDst, INT32 nWidth, INT32 nH FreeRDPWriteColor(dstRight, hdc->format, color); } - for (x = 0; x < nWidth; x++) + for (INT32 x = 0; x < nWidth; x++) { BYTE* dstTop = gdi_get_bitmap_pointer(hdc, nXDst + x, nYDst); BYTE* dstBottom = gdi_get_bitmap_pointer(hdc, nXDst + x, nYDst + nHeight - 1); diff --git a/libfreerdp/gdi/test/TestGdiBitBlt.c b/libfreerdp/gdi/test/TestGdiBitBlt.c index 78cfef50c..063d0308a 100644 --- a/libfreerdp/gdi/test/TestGdiBitBlt.c +++ b/libfreerdp/gdi/test/TestGdiBitBlt.c @@ -409,7 +409,6 @@ static BOOL test_gdi_BitBlt(UINT32 SrcFormat, UINT32 DstFormat) { BOOL rc = FALSE; BOOL failed = FALSE; - UINT32 x = 0; HGDI_DC hdcSrc = NULL; HGDI_DC hdcDst = NULL; const UINT32 RawFormat = PIXEL_FORMAT_RGB8; @@ -463,7 +462,7 @@ static BOOL test_gdi_BitBlt(UINT32 SrcFormat, UINT32 DstFormat) gdiPalette* hPalette = &g; g.format = DstFormat; - for (x = 0; x < 256; x++) + for (UINT32 x = 0; x < 256; x++) g.palette[x] = FreeRDPGetColor(DstFormat, x, x, x, 0xFF); if (!(hdcSrc = gdi_GetDC())) @@ -499,7 +498,7 @@ static BOOL test_gdi_BitBlt(UINT32 SrcFormat, UINT32 DstFormat) if (!hBmpDstOriginal) goto fail; - for (x = 0; x < number_tests; x++) + for (UINT32 x = 0; x < number_tests; x++) { tests[x].bmp = test_convert_to_bitmap(tests[x].src, RawFormat, 0, 0, 0, SrcFormat, 0, 0, 0, 16, 16, hPalette); @@ -511,7 +510,7 @@ static BOOL test_gdi_BitBlt(UINT32 SrcFormat, UINT32 DstFormat) brush = gdi_CreateSolidBrush(0x123456); gdi_SelectObject(hdcDst, (HGDIOBJECT)brush); - for (x = 0; x < number_tests; x++) + for (UINT32 x = 0; x < number_tests; x++) { if (!test_rop(hdcDst, hdcSrc, hBmpSrc, hBmpDst, hBmpDstOriginal, tests[x].rop, tests[x].bmp, hPalette)) @@ -523,7 +522,7 @@ static BOOL test_gdi_BitBlt(UINT32 SrcFormat, UINT32 DstFormat) rc = !failed; fail: - for (x = 0; x < number_tests; x++) + for (UINT32 x = 0; x < number_tests; x++) gdi_DeleteObject((HGDIOBJECT)tests[x].bmp); gdi_DeleteObject((HGDIOBJECT)hBmpSrc); diff --git a/libfreerdp/gdi/test/TestGdiCreate.c b/libfreerdp/gdi/test/TestGdiCreate.c index b979fc11a..c71b396a6 100644 --- a/libfreerdp/gdi/test/TestGdiCreate.c +++ b/libfreerdp/gdi/test/TestGdiCreate.c @@ -327,12 +327,9 @@ fail: static BOOL test_gdi_GetPixel(void) { BOOL rc = TRUE; - UINT32 x = 0; - for (x = 0; x < colorFormatCount; x++) + for (UINT32 x = 0; x < colorFormatCount; x++) { - UINT32 i = 0; - UINT32 j = 0; UINT32 bpp = 0; HGDI_DC hdc = NULL; UINT32 width = 128; @@ -357,9 +354,9 @@ static BOOL test_gdi_GetPixel(void) gdi_SelectObject(hdc, (HGDIOBJECT)hBitmap); bpp = FreeRDPGetBytesPerPixel(hBitmap->format); - for (i = 0; i < height; i++) + for (UINT32 i = 0; i < height; i++) { - for (j = 0; j < width; j++) + for (UINT32 j = 0; j < width; j++) { UINT32 pixel = 0; const UINT32 color = @@ -389,12 +386,9 @@ static BOOL test_gdi_GetPixel(void) static BOOL test_gdi_SetPixel(void) { BOOL rc = TRUE; - UINT32 x = 0; - for (x = 0; x < colorFormatCount; x++) + for (UINT32 x = 0; x < colorFormatCount; x++) { - UINT32 i = 0; - UINT32 j = 0; UINT32 bpp = 0; HGDI_DC hdc = NULL; UINT32 width = 128; @@ -412,9 +406,9 @@ static BOOL test_gdi_SetPixel(void) gdi_SelectObject(hdc, (HGDIOBJECT)hBitmap); bpp = FreeRDPGetBytesPerPixel(hBitmap->format); - for (i = 0; i < height; i++) + for (UINT32 i = 0; i < height; i++) { - for (j = 0; j < width; j++) + for (UINT32 j = 0; j < width; j++) { UINT32 pixel = 0; const UINT32 color = diff --git a/libfreerdp/gdi/test/TestGdiEllipse.c b/libfreerdp/gdi/test/TestGdiEllipse.c index 7548cc9f0..ca9e629d0 100644 --- a/libfreerdp/gdi/test/TestGdiEllipse.c +++ b/libfreerdp/gdi/test/TestGdiEllipse.c @@ -77,8 +77,6 @@ static const BYTE ellipse_case_3[256] = { int TestGdiEllipse(int argc, char* argv[]) { int rc = -1; - UINT32 i = 0; - UINT32 j = 0; const UINT32 RawFormat = PIXEL_FORMAT_RGB8; const UINT32 colorFormats[] = { PIXEL_FORMAT_RGB15, PIXEL_FORMAT_ARGB15, PIXEL_FORMAT_RGB16, PIXEL_FORMAT_RGB24, PIXEL_FORMAT_ARGB32, PIXEL_FORMAT_XRGB32, @@ -91,7 +89,7 @@ int TestGdiEllipse(int argc, char* argv[]) WINPR_UNUSED(argc); WINPR_UNUSED(argv); - for (i = 0; i < number_formats; i++) + for (UINT32 i = 0; i < number_formats; i++) { HGDI_DC hdc = NULL; HGDI_PEN pen = NULL; @@ -103,7 +101,7 @@ int TestGdiEllipse(int argc, char* argv[]) gdiPalette* hPalette = &g; g.format = format; - for (j = 0; j < 256; j++) + for (UINT32 j = 0; j < 256; j++) g.palette[i] = FreeRDPGetColor(format, j, j, j, 0xFF); rc = -1; diff --git a/libfreerdp/gdi/test/TestGdiLine.c b/libfreerdp/gdi/test/TestGdiLine.c index ae2152826..f014f375a 100644 --- a/libfreerdp/gdi/test/TestGdiLine.c +++ b/libfreerdp/gdi/test/TestGdiLine.c @@ -1,4 +1,3 @@ - #include #include @@ -565,9 +564,7 @@ static BOOL test_line(HGDI_DC hdc, const gdiPalette* hPalette, UINT32 mX, UINT32 int TestGdiLine(int argc, char* argv[]) { int rc = -1; - UINT32 x = 0; - UINT32 i = 0; - gdiPalette g; + const UINT32 RawFormat = PIXEL_FORMAT_RGB8; const UINT32 colorFormats[] = { PIXEL_FORMAT_RGB15, PIXEL_FORMAT_ARGB15, PIXEL_FORMAT_RGB16, PIXEL_FORMAT_RGB24, PIXEL_FORMAT_ARGB32, PIXEL_FORMAT_XRGB32, @@ -575,12 +572,13 @@ int TestGdiLine(int argc, char* argv[]) PIXEL_FORMAT_ABGR15, PIXEL_FORMAT_BGR16, PIXEL_FORMAT_BGR24, PIXEL_FORMAT_ABGR32, PIXEL_FORMAT_XBGR32, PIXEL_FORMAT_BGRA32, PIXEL_FORMAT_BGRX32 }; - const UINT32 number_formats = sizeof(colorFormats) / sizeof(colorFormats[0]); + const size_t number_formats = sizeof(colorFormats) / sizeof(colorFormats[0]); WINPR_UNUSED(argc); WINPR_UNUSED(argv); - for (i = 0; i < number_formats; i++) + for (size_t ifmt = 0; ifmt < number_formats; ifmt++) { + gdiPalette g = { 0 }; HGDI_DC hdc = NULL; HGDI_PEN pen = NULL; HGDI_BITMAP hBmp = NULL; @@ -600,15 +598,15 @@ int TestGdiLine(int argc, char* argv[]) { GDI_R2_MERGEPENNOT, NULL, line_to_R2_MERGEPENNOT }, { GDI_R2_MERGEPEN, NULL, line_to_R2_MERGEPEN }, { GDI_R2_WHITE, NULL, line_to_R2_WHITE } }; - const UINT32 map_size = sizeof(rop_map) / sizeof(rop_map[0]); + const size_t map_size = sizeof(rop_map) / sizeof(rop_map[0]); HGDI_BITMAP hBmp_LineTo[LINTETO_NUMBER] = { NULL }; gdiPalette* hPalette = &g; UINT32 penColor = 0; - const UINT32 format = colorFormats[i]; + const UINT32 format = colorFormats[ifmt]; g.format = format; - for (i = 0; i < 256; i++) - g.palette[i] = FreeRDPGetColor(format, i, i, i, 0xFF); + for (unsigned x = 0; x < 256; x++) + g.palette[x] = FreeRDPGetColor(format, x, x, x, 0xFF); rc = -1; @@ -632,7 +630,7 @@ int TestGdiLine(int argc, char* argv[]) hBmp = gdi_CreateCompatibleBitmap(hdc, 16, 16); gdi_SelectObject(hdc, (HGDIOBJECT)hBmp); - for (x = 0; x < LINTETO_NUMBER; x++) + for (UINT32 x = 0; x < LINTETO_NUMBER; x++) { hBmp_LineTo[x] = test_convert_to_bitmap(line_to_case[x], RawFormat, 0, 0, 0, format, 0, 0, 0, 16, 16, hPalette); @@ -641,7 +639,7 @@ int TestGdiLine(int argc, char* argv[]) goto fail; } - for (x = 0; x < map_size; x++) + for (UINT32 x = 0; x < map_size; x++) { rop_map[x].bmp = test_convert_to_bitmap(rop_map[x].src, RawFormat, 0, 0, 0, format, 0, 0, 0, 16, 16, hPalette); @@ -683,9 +681,9 @@ int TestGdiLine(int argc, char* argv[]) if (!test_line(hdc, hPalette, 0, 0, 26, 26, hBmp, hBmp_LineTo[10], 0, 0, 16, 16)) goto fail; - for (x = 0; x < map_size; x++) + for (UINT32 x = 0; x < map_size; x++) { - char name[1024]; + char name[1024] = { 0 }; _snprintf(name, sizeof(name), "%s [%s]", gdi_rop_to_string(rop_map[x].rop), FreeRDPGetColorFormatName(hdc->format)); @@ -708,10 +706,10 @@ int TestGdiLine(int argc, char* argv[]) rc = 0; fail: - for (x = 0; x < LINTETO_NUMBER; x++) + for (UINT32 x = 0; x < LINTETO_NUMBER; x++) gdi_DeleteObject((HGDIOBJECT)hBmp_LineTo[x]); - for (x = 0; x < map_size; x++) + for (UINT32 x = 0; x < map_size; x++) gdi_DeleteObject((HGDIOBJECT)rop_map[x].bmp); gdi_DeleteObject((HGDIOBJECT)hBmp); diff --git a/libfreerdp/gdi/test/TestGdiRect.c b/libfreerdp/gdi/test/TestGdiRect.c index be9960b88..87cf577b0 100644 --- a/libfreerdp/gdi/test/TestGdiRect.c +++ b/libfreerdp/gdi/test/TestGdiRect.c @@ -72,8 +72,6 @@ static int test_gdi_FillRect(void) UINT32 color = 0; UINT32 pixel = 0; UINT32 rawPixel = 0; - UINT32 x = 0; - UINT32 y = 0; UINT32 badPixels = 0; UINT32 goodPixels = 0; UINT32 width = 200; @@ -106,9 +104,9 @@ static int test_gdi_FillRect(void) badPixels = 0; goodPixels = 0; - for (x = 0; x < width; x++) + for (UINT32 x = 0; x < width; x++) { - for (y = 0; y < height; y++) + for (UINT32 y = 0; y < height; y++) { rawPixel = gdi_GetPixel(hdc, x, y); pixel = FreeRDPConvertColor(rawPixel, hdc->format, PIXEL_FORMAT_ARGB32, NULL); diff --git a/libfreerdp/gdi/test/TestGdiRop3.c b/libfreerdp/gdi/test/TestGdiRop3.c index 47b9ab6b5..27566330b 100644 --- a/libfreerdp/gdi/test/TestGdiRop3.c +++ b/libfreerdp/gdi/test/TestGdiRop3.c @@ -96,7 +96,6 @@ static char* gdi_convert_postfix_to_infix(const char* postfix) { - size_t i = 0; size_t length = 0; BOOL unary = 0; wStack* stack = NULL; @@ -112,7 +111,7 @@ static char* gdi_convert_postfix_to_infix(const char* postfix) stack = Stack_New(FALSE); length = strlen(postfix); - for (i = 0; i < length; i++) + for (size_t i = 0; i < length; i++) { if ((postfix[i] == 'P') || (postfix[i] == 'D') || (postfix[i] == 'S')) { @@ -190,11 +189,10 @@ static const char* test_ROP3[] = { "DSPDxax", "PSDPxax", "SPna", "DSna", "D int TestGdiRop3(int argc, char* argv[]) { - size_t index = 0; WINPR_UNUSED(argc); WINPR_UNUSED(argv); - for (index = 0; index < sizeof(test_ROP3) / sizeof(test_ROP3[0]); index++) + for (size_t index = 0; index < sizeof(test_ROP3) / sizeof(test_ROP3[0]); index++) { const char* postfix = test_ROP3[index]; char* infix = gdi_convert_postfix_to_infix(postfix); diff --git a/libfreerdp/gdi/test/helpers.c b/libfreerdp/gdi/test/helpers.c index c834ff14c..6d7ae87b8 100644 --- a/libfreerdp/gdi/test/helpers.c +++ b/libfreerdp/gdi/test/helpers.c @@ -56,7 +56,6 @@ HGDI_BITMAP test_convert_to_bitmap(const BYTE* src, UINT32 SrcFormat, UINT32 Src static void test_dump_data(unsigned char* p, int len, int width, const char* name) { unsigned char* line = p; - int i = 0; int thisline = 0; int offset = 0; return; // TODO: Activate this manually if required. Improves test speed @@ -64,13 +63,14 @@ static void test_dump_data(unsigned char* p, int len, int width, const char* nam while (offset < len) { + int i = 0; printf("%04x ", offset); thisline = len - offset; if (thisline > width) thisline = width; - for (i = 0; i < thisline; i++) + for (; i < thisline; i++) printf("%02x ", line[i]); for (; i < width; i++) @@ -93,21 +93,17 @@ void test_dump_bitmap(HGDI_BITMAP hBmp, const char* name) static BOOL CompareBitmaps(HGDI_BITMAP hBmp1, HGDI_BITMAP hBmp2, const gdiPalette* palette) { - UINT32 x = 0; - UINT32 y = 0; const BYTE* p1 = hBmp1->data; const BYTE* p2 = hBmp2->data; - UINT32 colorA = 0; - UINT32 colorB = 0; - UINT32 minw = (hBmp1->width < hBmp2->width) ? hBmp1->width : hBmp2->width; - UINT32 minh = (hBmp1->height < hBmp2->height) ? hBmp1->height : hBmp2->height; + const UINT32 minw = (hBmp1->width < hBmp2->width) ? hBmp1->width : hBmp2->width; + const UINT32 minh = (hBmp1->height < hBmp2->height) ? hBmp1->height : hBmp2->height; - for (y = 0; y < minh; y++) + for (UINT32 y = 0; y < minh; y++) { - for (x = 0; x < minw; x++) + for (UINT32 x = 0; x < minw; x++) { - colorA = FreeRDPReadColor(p1, hBmp1->format); - colorB = FreeRDPReadColor(p2, hBmp2->format); + UINT32 colorA = FreeRDPReadColor(p1, hBmp1->format); + UINT32 colorB = FreeRDPReadColor(p2, hBmp2->format); p1 += FreeRDPGetBytesPerPixel(hBmp1->format); p2 += FreeRDPGetBytesPerPixel(hBmp2->format); diff --git a/libfreerdp/locale/keyboard.c b/libfreerdp/locale/keyboard.c index 3ca340965..4c4dd1990 100644 --- a/libfreerdp/locale/keyboard.c +++ b/libfreerdp/locale/keyboard.c @@ -290,7 +290,6 @@ static int freerdp_keyboard_init_x11_evdev(DWORD* keyboardLayoutId, DWORD freerdp_keyboard_init(DWORD keyboardLayoutId) { - DWORD keycode = 0; int status = -1; #if defined(__APPLE__) @@ -324,7 +323,7 @@ DWORD freerdp_keyboard_init(DWORD keyboardLayoutId) ZeroMemory(VIRTUAL_SCANCODE_TO_X11_KEYCODE, sizeof(VIRTUAL_SCANCODE_TO_X11_KEYCODE)); - for (keycode = 0; keycode < ARRAYSIZE(VIRTUAL_SCANCODE_TO_X11_KEYCODE); keycode++) + for (size_t keycode = 0; keycode < ARRAYSIZE(VIRTUAL_SCANCODE_TO_X11_KEYCODE); keycode++) { const DWORD x11 = X11_KEYCODE_TO_VIRTUAL_SCANCODE[keycode]; const DWORD sc = RDP_SCANCODE_CODE(x11); @@ -412,9 +411,7 @@ DWORD freerdp_keyboard_get_x11_keycode_from_rdp_scancode(DWORD scancode, BOOL ex const char* freerdp_keyboard_scancode_name(DWORD scancode) { - size_t x = 0; - - for (x = 0; x < ARRAYSIZE(RDP_SCANCODE_MAP); x++) + for (size_t x = 0; x < ARRAYSIZE(RDP_SCANCODE_MAP); x++) { const struct scancode_map_entry* entry = &RDP_SCANCODE_MAP[x]; if (entry->scancode == scancode) diff --git a/libfreerdp/locale/keyboard_apple.c b/libfreerdp/locale/keyboard_apple.c index a578d08ac..b9a385fe9 100644 --- a/libfreerdp/locale/keyboard_apple.c +++ b/libfreerdp/locale/keyboard_apple.c @@ -187,7 +187,6 @@ static const KEYBOARD_LAYOUT_MAPPING KEYBOARD_MAPPING_TABLE[] = { int freerdp_detect_keyboard_layout_from_cf(DWORD* keyboardLayoutId) { - int i; CFIndex length; char* inputSourceId = NULL; CFStringRef inputSourceIdRef; @@ -223,7 +222,7 @@ int freerdp_detect_keyboard_layout_from_cf(DWORD* keyboardLayoutId) } /* Search for the id in the mapping table */ - for (i = 0; i < ARRAYSIZE(KEYBOARD_MAPPING_TABLE); ++i) + for (size_t i = 0; i < ARRAYSIZE(KEYBOARD_MAPPING_TABLE); ++i) { if (strcmp(inputSourceId, KEYBOARD_MAPPING_TABLE[i].inputSourceId) == 0) { diff --git a/libfreerdp/locale/keyboard_layout.c b/libfreerdp/locale/keyboard_layout.c index e6a456e8d..d94de5558 100644 --- a/libfreerdp/locale/keyboard_layout.c +++ b/libfreerdp/locale/keyboard_layout.c @@ -799,12 +799,10 @@ static const RDP_KEYBOARD_IME RDP_KEYBOARD_IME_TABLE[] = { void freerdp_keyboard_layouts_free(RDP_KEYBOARD_LAYOUT* layouts, size_t count) { - size_t x = 0; - if (!layouts) return; - for (x = 0; x < count; x++) + for (size_t x = 0; x < count; x++) { RDP_KEYBOARD_LAYOUT* current = &layouts[x]; free(current->name); @@ -817,7 +815,6 @@ void freerdp_keyboard_layouts_free(RDP_KEYBOARD_LAYOUT* layouts, size_t count) RDP_KEYBOARD_LAYOUT* freerdp_keyboard_get_layouts(DWORD types, size_t* count) { size_t num = 0; - size_t i = 0; RDP_KEYBOARD_LAYOUT* layouts = NULL; num = 0; @@ -836,7 +833,7 @@ RDP_KEYBOARD_LAYOUT* freerdp_keyboard_get_layouts(DWORD types, size_t* count) layouts = new; - for (i = 0; i < length; i++, num++) + for (size_t i = 0; i < length; i++, num++) { layouts[num].code = RDP_KEYBOARD_LAYOUT_TABLE[i].code; layouts[num].name = _strdup(RDP_KEYBOARD_LAYOUT_TABLE[i].name); @@ -857,7 +854,7 @@ RDP_KEYBOARD_LAYOUT* freerdp_keyboard_get_layouts(DWORD types, size_t* count) layouts = new; - for (i = 0; i < length; i++, num++) + for (size_t i = 0; i < length; i++, num++) { layouts[num].code = RDP_KEYBOARD_LAYOUT_VARIANT_TABLE[i].code; layouts[num].name = _strdup(RDP_KEYBOARD_LAYOUT_VARIANT_TABLE[i].name); @@ -878,7 +875,7 @@ RDP_KEYBOARD_LAYOUT* freerdp_keyboard_get_layouts(DWORD types, size_t* count) layouts = new; - for (i = 0; i < length; i++, num++) + for (size_t i = 0; i < length; i++, num++) { layouts[num].code = RDP_KEYBOARD_IME_TABLE[i].code; layouts[num].name = _strdup(RDP_KEYBOARD_IME_TABLE[i].name); @@ -897,21 +894,19 @@ fail: const char* freerdp_keyboard_get_layout_name_from_id(DWORD keyboardLayoutID) { - size_t i = 0; - - for (i = 0; i < ARRAYSIZE(RDP_KEYBOARD_LAYOUT_TABLE); i++) + for (size_t i = 0; i < ARRAYSIZE(RDP_KEYBOARD_LAYOUT_TABLE); i++) { if (RDP_KEYBOARD_LAYOUT_TABLE[i].code == keyboardLayoutID) return RDP_KEYBOARD_LAYOUT_TABLE[i].name; } - for (i = 0; i < ARRAYSIZE(RDP_KEYBOARD_LAYOUT_VARIANT_TABLE); i++) + for (size_t i = 0; i < ARRAYSIZE(RDP_KEYBOARD_LAYOUT_VARIANT_TABLE); i++) { if (RDP_KEYBOARD_LAYOUT_VARIANT_TABLE[i].code == keyboardLayoutID) return RDP_KEYBOARD_LAYOUT_VARIANT_TABLE[i].name; } - for (i = 0; i < ARRAYSIZE(RDP_KEYBOARD_IME_TABLE); i++) + for (size_t i = 0; i < ARRAYSIZE(RDP_KEYBOARD_IME_TABLE); i++) { if (RDP_KEYBOARD_IME_TABLE[i].code == keyboardLayoutID) return RDP_KEYBOARD_IME_TABLE[i].name; @@ -922,21 +917,19 @@ const char* freerdp_keyboard_get_layout_name_from_id(DWORD keyboardLayoutID) DWORD freerdp_keyboard_get_layout_id_from_name(const char* name) { - size_t i = 0; - - for (i = 0; i < ARRAYSIZE(RDP_KEYBOARD_LAYOUT_TABLE); i++) + for (size_t i = 0; i < ARRAYSIZE(RDP_KEYBOARD_LAYOUT_TABLE); i++) { if (strcmp(RDP_KEYBOARD_LAYOUT_TABLE[i].name, name) == 0) return RDP_KEYBOARD_LAYOUT_TABLE[i].code; } - for (i = 0; i < ARRAYSIZE(RDP_KEYBOARD_LAYOUT_VARIANT_TABLE); i++) + for (size_t i = 0; i < ARRAYSIZE(RDP_KEYBOARD_LAYOUT_VARIANT_TABLE); i++) { if (strcmp(RDP_KEYBOARD_LAYOUT_VARIANT_TABLE[i].name, name) == 0) return RDP_KEYBOARD_LAYOUT_VARIANT_TABLE[i].code; } - for (i = 0; i < ARRAYSIZE(RDP_KEYBOARD_IME_TABLE); i++) + for (size_t i = 0; i < ARRAYSIZE(RDP_KEYBOARD_IME_TABLE); i++) { if (strcmp(RDP_KEYBOARD_IME_TABLE[i].name, name) == 0) return RDP_KEYBOARD_IME_TABLE[i].code; @@ -1000,7 +993,6 @@ static BOOL copyOnMatch(DWORD column, const char* filter, const struct LanguageI RDP_CODEPAGE* freerdp_keyboard_get_matching_codepages(DWORD column, const char* filter, size_t* count) { - size_t x = 0; size_t cnt = 0; const size_t c = ARRAYSIZE(language_identifiers); RDP_CODEPAGE* pages = calloc(ARRAYSIZE(language_identifiers), sizeof(RDP_CODEPAGE)); @@ -1014,7 +1006,7 @@ RDP_CODEPAGE* freerdp_keyboard_get_matching_codepages(DWORD column, const char* if (column > 4) goto fail; - for (x = 0; x < c; x++) + for (size_t x = 0; x < c; x++) { const struct LanguageIdentifier* cur = &language_identifiers[x]; if (copyOnMatch(column, filter, cur, &pages[cnt])) diff --git a/libfreerdp/locale/keyboard_sun.c b/libfreerdp/locale/keyboard_sun.c index 830a5d558..094ed5b6a 100644 --- a/libfreerdp/locale/keyboard_sun.c +++ b/libfreerdp/locale/keyboard_sun.c @@ -265,14 +265,13 @@ fail: DWORD freerdp_detect_solaris_keyboard_layout() { - int i; int type; int layout; if (freerdp_get_solaris_keyboard_layout_and_type(&type, &layout) < 0) return 0; - for (i = 0; i < ARRAYSIZE(SOLARIS_KEYBOARD_TABLE); i++) + for (size_t i = 0; i < ARRAYSIZE(SOLARIS_KEYBOARD_TABLE); i++) { if (SOLARIS_KEYBOARD_TABLE[i].type == type) { diff --git a/libfreerdp/locale/keyboard_x11.c b/libfreerdp/locale/keyboard_x11.c index 7469eb529..3f3f574a5 100644 --- a/libfreerdp/locale/keyboard_x11.c +++ b/libfreerdp/locale/keyboard_x11.c @@ -31,8 +31,6 @@ static BOOL parse_xkb_rule_names(char* xkb_rule, unsigned long num_bytes, char** layout, char** variant) { - size_t i = 0; - size_t index = 0; /* Sample output for "Canadian Multilingual Standard" * * _XKB_RULES_NAMES_BACKUP(STRING) = "xorg", "pc105", "ca", "multi", "magic" @@ -48,7 +46,7 @@ static BOOL parse_xkb_rule_names(char* xkb_rule, unsigned long num_bytes, char** * “eurosign:e,lv3:ralt_switch,grp:rctrl_toggle” * - three options) */ - for (i = 0, index = 0; i < num_bytes; i++, index++) + for (size_t i = 0, index = 0; i < num_bytes; i++, index++) { char* ptr = xkb_rule + i; diff --git a/libfreerdp/locale/locale.c b/libfreerdp/locale/locale.c index 597a6292e..a97594dc6 100644 --- a/libfreerdp/locale/locale.c +++ b/libfreerdp/locale/locale.c @@ -746,7 +746,6 @@ static BOOL freerdp_get_system_language_and_country_codes(char* language, size_t static const SYSTEM_LOCALE* freerdp_detect_system_locale(void) { - size_t i = 0; char language[LOCALE_LANGUAGE_LEN] = { 0 }; char country[LOCALE_COUNTRY_LEN] = { 0 }; const SYSTEM_LOCALE* locale = NULL; @@ -754,7 +753,7 @@ static const SYSTEM_LOCALE* freerdp_detect_system_locale(void) freerdp_get_system_language_and_country_codes(language, ARRAYSIZE(language), country, ARRAYSIZE(country)); - for (i = 0; i < ARRAYSIZE(SYSTEM_LOCALE_TABLE); i++) + for (size_t i = 0; i < ARRAYSIZE(SYSTEM_LOCALE_TABLE); i++) { const SYSTEM_LOCALE* current = &SYSTEM_LOCALE_TABLE[i]; @@ -781,9 +780,7 @@ DWORD freerdp_get_system_locale_id(void) const char* freerdp_get_system_locale_name_from_id(DWORD localeId) { - size_t index = 0; - - for (index = 0; index < ARRAYSIZE(LOCALE_NAME_TABLE); index++) + for (size_t index = 0; index < ARRAYSIZE(LOCALE_NAME_TABLE); index++) { const LOCALE_NAME* const current = &LOCALE_NAME_TABLE[index]; diff --git a/libfreerdp/primitives/prim_YCoCg.c b/libfreerdp/primitives/prim_YCoCg.c index 27f468bd6..7c1a429f9 100644 --- a/libfreerdp/primitives/prim_YCoCg.c +++ b/libfreerdp/primitives/prim_YCoCg.c @@ -37,16 +37,14 @@ static pstatus_t general_YCoCgToRGB_8u_AC4R(const BYTE* pSrc, INT32 srcStep, BYT UINT32 DstFormat, INT32 dstStep, UINT32 width, UINT32 height, UINT8 shift, BOOL withAlpha) { - UINT32 x = 0; - UINT32 y = 0; const DWORD formatSize = FreeRDPGetBytesPerPixel(DstFormat); fkt_writePixel writePixel = getPixelWriteFunction(DstFormat, TRUE); - for (y = 0; y < height; y++) + for (UINT32 y = 0; y < height; y++) { const BYTE* sptr = &pSrc[srcStep * y]; BYTE* dptr = &pDst[dstStep * y]; - for (x = 0; x < width; x++) + for (UINT32 x = 0; x < width; x++) { /* Note: shifts must be done before sign-conversion. */ const INT16 Cg = convert(*sptr++, shift); diff --git a/libfreerdp/primitives/prim_YCoCg_opt.c b/libfreerdp/primitives/prim_YCoCg_opt.c index fa4f0f0d2..bba13fac3 100644 --- a/libfreerdp/primitives/prim_YCoCg_opt.c +++ b/libfreerdp/primitives/prim_YCoCg_opt.c @@ -46,7 +46,6 @@ static pstatus_t ssse3_YCoCgRToRGB_8u_AC4R_invert(const BYTE* WINPR_RESTRICT pSr BYTE* dptr = (BYTE*)pDst; int sRowBump = srcStep - width * sizeof(UINT32); int dRowBump = dstStep - width * sizeof(UINT32); - UINT32 h = 0; /* Shift left by "shift" and divide by two is the same as shift * left by "shift-1". */ @@ -69,7 +68,7 @@ static pstatus_t ssse3_YCoCgRToRGB_8u_AC4R_invert(const BYTE* WINPR_RESTRICT pSr shift, withAlpha); } - for (h = 0; h < height; h++) + for (UINT32 h = 0; h < height; h++) { UINT32 w = width; BOOL onStride = 0; @@ -233,7 +232,6 @@ static pstatus_t ssse3_YCoCgRToRGB_8u_AC4R_no_invert(const BYTE* WINPR_RESTRICT BYTE* dptr = (BYTE*)pDst; int sRowBump = srcStep - width * sizeof(UINT32); int dRowBump = dstStep - width * sizeof(UINT32); - UINT32 h = 0; /* Shift left by "shift" and divide by two is the same as shift * left by "shift-1". */ @@ -256,7 +254,7 @@ static pstatus_t ssse3_YCoCgRToRGB_8u_AC4R_no_invert(const BYTE* WINPR_RESTRICT shift, withAlpha); } - for (h = 0; h < height; h++) + for (UINT32 h = 0; h < height; h++) { int w = width; BOOL onStride = 0; @@ -446,7 +444,6 @@ static pstatus_t neon_YCoCgToRGB_8u_X(const BYTE* WINPR_RESTRICT pSrc, INT32 src UINT32 width, UINT32 height, UINT8 shift, BYTE bPos, BYTE gPos, BYTE rPos, BYTE aPos, BOOL alpha) { - UINT32 y; BYTE* dptr = pDst; const BYTE* sptr = pSrc; const DWORD formatSize = FreeRDPGetBytesPerPixel(DstFormat); @@ -457,11 +454,9 @@ static pstatus_t neon_YCoCgToRGB_8u_X(const BYTE* WINPR_RESTRICT pSrc, INT32 src const uint8x8_t aVal = vdup_n_u8(0xFF); const int8x8_t cllv = vdup_n_s8(cll); - for (y = 0; y < height; y++) + for (UINT32 y = 0; y < height; y++) { - UINT32 x; - - for (x = 0; x < width - pad; x += 8) + for (UINT32 x = 0; x < width - pad; x += 8) { /* Note: shifts must be done before sign-conversion. */ const uint8x8x4_t raw = vld4_u8(sptr); @@ -489,7 +484,7 @@ static pstatus_t neon_YCoCgToRGB_8u_X(const BYTE* WINPR_RESTRICT pSrc, INT32 src dptr += sizeof(bgrx); } - for (x = 0; x < pad; x++) + for (UINT32 x = 0; x < pad; x++) { /* Note: shifts must be done before sign-conversion. */ const INT16 Cg = (INT16)((INT8)((*sptr++) << cll)); diff --git a/libfreerdp/primitives/prim_YUV.c b/libfreerdp/primitives/prim_YUV.c index ad4a0abbe..ec021399a 100644 --- a/libfreerdp/primitives/prim_YUV.c +++ b/libfreerdp/primitives/prim_YUV.c @@ -99,11 +99,9 @@ static pstatus_t general_ChromaFilter(BYTE* WINPR_RESTRICT pDst[3], const UINT32 const UINT32 nHeight = roi->bottom - roi->top; const UINT32 halfHeight = (nHeight + 1) / 2; const UINT32 halfWidth = (nWidth + 1) / 2; - UINT32 x = 0; - UINT32 y = 0; /* Filter */ - for (y = roi->top; y < halfHeight + roi->top; y++) + for (UINT32 y = roi->top; y < halfHeight + roi->top; y++) { const UINT32 val2y = (y * 2 + evenY); const UINT32 val2y1 = val2y + oddY; @@ -115,7 +113,7 @@ static pstatus_t general_ChromaFilter(BYTE* WINPR_RESTRICT pDst[3], const UINT32 if (val2y1 > nHeight) continue; - for (x = roi->left; x < halfWidth + roi->left; x++) + for (UINT32 x = roi->left; x < halfWidth + roi->left; x++) { const UINT32 val2x = (x * 2); const UINT32 val2x1 = val2x + 1; @@ -148,8 +146,6 @@ static pstatus_t general_ChromaV1ToYUV444(const BYTE* const WINPR_RESTRICT pSrcR const UINT32 mod = 16; UINT32 uY = 0; UINT32 vY = 0; - UINT32 x = 0; - UINT32 y = 0; const UINT32 nWidth = roi->right - roi->left; const UINT32 nHeight = roi->bottom - roi->top; const UINT32 halfWidth = (nWidth) / 2; @@ -169,7 +165,7 @@ static pstatus_t general_ChromaV1ToYUV444(const BYTE* const WINPR_RESTRICT pSrcR /* The second half of U and V is a bit more tricky... */ /* B4 and B5 */ - for (y = 0; y < padHeigth; y++) + for (UINT32 y = 0; y < padHeigth; y++) { const BYTE* Ya = pSrc[0] + srcStep[0] * y; BYTE* pX = NULL; @@ -197,7 +193,7 @@ static pstatus_t general_ChromaV1ToYUV444(const BYTE* const WINPR_RESTRICT pSrcR } /* B6 and B7 */ - for (y = 0; y < halfHeight; y++) + for (UINT32 y = 0; y < halfHeight; y++) { const UINT32 val2y = (y * 2 + evenY); const BYTE* Ua = pSrc[1] + srcStep[1] * y; @@ -205,7 +201,7 @@ static pstatus_t general_ChromaV1ToYUV444(const BYTE* const WINPR_RESTRICT pSrcR BYTE* pU = pDst[1] + dstStep[1] * val2y; BYTE* pV = pDst[2] + dstStep[2] * val2y; - for (x = 0; x < halfWidth; x++) + for (UINT32 x = 0; x < halfWidth; x++) { const UINT32 val2x1 = (x * 2 + oddX); pU[val2x1] = Ua[x]; @@ -223,8 +219,6 @@ static pstatus_t general_ChromaV2ToYUV444(const BYTE* const WINPR_RESTRICT pSrc[ const UINT32 dstStep[3], const RECTANGLE_16* WINPR_RESTRICT roi) { - UINT32 x = 0; - UINT32 y = 0; const UINT32 nWidth = roi->right - roi->left; const UINT32 nHeight = roi->bottom - roi->top; const UINT32 halfWidth = (nWidth + 1) / 2; @@ -232,7 +226,7 @@ static pstatus_t general_ChromaV2ToYUV444(const BYTE* const WINPR_RESTRICT pSrc[ const UINT32 quaterWidth = (nWidth + 3) / 4; /* B4 and B5: odd UV values for width/2, height */ - for (y = 0; y < nHeight; y++) + for (UINT32 y = 0; y < nHeight; y++) { const UINT32 yTop = y + roi->top; const BYTE* pYaU = pSrc[0] + srcStep[0] * yTop + roi->left / 2; @@ -240,7 +234,7 @@ static pstatus_t general_ChromaV2ToYUV444(const BYTE* const WINPR_RESTRICT pSrc[ BYTE* pU = pDst[1] + dstStep[1] * yTop + roi->left; BYTE* pV = pDst[2] + dstStep[2] * yTop + roi->left; - for (x = 0; x < halfWidth; x++) + for (UINT32 x = 0; x < halfWidth; x++) { const UINT32 odd = 2 * x + 1; pU[odd] = *pYaU++; @@ -249,7 +243,7 @@ static pstatus_t general_ChromaV2ToYUV444(const BYTE* const WINPR_RESTRICT pSrc[ } /* B6 - B9 */ - for (y = 0; y < halfHeight; y++) + for (UINT32 y = 0; y < halfHeight; y++) { const BYTE* pUaU = pSrc[1] + srcStep[1] * (y + roi->top / 2) + roi->left / 4; const BYTE* pUaV = pUaU + nTotalWidth / 4; @@ -258,7 +252,7 @@ static pstatus_t general_ChromaV2ToYUV444(const BYTE* const WINPR_RESTRICT pSrc[ BYTE* pU = pDst[1] + dstStep[1] * (2 * y + 1 + roi->top) + roi->left; BYTE* pV = pDst[2] + dstStep[2] * (2 * y + 1 + roi->top) + roi->left; - for (x = 0; x < quaterWidth; x++) + for (UINT32 x = 0; x < quaterWidth; x++) { pU[4 * x + 0] = *pUaU++; pV[4 * x + 0] = *pUaV++; @@ -308,8 +302,6 @@ general_YUV444SplitToYUV420(const BYTE* const WINPR_RESTRICT pSrc[3], const UINT BYTE* WINPR_RESTRICT pAuxDst[3], const UINT32 dstAuxStep[3], const prim_size_t* WINPR_RESTRICT roi) { - UINT32 x = 0; - UINT32 y = 0; UINT32 uY = 0; UINT32 vY = 0; UINT32 halfWidth = 0; @@ -321,7 +313,7 @@ general_YUV444SplitToYUV420(const BYTE* const WINPR_RESTRICT pSrc[3], const UINT halfHeight = (roi->height + 1) / 2; /* B1 */ - for (y = 0; y < roi->height; y++) + for (UINT32 y = 0; y < roi->height; y++) { const BYTE* pSrcY = pSrc[0] + y * srcStep[0]; BYTE* pY = pMainDst[0] + y * dstMainStep[0]; @@ -329,7 +321,7 @@ general_YUV444SplitToYUV420(const BYTE* const WINPR_RESTRICT pSrc[3], const UINT } /* B2 and B3 */ - for (y = 0; y < halfHeight; y++) + for (UINT32 y = 0; y < halfHeight; y++) { const BYTE* pSrcU = pSrc[1] + 2 * y * srcStep[1]; const BYTE* pSrcV = pSrc[2] + 2 * y * srcStep[2]; @@ -338,7 +330,7 @@ general_YUV444SplitToYUV420(const BYTE* const WINPR_RESTRICT pSrc[3], const UINT BYTE* pU = pMainDst[1] + y * dstMainStep[1]; BYTE* pV = pMainDst[2] + y * dstMainStep[2]; - for (x = 0; x < halfWidth; x++) + for (UINT32 x = 0; x < halfWidth; x++) { /* Filter */ const INT32 u = pSrcU[2 * x] + pSrcU[2 * x + 1] + pSrcU1[2 * x] + pSrcU1[2 * x + 1]; @@ -349,7 +341,7 @@ general_YUV444SplitToYUV420(const BYTE* const WINPR_RESTRICT pSrc[3], const UINT } /* B4 and B5 */ - for (y = 0; y < padHeigth; y++) + for (UINT32 y = 0; y < padHeigth; y++) { BYTE* pY = pAuxDst[0] + y * dstAuxStep[0]; @@ -376,14 +368,14 @@ general_YUV444SplitToYUV420(const BYTE* const WINPR_RESTRICT pSrc[3], const UINT } /* B6 and B7 */ - for (y = 0; y < halfHeight; y++) + for (UINT32 y = 0; y < halfHeight; y++) { const BYTE* pSrcU = pSrc[1] + 2 * y * srcStep[1]; const BYTE* pSrcV = pSrc[2] + 2 * y * srcStep[2]; BYTE* pU = pAuxDst[1] + y * dstAuxStep[1]; BYTE* pV = pAuxDst[2] + y * dstAuxStep[2]; - for (x = 0; x < halfWidth; x++) + for (UINT32 x = 0; x < halfWidth; x++) { pU[x] = pSrcU[2 * x + 1]; pV[x] = pSrcV[2 * x + 1]; @@ -494,8 +486,6 @@ static pstatus_t general_YUV420ToRGB_8u_P3AC4R(const BYTE* const WINPR_RESTRICT UINT32 dstStep, UINT32 DstFormat, const prim_size_t* WINPR_RESTRICT roi) { - UINT32 x = 0; - UINT32 y = 0; UINT32 dstPad = 0; UINT32 srcPad[3]; BYTE Y = 0; @@ -527,12 +517,12 @@ static pstatus_t general_YUV420ToRGB_8u_P3AC4R(const BYTE* const WINPR_RESTRICT srcPad[2] = (srcStep[2] - halfWidth); dstPad = (dstStep - (nWidth * 4)); - for (y = 0; y < halfHeight;) + for (UINT32 y = 0; y < halfHeight;) { if (++y == halfHeight) lastRow <<= 1; - for (x = 0; x < halfWidth;) + for (UINT32 x = 0; x < halfWidth;) { BYTE r = 0; BYTE g = 0; @@ -575,7 +565,7 @@ static pstatus_t general_YUV420ToRGB_8u_P3AC4R(const BYTE* const WINPR_RESTRICT if (lastRow & 0x02) break; - for (x = 0; x < halfWidth;) + for (UINT32 x = 0; x < halfWidth;) { BYTE r = 0; BYTE g = 0; @@ -645,21 +635,19 @@ static pstatus_t general_RGBToYUV444_8u_P3AC4R(const BYTE* WINPR_RESTRICT pSrc, const prim_size_t* WINPR_RESTRICT roi) { const UINT32 bpp = FreeRDPGetBytesPerPixel(SrcFormat); - UINT32 x = 0; - UINT32 y = 0; UINT32 nWidth = 0; UINT32 nHeight = 0; nWidth = roi->width; nHeight = roi->height; - for (y = 0; y < nHeight; y++) + for (UINT32 y = 0; y < nHeight; y++) { const BYTE* pRGB = pSrc + y * srcStep; BYTE* pY = pDst[0] + y * dstStep[0]; BYTE* pU = pDst[1] + y * dstStep[1]; BYTE* pV = pDst[2] + y * dstStep[2]; - for (x = 0; x < nWidth; x++) + for (UINT32 x = 0; x < nWidth; x++) { BYTE B = 0; BYTE G = 0; @@ -680,8 +668,6 @@ static INLINE pstatus_t general_RGBToYUV420_BGRX(const BYTE* WINPR_RESTRICT pSrc const UINT32 dstStep[3], const prim_size_t* WINPR_RESTRICT roi) { - UINT32 x = 0; - UINT32 y = 0; UINT32 i = 0; size_t x1 = 0; size_t x2 = 4; @@ -694,14 +680,14 @@ static INLINE pstatus_t general_RGBToYUV420_BGRX(const BYTE* WINPR_RESTRICT pSrc UINT32 max_x = roi->width - 1; UINT32 max_y = roi->height - 1; - for (y = i = 0; y < roi->height; y += 2, i++) + for (UINT32 y = i = 0; y < roi->height; y += 2, i++) { const BYTE* src = pSrc + y * srcStep; BYTE* ydst = pDst[0] + y * dstStep[0]; BYTE* udst = pDst[1] + i * dstStep[1]; BYTE* vdst = pDst[2] + i * dstStep[2]; - for (x = 0; x < roi->width; x += 2) + for (UINT32 x = 0; x < roi->width; x += 2) { BYTE R = 0; BYTE G = 0; @@ -760,9 +746,6 @@ static INLINE pstatus_t general_RGBToYUV420_RGBX(const BYTE* WINPR_RESTRICT pSrc const UINT32 dstStep[3], const prim_size_t* WINPR_RESTRICT roi) { - UINT32 x = 0; - UINT32 y = 0; - UINT32 i = 0; size_t x1 = 0; size_t x2 = 4; size_t x3 = srcStep; @@ -774,14 +757,14 @@ static INLINE pstatus_t general_RGBToYUV420_RGBX(const BYTE* WINPR_RESTRICT pSrc UINT32 max_x = roi->width - 1; UINT32 max_y = roi->height - 1; - for (y = i = 0; y < roi->height; y += 2, i++) + for (UINT32 y = 0, i = 0; y < roi->height; y += 2, i++) { const BYTE* src = pSrc + y * srcStep; BYTE* ydst = pDst[0] + y * dstStep[0]; BYTE* udst = pDst[1] + i * dstStep[1]; BYTE* vdst = pDst[2] + i * dstStep[2]; - for (x = 0; x < roi->width; x += 2) + for (UINT32 x = 0; x < roi->width; x += 2) { BYTE R = 0; BYTE G = 0; @@ -841,9 +824,6 @@ static INLINE pstatus_t general_RGBToYUV420_ANY(const BYTE* WINPR_RESTRICT pSrc, const prim_size_t* WINPR_RESTRICT roi) { const UINT32 bpp = FreeRDPGetBytesPerPixel(srcFormat); - UINT32 x = 0; - UINT32 y = 0; - UINT32 i = 0; size_t x1 = 0; size_t x2 = bpp; size_t x3 = srcStep; @@ -855,14 +835,14 @@ static INLINE pstatus_t general_RGBToYUV420_ANY(const BYTE* WINPR_RESTRICT pSrc, UINT32 max_x = roi->width - 1; UINT32 max_y = roi->height - 1; - for (y = i = 0; y < roi->height; y += 2, i++) + for (UINT32 y = 0, i = 0; y < roi->height; y += 2, i++) { const BYTE* src = pSrc + y * srcStep; BYTE* ydst = pDst[0] + y * dstStep[0]; BYTE* udst = pDst[1] + i * dstStep[1]; BYTE* vdst = pDst[2] + i * dstStep[2]; - for (x = 0; x < roi->width; x += 2) + for (UINT32 x = 0; x < roi->width; x += 2) { BYTE R = 0; BYTE G = 0; @@ -1062,10 +1042,9 @@ static INLINE pstatus_t general_RGBToAVC444YUV_BGRX(const BYTE* WINPR_RESTRICT p * Note: * Read information in function general_RGBToAVC444YUV_ANY below ! */ - UINT32 y = 0; const BYTE* pMaxSrc = pSrc + (roi->height - 1) * srcStep; - for (y = 0; y < roi->height; y += 2) + for (UINT32 y = 0; y < roi->height; y += 2) { const BOOL last = (y >= (roi->height - 1)); const BYTE* srcEven = y < roi->height ? pSrc + y * srcStep : pMaxSrc; diff --git a/libfreerdp/primitives/prim_YUV_neon.c b/libfreerdp/primitives/prim_YUV_neon.c index b63c87ffd..5e2039e3b 100644 --- a/libfreerdp/primitives/prim_YUV_neon.c +++ b/libfreerdp/primitives/prim_YUV_neon.c @@ -138,7 +138,6 @@ static INLINE pstatus_t neon_YUV420ToX(const BYTE* const WINPR_RESTRICT pSrc[3], const uint8_t rPos, const uint8_t gPos, const uint8_t bPos, const uint8_t aPos) { - UINT32 y; const UINT32 nWidth = roi->width; const UINT32 nHeight = roi->height; const DWORD pad = nWidth % 16; @@ -148,7 +147,7 @@ static INLINE pstatus_t neon_YUV420ToX(const BYTE* const WINPR_RESTRICT pSrc[3], const UINT32 dPad = dstStep - roi->width * 4; const int16x8_t c128 = vdupq_n_s16(128); - for (y = 0; y < nHeight; y += 2) + for (UINT32 y = 0; y < nHeight; y += 2) { const uint8_t* pY1 = pSrc[0] + y * srcStep[0]; const uint8_t* pY2 = pY1 + srcStep[0]; @@ -156,10 +155,9 @@ static INLINE pstatus_t neon_YUV420ToX(const BYTE* const WINPR_RESTRICT pSrc[3], const uint8_t* pV = pSrc[2] + (y / 2) * srcStep[2]; uint8_t* pRGB1 = pDst + y * dstStep; uint8_t* pRGB2 = pRGB1 + dstStep; - UINT32 x; const BOOL lastY = y >= nHeight - 1; - for (x = 0; x < nWidth - pad;) + for (UINT32 x = 0; x < nWidth - pad;) { const uint8x8_t Uraw = vld1_u8(pU); const uint8x8x2_t Uu = vzip_u8(Uraw, Uraw); @@ -289,7 +287,6 @@ static INLINE pstatus_t neon_YUV444ToX(const BYTE* const WINPR_RESTRICT pSrc[3], const uint8_t rPos, const uint8_t gPos, const uint8_t bPos, const uint8_t aPos) { - UINT32 y; const UINT32 nWidth = roi->width; const UINT32 nHeight = roi->height; const UINT32 yPad = srcStep[0] - roi->width; @@ -303,11 +300,9 @@ static INLINE pstatus_t neon_YUV444ToX(const BYTE* const WINPR_RESTRICT pSrc[3], const int16x8_t c128 = vdupq_n_s16(128); const DWORD pad = nWidth % 8; - for (y = 0; y < nHeight; y++) + for (UINT32 y = 0; y < nHeight; y++) { - UINT32 x; - - for (x = 0; x < nWidth - pad; x += 8) + for (UINT32 x = 0; x < nWidth - pad; x += 8) { const uint8x8_t Yu = vld1_u8(pY); const int16x8_t Y = vreinterpretq_s16_u16(vmovl_u8(Yu)); @@ -325,7 +320,7 @@ static INLINE pstatus_t neon_YUV444ToX(const BYTE* const WINPR_RESTRICT pSrc[3], pV += 8; } - for (x = 0; x < pad; x++) + for (UINT32 x = 0; x < pad; x++) { const BYTE Y = *pY++; const BYTE U = *pU++; @@ -381,7 +376,6 @@ static pstatus_t neon_LumaToYUV444(const BYTE* const WINPR_RESTRICT pSrcRaw[3], const UINT32 srcStep[3], BYTE* WINPR_RESTRICT pDstRaw[3], const UINT32 dstStep[3], const RECTANGLE_16* WINPR_RESTRICT roi) { - UINT32 x, y; const UINT32 nWidth = roi->right - roi->left; const UINT32 nHeight = roi->bottom - roi->top; const UINT32 halfWidth = (nWidth + 1) / 2; @@ -396,7 +390,7 @@ static pstatus_t neon_LumaToYUV444(const BYTE* const WINPR_RESTRICT pSrcRaw[3], /* Y data is already here... */ /* B1 */ - for (y = 0; y < nHeight; y++) + for (UINT32 y = 0; y < nHeight; y++) { const BYTE* Ym = pSrc[0] + srcStep[0] * y; BYTE* pY = pDst[0] + dstStep[0] * y; @@ -405,7 +399,7 @@ static pstatus_t neon_LumaToYUV444(const BYTE* const WINPR_RESTRICT pSrcRaw[3], /* The first half of U, V are already here part of this frame. */ /* B2 and B3 */ - for (y = 0; y < halfHeight; y++) + for (UINT32 y = 0; y < halfHeight; y++) { const UINT32 val2y = (2 * y + evenY); const BYTE* Um = pSrc[1] + srcStep[1] * y; @@ -415,7 +409,7 @@ static pstatus_t neon_LumaToYUV444(const BYTE* const WINPR_RESTRICT pSrcRaw[3], BYTE* pU1 = pU + dstStep[1]; BYTE* pV1 = pV + dstStep[2]; - for (x = 0; x + 16 < halfWidth; x += 16) + for (UINT32 x = 0; x + 16 < halfWidth; x += 16) { { const uint8x16_t u = vld1q_u8(Um); @@ -469,10 +463,9 @@ static pstatus_t neon_ChromaFilter(BYTE* WINPR_RESTRICT pDst[3], const UINT32 ds const UINT32 halfHeight = (nHeight + 1) / 2; const UINT32 halfWidth = (nWidth + 1) / 2; const UINT32 halfPad = halfWidth % 16; - UINT32 x, y; /* Filter */ - for (y = roi->top; y < halfHeight + roi->top; y++) + for (UINT32 y = roi->top; y < halfHeight + roi->top; y++) { const UINT32 val2y = (y * 2 + evenY); const UINT32 val2y1 = val2y + oddY; @@ -484,7 +477,7 @@ static pstatus_t neon_ChromaFilter(BYTE* WINPR_RESTRICT pDst[3], const UINT32 ds if (val2y1 > nHeight) continue; - for (x = roi->left / 2; x < halfWidth + roi->left / 2 - halfPad; x += 16) + for (UINT32 x = roi->left / 2; x < halfWidth + roi->left / 2 - halfPad; x += 16) { { /* U = (U2x,2y << 2) - U2x1,2y - U2x,2y1 - U2x1,2y1 */ @@ -548,7 +541,6 @@ static pstatus_t neon_ChromaV1ToYUV444(const BYTE* const WINPR_RESTRICT pSrcRaw[ const UINT32 mod = 16; UINT32 uY = 0; UINT32 vY = 0; - UINT32 x, y; const UINT32 nWidth = roi->right - roi->left; const UINT32 nHeight = roi->bottom - roi->top; const UINT32 halfWidth = (nWidth) / 2; @@ -569,7 +561,7 @@ static pstatus_t neon_ChromaV1ToYUV444(const BYTE* const WINPR_RESTRICT pSrcRaw[ /* The second half of U and V is a bit more tricky... */ /* B4 and B5 */ - for (y = 0; y < padHeigth; y++) + for (UINT32 y = 0; y < padHeigth; y++) { const BYTE* Ya = pSrc[0] + srcStep[0] * y; BYTE* pX; @@ -597,7 +589,7 @@ static pstatus_t neon_ChromaV1ToYUV444(const BYTE* const WINPR_RESTRICT pSrcRaw[ } /* B6 and B7 */ - for (y = 0; y < halfHeight; y++) + for (UINT32 y = 0; y < halfHeight; y++) { const UINT32 val2y = (y * 2 + evenY); const BYTE* Ua = pSrc[1] + srcStep[1] * y; @@ -605,7 +597,7 @@ static pstatus_t neon_ChromaV1ToYUV444(const BYTE* const WINPR_RESTRICT pSrcRaw[ BYTE* pU = pDst[1] + dstStep[1] * val2y; BYTE* pV = pDst[2] + dstStep[2] * val2y; - for (x = 0; x < halfWidth - halfPad; x += 16) + for (UINT32 x = 0; x < halfWidth - halfPad; x += 16) { { uint8x16x2_t u = vld2q_u8(&pU[2 * x]); @@ -637,7 +629,6 @@ static pstatus_t neon_ChromaV2ToYUV444(const BYTE* const WINPR_RESTRICT pSrc[3], const UINT32 dstStep[3], const RECTANGLE_16* WINPR_RESTRICT roi) { - UINT32 x, y; const UINT32 nWidth = roi->right - roi->left; const UINT32 nHeight = roi->bottom - roi->top; const UINT32 halfWidth = (nWidth + 1) / 2; @@ -647,7 +638,7 @@ static pstatus_t neon_ChromaV2ToYUV444(const BYTE* const WINPR_RESTRICT pSrc[3], const UINT32 quaterPad = quaterWidth % 16; /* B4 and B5: odd UV values for width/2, height */ - for (y = 0; y < nHeight; y++) + for (UINT32 y = 0; y < nHeight; y++) { const UINT32 yTop = y + roi->top; const BYTE* pYaU = pSrc[0] + srcStep[0] * yTop + roi->left / 2; @@ -655,7 +646,7 @@ static pstatus_t neon_ChromaV2ToYUV444(const BYTE* const WINPR_RESTRICT pSrc[3], BYTE* pU = pDst[1] + dstStep[1] * yTop + roi->left; BYTE* pV = pDst[2] + dstStep[2] * yTop + roi->left; - for (x = 0; x < halfWidth - halfPad; x += 16) + for (UINT32 x = 0; x < halfWidth - halfPad; x += 16) { { uint8x16x2_t u = vld2q_u8(&pU[2 * x]); @@ -678,7 +669,7 @@ static pstatus_t neon_ChromaV2ToYUV444(const BYTE* const WINPR_RESTRICT pSrc[3], } /* B6 - B9 */ - for (y = 0; y < halfHeight; y++) + for (UINT32 y = 0; y < halfHeight; y++) { const BYTE* pUaU = pSrc[1] + srcStep[1] * (y + roi->top / 2) + roi->left / 4; const BYTE* pUaV = pUaU + nTotalWidth / 4; @@ -687,7 +678,7 @@ static pstatus_t neon_ChromaV2ToYUV444(const BYTE* const WINPR_RESTRICT pSrc[3], BYTE* pU = pDst[1] + dstStep[1] * (2 * y + 1 + roi->top) + roi->left; BYTE* pV = pDst[2] + dstStep[2] * (2 * y + 1 + roi->top) + roi->left; - for (x = 0; x < quaterWidth - quaterPad; x += 16) + for (UINT32 x = 0; x < quaterWidth - quaterPad; x += 16) { { uint8x16x4_t u = vld4q_u8(&pU[4 * x]); diff --git a/libfreerdp/primitives/prim_YUV_ssse3.c b/libfreerdp/primitives/prim_YUV_ssse3.c index c0108f3aa..2fbef3e94 100644 --- a/libfreerdp/primitives/prim_YUV_ssse3.c +++ b/libfreerdp/primitives/prim_YUV_ssse3.c @@ -161,17 +161,15 @@ static pstatus_t ssse3_YUV420ToRGB_BGRX(const BYTE* const WINPR_RESTRICT pSrc[], const UINT32 nHeight = roi->height; const UINT32 pad = roi->width % 16; const __m128i duplicate = _mm_set_epi8(7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0); - UINT32 y = 0; - for (y = 0; y < nHeight; y++) + for (UINT32 y = 0; y < nHeight; y++) { - UINT32 x = 0; __m128i* dst = (__m128i*)(pDst + dstStep * y); const BYTE* YData = pSrc[0] + y * srcStep[0]; const BYTE* UData = pSrc[1] + (y / 2) * srcStep[1]; const BYTE* VData = pSrc[2] + (y / 2) * srcStep[2]; - for (x = 0; x < nWidth - pad; x += 16) + for (UINT32 x = 0; x < nWidth - pad; x += 16) { const __m128i Y = _mm_loadu_si128((const __m128i*)YData); const __m128i uRaw = _mm_loadu_si128((const __m128i*)UData); @@ -187,7 +185,7 @@ static pstatus_t ssse3_YUV420ToRGB_BGRX(const BYTE* const WINPR_RESTRICT pSrc[], dst = ssse3_YUV444Pixel(dst, Y, U, V, 3); } - for (x = 0; x < pad; x++) + for (UINT32 x = 0; x < pad; x++) { const BYTE Y = *YData++; const BYTE U = *UData; @@ -232,17 +230,15 @@ static pstatus_t ssse3_YUV444ToRGB_8u_P3AC4R_BGRX(const BYTE* const WINPR_RESTRI const UINT32 nWidth = roi->width; const UINT32 nHeight = roi->height; const UINT32 pad = roi->width % 16; - UINT32 y = 0; - for (y = 0; y < nHeight; y++) + for (UINT32 y = 0; y < nHeight; y++) { - UINT32 x = 0; __m128i* dst = (__m128i*)(pDst + dstStep * y); const BYTE* YData = pSrc[0] + y * srcStep[0]; const BYTE* UData = pSrc[1] + y * srcStep[1]; const BYTE* VData = pSrc[2] + y * srcStep[2]; - for (x = 0; x < nWidth - pad; x += 16) + for (UINT32 x = 0; x < nWidth - pad; x += 16) { __m128i Y = _mm_load_si128((const __m128i*)YData); __m128i U = _mm_load_si128((const __m128i*)UData); @@ -256,7 +252,7 @@ static pstatus_t ssse3_YUV444ToRGB_8u_P3AC4R_BGRX(const BYTE* const WINPR_RESTRI dst = ssse3_YUV444Pixel(dst, Y, U, V, 3); } - for (x = 0; x < pad; x++) + for (UINT32 x = 0; x < pad; x++) { const BYTE Y = *YData++; const BYTE U = *UData++; @@ -348,7 +344,6 @@ PRIM_ALIGN_128 static const BYTE rgbx_v_factors[] = { static INLINE void ssse3_RGBToYUV420_BGRX_Y(const BYTE* WINPR_RESTRICT src, BYTE* dst, UINT32 width) { - UINT32 x = 0; __m128i x0; __m128i x1; __m128i x2; @@ -357,7 +352,7 @@ static INLINE void ssse3_RGBToYUV420_BGRX_Y(const BYTE* WINPR_RESTRICT src, BYTE const __m128i* argb = (const __m128i*)src; __m128i* ydst = (__m128i*)dst; - for (x = 0; x < width; x += 16) + for (UINT32 x = 0; x < width; x += 16) { /* store 16 rgba pixels in 4 128 bit registers */ x0 = _mm_load_si128(argb++); // 1st 4 pixels @@ -389,7 +384,6 @@ static INLINE void ssse3_RGBToYUV420_BGRX_UV(const BYTE* WINPR_RESTRICT src1, BYTE* WINPR_RESTRICT dst1, BYTE* WINPR_RESTRICT dst2, UINT32 width) { - UINT32 x = 0; const __m128i u_factors = BGRX_U_FACTORS; const __m128i v_factors = BGRX_V_FACTORS; const __m128i vector128 = CONST128_FACTORS; @@ -404,7 +398,7 @@ static INLINE void ssse3_RGBToYUV420_BGRX_UV(const BYTE* WINPR_RESTRICT src1, __m64* udst = (__m64*)dst1; __m64* vdst = (__m64*)dst2; - for (x = 0; x < width; x += 16) + for (UINT32 x = 0; x < width; x += 16) { /* subsample 16x2 pixels into 16x1 pixels */ x0 = _mm_load_si128(rgb1++); @@ -458,7 +452,6 @@ static pstatus_t ssse3_RGBToYUV420_BGRX(const BYTE* WINPR_RESTRICT pSrc, UINT32 const UINT32 dstStep[], const prim_size_t* WINPR_RESTRICT roi) { - UINT32 y = 0; const BYTE* argb = pSrc; BYTE* ydst = pDst[0]; BYTE* udst = pDst[1]; @@ -474,7 +467,7 @@ static pstatus_t ssse3_RGBToYUV420_BGRX(const BYTE* WINPR_RESTRICT pSrc, UINT32 return generic->RGBToYUV420_8u_P3AC4R(pSrc, srcFormat, srcStep, pDst, dstStep, roi); } - for (y = 0; y < roi->height - 1; y += 2) + for (UINT32 y = 0; y < roi->height - 1; y += 2) { const BYTE* line1 = argb; const BYTE* line2 = argb + srcStep; @@ -522,7 +515,6 @@ static INLINE void ssse3_RGBToAVC444YUV_BGRX_DOUBLE_ROW( BYTE* WINPR_RESTRICT b3, BYTE* WINPR_RESTRICT b4, BYTE* WINPR_RESTRICT b5, BYTE* WINPR_RESTRICT b6, BYTE* WINPR_RESTRICT b7, UINT32 width) { - UINT32 x = 0; const __m128i* argbEven = (const __m128i*)srcEven; const __m128i* argbOdd = (const __m128i*)srcOdd; const __m128i y_factors = BGRX_Y_FACTORS; @@ -530,7 +522,7 @@ static INLINE void ssse3_RGBToAVC444YUV_BGRX_DOUBLE_ROW( const __m128i v_factors = BGRX_V_FACTORS; const __m128i vector128 = CONST128_FACTORS; - for (x = 0; x < width; x += 16) + for (UINT32 x = 0; x < width; x += 16) { /* store 16 rgba pixels in 4 128 bit registers */ const __m128i xe1 = _mm_load_si128(argbEven++); // 1st 4 pixels @@ -804,12 +796,11 @@ static INLINE void ssse3_RGBToAVC444YUVv2_BGRX_DOUBLE_ROW( BYTE* WINPR_RESTRICT uChromaDst1, BYTE* WINPR_RESTRICT uChromaDst2, BYTE* WINPR_RESTRICT vChromaDst1, BYTE* WINPR_RESTRICT vChromaDst2, UINT32 width) { - UINT32 x = 0; const __m128i vector128 = CONST128_FACTORS; const __m128i* argbEven = (const __m128i*)srcEven; const __m128i* argbOdd = (const __m128i*)srcOdd; - for (x = 0; x < width; x += 16) + for (UINT32 x = 0; x < width; x += 16) { /* store 16 rgba pixels in 4 128 bit registers * for even and odd rows. @@ -1102,8 +1093,6 @@ static pstatus_t ssse3_LumaToYUV444(const BYTE* const WINPR_RESTRICT pSrcRaw[], const UINT32 srcStep[], BYTE* WINPR_RESTRICT pDstRaw[], const UINT32 dstStep[], const RECTANGLE_16* WINPR_RESTRICT roi) { - UINT32 x = 0; - UINT32 y = 0; const UINT32 nWidth = roi->right - roi->left; const UINT32 nHeight = roi->bottom - roi->top; const UINT32 halfWidth = (nWidth + 1) / 2; @@ -1122,7 +1111,7 @@ static pstatus_t ssse3_LumaToYUV444(const BYTE* const WINPR_RESTRICT pSrcRaw[], /* Y data is already here... */ /* B1 */ - for (y = 0; y < nHeight; y++) + for (UINT32 y = 0; y < nHeight; y++) { const BYTE* Ym = pSrc[0] + srcStep[0] * y; BYTE* pY = pDst[0] + dstStep[0] * y; @@ -1131,7 +1120,7 @@ static pstatus_t ssse3_LumaToYUV444(const BYTE* const WINPR_RESTRICT pSrcRaw[], /* The first half of U, V are already here part of this frame. */ /* B2 and B3 */ - for (y = 0; y < halfHeight; y++) + for (UINT32 y = 0; y < halfHeight; y++) { const UINT32 val2y = (2 * y + evenY); const UINT32 val2y1 = val2y + oddY; @@ -1142,7 +1131,8 @@ static pstatus_t ssse3_LumaToYUV444(const BYTE* const WINPR_RESTRICT pSrcRaw[], BYTE* pU1 = pDst[1] + dstStep[1] * val2y1; BYTE* pV1 = pDst[2] + dstStep[2] * val2y1; - for (x = 0; x < halfWidth - halfPad; x += 16) + UINT32 x = 0; + for (; x < halfWidth - halfPad; x += 16) { const __m128i unpackHigh = _mm_set_epi8(7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0); const __m128i unpackLow = @@ -1217,12 +1207,11 @@ static pstatus_t ssse3_ChromaFilter(BYTE* WINPR_RESTRICT pDst[], const UINT32 ds const UINT32 halfHeight = (nHeight + 1) / 2; const UINT32 halfWidth = (nWidth + 1) / 2; const UINT32 halfPad = halfWidth % 16; - UINT32 x = 0; - UINT32 y = 0; /* Filter */ - for (y = roi->top; y < halfHeight + roi->top; y++) + for (UINT32 y = roi->top; y < halfHeight + roi->top; y++) { + UINT32 x = roi->left; const UINT32 val2y = (y * 2 + evenY); const UINT32 val2y1 = val2y + oddY; BYTE* pU1 = pDst[1] + dstStep[1] * val2y1; @@ -1233,7 +1222,7 @@ static pstatus_t ssse3_ChromaFilter(BYTE* WINPR_RESTRICT pDst[], const UINT32 ds if (val2y1 > nHeight) continue; - for (x = roi->left; x < halfWidth + roi->left - halfPad; x += 16) + for (; x < halfWidth + roi->left - halfPad; x += 16) { ssse3_filter(&pU[2 * x], &pU1[2 * x]); ssse3_filter(&pV[2 * x], &pV1[2 * x]); @@ -1271,8 +1260,6 @@ static pstatus_t ssse3_ChromaV1ToYUV444(const BYTE* const WINPR_RESTRICT pSrcRaw const UINT32 mod = 16; UINT32 uY = 0; UINT32 vY = 0; - UINT32 x = 0; - UINT32 y = 0; const UINT32 nWidth = roi->right - roi->left; const UINT32 nHeight = roi->bottom - roi->top; const UINT32 halfWidth = (nWidth + 1) / 2; @@ -1296,7 +1283,7 @@ static pstatus_t ssse3_ChromaV1ToYUV444(const BYTE* const WINPR_RESTRICT pSrcRaw /* The second half of U and V is a bit more tricky... */ /* B4 and B5 */ - for (y = 0; y < padHeigth; y++) + for (UINT32 y = 0; y < padHeigth; y++) { const BYTE* Ya = pSrc[0] + srcStep[0] * y; BYTE* pX = NULL; @@ -1324,7 +1311,7 @@ static pstatus_t ssse3_ChromaV1ToYUV444(const BYTE* const WINPR_RESTRICT pSrcRaw } /* B6 and B7 */ - for (y = 0; y < halfHeight; y++) + for (UINT32 y = 0; y < halfHeight; y++) { const UINT32 val2y = (y * 2 + evenY); const BYTE* Ua = pSrc[1] + srcStep[1] * y; @@ -1332,7 +1319,8 @@ static pstatus_t ssse3_ChromaV1ToYUV444(const BYTE* const WINPR_RESTRICT pSrcRaw BYTE* pU = pDst[1] + dstStep[1] * val2y; BYTE* pV = pDst[2] + dstStep[2] * val2y; - for (x = 0; x < halfWidth - halfPad; x += 16) + UINT32 x = 0; + for (; x < halfWidth - halfPad; x += 16) { { const __m128i u = _mm_loadu_si128((const __m128i*)&Ua[x]); @@ -1368,8 +1356,6 @@ static pstatus_t ssse3_ChromaV2ToYUV444(const BYTE* const WINPR_RESTRICT pSrc[3] const UINT32 dstStep[3], const RECTANGLE_16* WINPR_RESTRICT roi) { - UINT32 x = 0; - UINT32 y = 0; const UINT32 nWidth = roi->right - roi->left; const UINT32 nHeight = roi->bottom - roi->top; const UINT32 halfWidth = (nWidth + 1) / 2; @@ -1390,7 +1376,7 @@ static pstatus_t ssse3_ChromaV2ToYUV444(const BYTE* const WINPR_RESTRICT pSrc[3] (char)0x80, 2, (char)0x80, 1, (char)0x80, 0); /* B4 and B5: odd UV values for width/2, height */ - for (y = 0; y < nHeight; y++) + for (UINT32 y = 0; y < nHeight; y++) { const UINT32 yTop = y + roi->top; const BYTE* pYaU = pSrc[0] + srcStep[0] * yTop + roi->left / 2; @@ -1398,7 +1384,8 @@ static pstatus_t ssse3_ChromaV2ToYUV444(const BYTE* const WINPR_RESTRICT pSrc[3] BYTE* pU = pDst[1] + dstStep[1] * yTop + roi->left; BYTE* pV = pDst[2] + dstStep[2] * yTop + roi->left; - for (x = 0; x < halfWidth - halfPad; x += 16) + UINT32 x = 0; + for (; x < halfWidth - halfPad; x += 16) { { const __m128i u = _mm_loadu_si128((const __m128i*)&pYaU[x]); @@ -1425,7 +1412,7 @@ static pstatus_t ssse3_ChromaV2ToYUV444(const BYTE* const WINPR_RESTRICT pSrc[3] } /* B6 - B9 */ - for (y = 0; y < halfHeight; y++) + for (UINT32 y = 0; y < halfHeight; y++) { const BYTE* pUaU = pSrc[1] + srcStep[1] * (y + roi->top / 2) + roi->left / 4; const BYTE* pUaV = pUaU + nTotalWidth / 4; @@ -1434,7 +1421,8 @@ static pstatus_t ssse3_ChromaV2ToYUV444(const BYTE* const WINPR_RESTRICT pSrc[3] BYTE* pU = pDst[1] + dstStep[1] * (2 * y + 1 + roi->top) + roi->left; BYTE* pV = pDst[2] + dstStep[2] * (2 * y + 1 + roi->top) + roi->left; - for (x = 0; x < quaterWidth - quaterPad; x += 16) + UINT32 x = 0; + for (; x < quaterWidth - quaterPad; x += 16) { { const __m128i uU = _mm_loadu_si128((const __m128i*)&pUaU[x]); diff --git a/libfreerdp/primitives/prim_alphaComp.c b/libfreerdp/primitives/prim_alphaComp.c index 5c94770bf..fe4f8dc98 100644 --- a/libfreerdp/primitives/prim_alphaComp.c +++ b/libfreerdp/primitives/prim_alphaComp.c @@ -37,16 +37,13 @@ static pstatus_t general_alphaComp_argb(const BYTE* pSrc1, UINT32 src1Step, cons UINT32 src2Step, BYTE* pDst, UINT32 dstStep, UINT32 width, UINT32 height) { - UINT32 y = 0; - - for (y = 0; y < height; y++) + for (UINT32 y = 0; y < height; y++) { const UINT32* sptr1 = (const UINT32*)(pSrc1 + y * src1Step); const UINT32* sptr2 = (const UINT32*)(pSrc2 + y * src2Step); UINT32* dptr = (UINT32*)(pDst + y * dstStep); - UINT32 x = 0; - for (x = 0; x < width; x++) + for (UINT32 x = 0; x < width; x++) { const UINT32 src1 = *sptr1++; const UINT32 src2 = *sptr2++; diff --git a/libfreerdp/primitives/prim_alphaComp_opt.c b/libfreerdp/primitives/prim_alphaComp_opt.c index 73f645477..2c675a4d5 100644 --- a/libfreerdp/primitives/prim_alphaComp_opt.c +++ b/libfreerdp/primitives/prim_alphaComp_opt.c @@ -55,7 +55,6 @@ static pstatus_t sse2_alphaComp_argb(const BYTE* WINPR_RESTRICT pSrc1, UINT32 sr int src1Jump = 0; int src2Jump = 0; int dstJump = 0; - UINT32 y = 0; __m128i xmm0; __m128i xmm1; @@ -76,7 +75,7 @@ static pstatus_t sse2_alphaComp_argb(const BYTE* WINPR_RESTRICT pSrc1, UINT32 sr xmm0 = _mm_set1_epi32(0); xmm1 = _mm_set1_epi16(1); - for (y = 0; y < height; ++y) + for (UINT32 y = 0; y < height; ++y) { int pixels = width; int count = 0; diff --git a/libfreerdp/primitives/prim_colors.c b/libfreerdp/primitives/prim_colors.c index 33458f451..4a23129a6 100644 --- a/libfreerdp/primitives/prim_colors.c +++ b/libfreerdp/primitives/prim_colors.c @@ -34,8 +34,6 @@ static pstatus_t general_yCbCrToRGB_16s8u_P3AC4R_BGRX(const INT16* const WINPR_R UINT32 dstStep, UINT32 DstFormat, const prim_size_t* WINPR_RESTRICT roi) { - UINT32 x = 0; - UINT32 y = 0; BYTE* pRGB = pDst; const INT16* pY = pSrc[0]; const INT16* pCb = pSrc[1]; @@ -44,9 +42,9 @@ static pstatus_t general_yCbCrToRGB_16s8u_P3AC4R_BGRX(const INT16* const WINPR_R const size_t dstPad = (dstStep - (roi->width * 4)); const DWORD formatSize = FreeRDPGetBytesPerPixel(DstFormat); - for (y = 0; y < roi->height; y++) + for (UINT32 y = 0; y < roi->height; y++) { - for (x = 0; x < roi->width; x++) + for (UINT32 x = 0; x < roi->width; x++) { INT16 R = 0; INT16 G = 0; @@ -79,8 +77,6 @@ static pstatus_t general_yCbCrToRGB_16s8u_P3AC4R_general(const INT16* const WINP UINT32 dstStep, UINT32 DstFormat, const prim_size_t* WINPR_RESTRICT roi) { - UINT32 x = 0; - UINT32 y = 0; BYTE* pRGB = pDst; const INT16* pY = pSrc[0]; const INT16* pCb = pSrc[1]; @@ -90,9 +86,9 @@ static pstatus_t general_yCbCrToRGB_16s8u_P3AC4R_general(const INT16* const WINP const fkt_writePixel writePixel = getPixelWriteFunction(DstFormat, FALSE); const DWORD formatSize = FreeRDPGetBytesPerPixel(DstFormat); - for (y = 0; y < roi->height; y++) + for (UINT32 y = 0; y < roi->height; y++) { - for (x = 0; x < roi->width; x++) + for (UINT32 x = 0; x < roi->width; x++) { INT64 R = 0; INT64 G = 0; @@ -164,13 +160,10 @@ general_yCbCrToRGB_16s16s_P3P3(const INT16* const WINPR_RESTRICT pSrc[3], INT32 INT16* bptr = pDst[2]; UINT32 srcbump = (srcStep - (roi->width * sizeof(UINT16))) / sizeof(UINT16); UINT32 dstbump = (dstStep - (roi->width * sizeof(UINT16))) / sizeof(UINT16); - UINT32 y = 0; - for (y = 0; y < roi->height; y++) + for (UINT32 y = 0; y < roi->height; y++) { - UINT32 x = 0; - - for (x = 0; x < roi->width; ++x) + for (UINT32 x = 0; x < roi->width; ++x) { /* INT32 is used intentionally because we calculate * with shifted factors! @@ -245,13 +238,10 @@ general_RGBToYCbCr_16s16s_P3P3(const INT16* const WINPR_RESTRICT pSrc[3], INT32 INT16* crptr = pDst[2]; UINT32 srcbump = (srcStep - (roi->width * sizeof(UINT16))) / sizeof(UINT16); UINT32 dstbump = (dstStep - (roi->width * sizeof(UINT16))) / sizeof(UINT16); - UINT32 y = 0; - for (y = 0; y < roi->height; y++) + for (UINT32 y = 0; y < roi->height; y++) { - UINT32 x = 0; - - for (x = 0; x < roi->width; ++x) + for (UINT32 x = 0; x < roi->width; ++x) { /* INT32 is used intentionally because we calculate with * shifted factors! @@ -293,21 +283,19 @@ general_RGBToYCbCr_16s16s_P3P3(const INT16* const WINPR_RESTRICT pSrc[3], INT32 static INLINE void writeScanlineGeneric(BYTE* dst, DWORD formatSize, UINT32 DstFormat, const INT16* r, const INT16* g, const INT16* b, DWORD width) { - DWORD x = 0; fkt_writePixel writePixel = getPixelWriteFunction(DstFormat, FALSE); - for (x = 0; x < width; x++) + for (UINT32 x = 0; x < width; x++) dst = writePixel(dst, formatSize, DstFormat, *r++, *g++, *b++, 0); } static INLINE void writeScanlineRGB(BYTE* dst, DWORD formatSize, UINT32 DstFormat, const INT16* r, const INT16* g, const INT16* b, DWORD width) { - DWORD x = 0; WINPR_UNUSED(formatSize); WINPR_UNUSED(DstFormat); - for (x = 0; x < width; x++) + for (UINT32 x = 0; x < width; x++) { const BYTE R = CLIP(*r++); const BYTE G = CLIP(*g++); @@ -321,11 +309,10 @@ static INLINE void writeScanlineRGB(BYTE* dst, DWORD formatSize, UINT32 DstForma static INLINE void writeScanlineBGR(BYTE* dst, DWORD formatSize, UINT32 DstFormat, const INT16* r, const INT16* g, const INT16* b, DWORD width) { - DWORD x = 0; WINPR_UNUSED(formatSize); WINPR_UNUSED(DstFormat); - for (x = 0; x < width; x++) + for (UINT32 x = 0; x < width; x++) { const BYTE R = CLIP(*r++); const BYTE G = CLIP(*g++); @@ -339,11 +326,10 @@ static INLINE void writeScanlineBGR(BYTE* dst, DWORD formatSize, UINT32 DstForma static INLINE void writeScanlineBGRX(BYTE* dst, DWORD formatSize, UINT32 DstFormat, const INT16* r, const INT16* g, const INT16* b, DWORD width) { - DWORD x = 0; WINPR_UNUSED(formatSize); WINPR_UNUSED(DstFormat); - for (x = 0; x < width; x++) + for (UINT32 x = 0; x < width; x++) { const BYTE R = CLIP(*r++); const BYTE G = CLIP(*g++); @@ -358,11 +344,10 @@ static INLINE void writeScanlineBGRX(BYTE* dst, DWORD formatSize, UINT32 DstForm static INLINE void writeScanlineRGBX(BYTE* dst, DWORD formatSize, UINT32 DstFormat, const INT16* r, const INT16* g, const INT16* b, DWORD width) { - DWORD x = 0; WINPR_UNUSED(formatSize); WINPR_UNUSED(DstFormat); - for (x = 0; x < width; x++) + for (UINT32 x = 0; x < width; x++) { const BYTE R = CLIP(*r++); const BYTE G = CLIP(*g++); @@ -377,11 +362,10 @@ static INLINE void writeScanlineRGBX(BYTE* dst, DWORD formatSize, UINT32 DstForm static INLINE void writeScanlineXBGR(BYTE* dst, DWORD formatSize, UINT32 DstFormat, const INT16* r, const INT16* g, const INT16* b, DWORD width) { - DWORD x = 0; WINPR_UNUSED(formatSize); WINPR_UNUSED(DstFormat); - for (x = 0; x < width; x++) + for (UINT32 x = 0; x < width; x++) { const BYTE R = CLIP(*r++); const BYTE G = CLIP(*g++); @@ -396,11 +380,10 @@ static INLINE void writeScanlineXBGR(BYTE* dst, DWORD formatSize, UINT32 DstForm static INLINE void writeScanlineXRGB(BYTE* dst, DWORD formatSize, UINT32 DstFormat, const INT16* r, const INT16* g, const INT16* b, DWORD width) { - DWORD x = 0; WINPR_UNUSED(formatSize); WINPR_UNUSED(DstFormat); - for (x = 0; x < width; x++) + for (UINT32 x = 0; x < width; x++) { const BYTE R = CLIP(*r++); const BYTE G = CLIP(*g++); @@ -457,12 +440,11 @@ static pstatus_t general_RGBToRGB_16s8u_P3AC4R_general( const INT16* r = pSrc[0]; const INT16* g = pSrc[1]; const INT16* b = pSrc[2]; - UINT32 y = 0; const DWORD srcAdd = srcStep / sizeof(INT16); fkt_writeScanline writeScanline = getScanlineWriteFunction(DstFormat); const DWORD formatSize = FreeRDPGetBytesPerPixel(DstFormat); - for (y = 0; y < roi->height; ++y) + for (UINT32 y = 0; y < roi->height; ++y) { (*writeScanline)(pDst, formatSize, DstFormat, r, g, b, roi->width); pDst += dstStep; @@ -484,11 +466,10 @@ static pstatus_t general_RGBToRGB_16s8u_P3AC4R_BGRX( const INT16* r = pSrc[0]; const INT16* g = pSrc[1]; const INT16* b = pSrc[2]; - UINT32 y = 0; const DWORD srcAdd = srcStep / sizeof(INT16); const DWORD formatSize = FreeRDPGetBytesPerPixel(DstFormat); - for (y = 0; y < roi->height; ++y) + for (UINT32 y = 0; y < roi->height; ++y) { writeScanlineBGRX(pDst, formatSize, DstFormat, r, g, b, roi->width); pDst += dstStep; diff --git a/libfreerdp/primitives/prim_colors_opt.c b/libfreerdp/primitives/prim_colors_opt.c index 010626eef..60debc3c6 100644 --- a/libfreerdp/primitives/prim_colors_opt.c +++ b/libfreerdp/primitives/prim_colors_opt.c @@ -55,9 +55,9 @@ static primitives_t* generic = NULL; static inline void GNU_INLINE _mm_prefetch_buffer(char* WINPR_RESTRICT buffer, int num_bytes) { __m128i* buf = (__m128i*)buffer; - unsigned int i; - for (i = 0; i < (num_bytes / sizeof(__m128i)); i += (CACHE_LINE_BYTES / sizeof(__m128i))) + for (unsigned int i = 0; i < (num_bytes / sizeof(__m128i)); + i += (CACHE_LINE_BYTES / sizeof(__m128i))) { _mm_prefetch((char*)(&buf[i]), _MM_HINT_NTA); } @@ -83,7 +83,6 @@ sse2_yCbCrToRGB_16s16s_P3P3(const INT16* const WINPR_RESTRICT pSrc[3], int srcSt __m128i* r_buf = NULL; __m128i* g_buf = NULL; __m128i* b_buf = NULL; - UINT32 yp = 0; int srcbump = 0; int dstbump = 0; int imax = 0; @@ -115,11 +114,9 @@ sse2_yCbCrToRGB_16s16s_P3P3(const INT16* const WINPR_RESTRICT pSrc[3], int srcSt #ifdef DO_PREFETCH /* Prefetch Y's, Cb's, and Cr's. */ - for (yp = 0; yp < roi->height; yp++) + for (UINT32 yp = 0; yp < roi->height; yp++) { - int i; - - for (i = 0; i < roi->width * sizeof(INT16) / sizeof(__m128i); + for (int i = 0; i < roi->width * sizeof(INT16) / sizeof(__m128i); i += (CACHE_LINE_BYTES / sizeof(__m128i))) { _mm_prefetch((char*)(&y_buf[i]), _MM_HINT_NTA); @@ -138,11 +135,9 @@ sse2_yCbCrToRGB_16s16s_P3P3(const INT16* const WINPR_RESTRICT pSrc[3], int srcSt #endif /* DO_PREFETCH */ imax = roi->width * sizeof(INT16) / sizeof(__m128i); - for (yp = 0; yp < roi->height; ++yp) + for (UINT32 yp = 0; yp < roi->height; ++yp) { - int i = 0; - - for (i = 0; i < imax; i++) + for (int i = 0; i < imax; i++) { /* In order to use SSE2 signed 16-bit integer multiplication * we need to convert the floating point factors to signed int @@ -229,16 +224,13 @@ sse2_yCbCrToRGB_16s8u_P3AC4R_BGRX(const INT16* const WINPR_RESTRICT pSrc[3], UIN const UINT32 step = sizeof(__m128i) / sizeof(INT16); const UINT32 imax = (roi->width - pad) * sizeof(INT16) / sizeof(__m128i); BYTE* d_buf = pDst; - UINT32 yp = 0; const size_t dstPad = (dstStep - roi->width * 4); #ifdef DO_PREFETCH /* Prefetch Y's, Cb's, and Cr's. */ - for (yp = 0; yp < roi->height; yp++) + for (UINT32 yp = 0; yp < roi->height; yp++) { - int i; - - for (i = 0; i < imax; i += (CACHE_LINE_BYTES / sizeof(__m128i))) + for (int i = 0; i < imax; i += (CACHE_LINE_BYTES / sizeof(__m128i))) { _mm_prefetch((char*)(&((__m128i*)y_buf)[i]), _MM_HINT_NTA); _mm_prefetch((char*)(&((__m128i*)cb_buf)[i]), _MM_HINT_NTA); @@ -255,11 +247,9 @@ sse2_yCbCrToRGB_16s8u_P3AC4R_BGRX(const INT16* const WINPR_RESTRICT pSrc[3], UIN cr_buf = (INT16*)pSrc[2]; #endif /* DO_PREFETCH */ - for (yp = 0; yp < roi->height; ++yp) + for (UINT32 yp = 0; yp < roi->height; ++yp) { - UINT32 i = 0; - - for (i = 0; i < imax; i += 2) + for (UINT32 i = 0; i < imax; i += 2) { /* In order to use SSE2 signed 16-bit integer multiplication * we need to convert the floating point factors to signed int @@ -387,7 +377,7 @@ sse2_yCbCrToRGB_16s8u_P3AC4R_BGRX(const INT16* const WINPR_RESTRICT pSrc[3], UIN } } - for (i = 0; i < pad; i++) + for (UINT32 i = 0; i < pad; i++) { const INT32 divisor = 16; const INT32 Y = ((*y_buf++) + 4096) << divisor; @@ -432,16 +422,13 @@ sse2_yCbCrToRGB_16s8u_P3AC4R_RGBX(const INT16* const WINPR_RESTRICT pSrc[3], UIN const UINT32 step = sizeof(__m128i) / sizeof(INT16); const UINT32 imax = (roi->width - pad) * sizeof(INT16) / sizeof(__m128i); BYTE* d_buf = pDst; - UINT32 yp = 0; const size_t dstPad = (dstStep - roi->width * 4); #ifdef DO_PREFETCH /* Prefetch Y's, Cb's, and Cr's. */ - for (yp = 0; yp < roi->height; yp++) + for (UINT32 yp = 0; yp < roi->height; yp++) { - int i; - - for (i = 0; i < imax; i += (CACHE_LINE_BYTES / sizeof(__m128i))) + for (int i = 0; i < imax; i += (CACHE_LINE_BYTES / sizeof(__m128i))) { _mm_prefetch((char*)(&((__m128i*)y_buf)[i]), _MM_HINT_NTA); _mm_prefetch((char*)(&((__m128i*)cb_buf)[i]), _MM_HINT_NTA); @@ -458,11 +445,9 @@ sse2_yCbCrToRGB_16s8u_P3AC4R_RGBX(const INT16* const WINPR_RESTRICT pSrc[3], UIN cr_buf = (INT16*)(pSrc[2]); #endif /* DO_PREFETCH */ - for (yp = 0; yp < roi->height; ++yp) + for (UINT32 yp = 0; yp < roi->height; ++yp) { - UINT32 i = 0; - - for (i = 0; i < imax; i += 2) + for (UINT32 i = 0; i < imax; i += 2) { /* In order to use SSE2 signed 16-bit integer multiplication * we need to convert the floating point factors to signed int @@ -590,7 +575,7 @@ sse2_yCbCrToRGB_16s8u_P3AC4R_RGBX(const INT16* const WINPR_RESTRICT pSrc[3], UIN } } - for (i = 0; i < pad; i++) + for (UINT32 i = 0; i < pad; i++) { const INT32 divisor = 16; const INT32 Y = ((*y_buf++) + 4096) << divisor; @@ -667,7 +652,6 @@ sse2_RGBToYCbCr_16s16s_P3P3(const INT16* const WINPR_RESTRICT pSrc[3], int srcSt __m128i* y_buf = (__m128i*)(pDst[0]); __m128i* cb_buf = (__m128i*)(pDst[1]); __m128i* cr_buf = (__m128i*)(pDst[2]); - UINT32 yp = 0; int srcbump = 0; int dstbump = 0; int imax = 0; @@ -698,11 +682,9 @@ sse2_RGBToYCbCr_16s16s_P3P3(const INT16* const WINPR_RESTRICT pSrc[3], int srcSt #ifdef DO_PREFETCH /* Prefetch RGB's. */ - for (yp = 0; yp < roi->height; yp++) + for (UINT32 yp = 0; yp < roi->height; yp++) { - int i; - - for (i = 0; i < roi->width * sizeof(INT16) / sizeof(__m128i); + for (int i = 0; i < roi->width * sizeof(INT16) / sizeof(__m128i); i += (CACHE_LINE_BYTES / sizeof(__m128i))) { _mm_prefetch((char*)(&r_buf[i]), _MM_HINT_NTA); @@ -721,11 +703,9 @@ sse2_RGBToYCbCr_16s16s_P3P3(const INT16* const WINPR_RESTRICT pSrc[3], int srcSt #endif /* DO_PREFETCH */ imax = roi->width * sizeof(INT16) / sizeof(__m128i); - for (yp = 0; yp < roi->height; ++yp) + for (UINT32 yp = 0; yp < roi->height; ++yp) { - int i = 0; - - for (i = 0; i < imax; i++) + for (int i = 0; i < imax; i++) { /* In order to use SSE2 signed 16-bit integer multiplication we * need to convert the floating point factors to signed int @@ -802,16 +782,13 @@ static pstatus_t sse2_RGBToRGB_16s8u_P3AC4R_BGRX( BYTE* out = NULL; UINT32 srcbump = 0; UINT32 dstbump = 0; - UINT32 y = 0; out = (BYTE*)pDst; srcbump = (srcStep - (roi->width * sizeof(UINT16))) / sizeof(UINT16); dstbump = (dstStep - (roi->width * sizeof(UINT32))); - for (y = 0; y < roi->height; ++y) + for (UINT32 y = 0; y < roi->height; ++y) { - UINT32 x = 0; - - for (x = 0; x < roi->width - pad; x += 16) + for (UINT32 x = 0; x < roi->width - pad; x += 16) { __m128i r; __m128i g; @@ -880,7 +857,7 @@ static pstatus_t sse2_RGBToRGB_16s8u_P3AC4R_BGRX( } } - for (x = 0; x < pad; x++) + for (UINT32 x = 0; x < pad; x++) { const BYTE R = CLIP(*pr++); const BYTE G = CLIP(*pg++); @@ -916,16 +893,13 @@ static pstatus_t sse2_RGBToRGB_16s8u_P3AC4R_RGBX( BYTE* out = NULL; UINT32 srcbump = 0; UINT32 dstbump = 0; - UINT32 y = 0; out = (BYTE*)pDst; srcbump = (srcStep - (roi->width * sizeof(UINT16))) / sizeof(UINT16); dstbump = (dstStep - (roi->width * sizeof(UINT32))); - for (y = 0; y < roi->height; ++y) + for (UINT32 y = 0; y < roi->height; ++y) { - UINT32 x = 0; - - for (x = 0; x < roi->width - pad; x += 16) + for (UINT32 x = 0; x < roi->width - pad; x += 16) { __m128i r; __m128i g; @@ -994,7 +968,7 @@ static pstatus_t sse2_RGBToRGB_16s8u_P3AC4R_RGBX( } } - for (x = 0; x < pad; x++) + for (UINT32 x = 0; x < pad; x++) { const BYTE R = CLIP(*pr++); const BYTE G = CLIP(*pg++); @@ -1030,16 +1004,13 @@ static pstatus_t sse2_RGBToRGB_16s8u_P3AC4R_XBGR( BYTE* out = NULL; UINT32 srcbump = 0; UINT32 dstbump = 0; - UINT32 y = 0; out = (BYTE*)pDst; srcbump = (srcStep - (roi->width * sizeof(UINT16))) / sizeof(UINT16); dstbump = (dstStep - (roi->width * sizeof(UINT32))); - for (y = 0; y < roi->height; ++y) + for (UINT32 y = 0; y < roi->height; ++y) { - UINT32 x = 0; - - for (x = 0; x < roi->width - pad; x += 16) + for (UINT32 x = 0; x < roi->width - pad; x += 16) { __m128i r; __m128i g; @@ -1108,7 +1079,7 @@ static pstatus_t sse2_RGBToRGB_16s8u_P3AC4R_XBGR( } } - for (x = 0; x < pad; x++) + for (UINT32 x = 0; x < pad; x++) { const BYTE R = CLIP(*pr++); const BYTE G = CLIP(*pg++); @@ -1144,16 +1115,13 @@ static pstatus_t sse2_RGBToRGB_16s8u_P3AC4R_XRGB( BYTE* out = NULL; UINT32 srcbump = 0; UINT32 dstbump = 0; - UINT32 y = 0; out = (BYTE*)pDst; srcbump = (srcStep - (roi->width * sizeof(UINT16))) / sizeof(UINT16); dstbump = (dstStep - (roi->width * sizeof(UINT32))); - for (y = 0; y < roi->height; ++y) + for (UINT32 y = 0; y < roi->height; ++y) { - UINT32 x = 0; - - for (x = 0; x < roi->width - pad; x += 16) + for (UINT32 x = 0; x < roi->width - pad; x += 16) { __m128i r; __m128i g; @@ -1222,7 +1190,7 @@ static pstatus_t sse2_RGBToRGB_16s8u_P3AC4R_XRGB( } } - for (x = 0; x < pad; x++) + for (UINT32 x = 0; x < pad; x++) { const BYTE R = CLIP(*pr++); const BYTE G = CLIP(*pg++); @@ -1301,14 +1269,11 @@ neon_yCbCrToRGB_16s16s_P3P3(const INT16* const WINPR_RESTRICT pSrc[3], INT32 src int16x8_t* b_buf = (int16x8_t*)pDst[2]; int srcbump = srcStep / sizeof(int16x8_t); int dstbump = dstStep / sizeof(int16x8_t); - int yp; int imax = roi->width * sizeof(INT16) / sizeof(int16x8_t); - for (yp = 0; yp < roi->height; ++yp) + for (int yp = 0; yp < roi->height; ++yp) { - int i; - - for (i = 0; i < imax; i++) + for (int i = 0; i < imax; i++) { /* In order to use NEON signed 16-bit integer multiplication we need to convert @@ -1373,7 +1338,6 @@ static pstatus_t neon_yCbCrToRGB_16s8u_P3AC4R_X(const INT16* const WINPR_RESTRIC const prim_size_t* WINPR_RESTRICT roi, uint8_t rPos, uint8_t gPos, uint8_t bPos, uint8_t aPos) { - UINT32 x, y; BYTE* pRGB = pDst; const INT16* pY = pSrc[0]; const INT16* pCb = pSrc[1]; @@ -1383,9 +1347,9 @@ static pstatus_t neon_yCbCrToRGB_16s8u_P3AC4R_X(const INT16* const WINPR_RESTRIC const size_t pad = roi->width % 8; const int16x4_t c4096 = vdup_n_s16(4096); - for (y = 0; y < roi->height; y++) + for (UINT32 y = 0; y < roi->height; y++) { - for (x = 0; x < roi->width - pad; x += 8) + for (UINT32 x = 0; x < roi->width - pad; x += 8) { const int16x8_t Y = vld1q_s16(pY); const int16x4_t Yh = vget_high_s16(Y); @@ -1451,7 +1415,7 @@ static pstatus_t neon_yCbCrToRGB_16s8u_P3AC4R_X(const INT16* const WINPR_RESTRIC pRGB += 32; } - for (x = 0; x < pad; x++) + for (UINT32 x = 0; x < pad; x++) { const INT32 divisor = 16; const INT32 Y = ((*pY++) + 4096) << divisor; @@ -1520,17 +1484,16 @@ static pstatus_t neon_RGBToRGB_16s8u_P3AC4R_X( const prim_size_t* WINPR_RESTRICT roi, /* region of interest */ uint8_t rPos, uint8_t gPos, uint8_t bPos, uint8_t aPos) { - UINT32 x, y; UINT32 pad = roi->width % 8; - for (y = 0; y < roi->height; y++) + for (UINT32 y = 0; y < roi->height; y++) { const INT16* pr = (INT16*)(((BYTE*)pSrc[0]) + y * srcStep); const INT16* pg = (INT16*)(((BYTE*)pSrc[1]) + y * srcStep); const INT16* pb = (INT16*)(((BYTE*)pSrc[2]) + y * srcStep); BYTE* dst = pDst + y * dstStep; - for (x = 0; x < roi->width - pad; x += 8) + for (UINT32 x = 0; x < roi->width - pad; x += 8) { int16x8_t r = vld1q_s16(pr); int16x8_t g = vld1q_s16(pg); @@ -1547,7 +1510,7 @@ static pstatus_t neon_RGBToRGB_16s8u_P3AC4R_X( dst += 32; } - for (x = 0; x < pad; x++) + for (UINT32 x = 0; x < pad; x++) { BYTE bgrx[4]; bgrx[bPos] = *pb++; diff --git a/libfreerdp/primitives/primitives.c b/libfreerdp/primitives/primitives.c index ddc60045f..18d5e108f 100644 --- a/libfreerdp/primitives/primitives.c +++ b/libfreerdp/primitives/primitives.c @@ -121,20 +121,18 @@ typedef struct static void primitives_YUV_benchmark_free(primitives_YUV_benchmark* bench) { - int i = 0; if (!bench) return; free(bench->outputBuffer); - for (i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) free(bench->channels[i]); memset(bench, 0, sizeof(primitives_YUV_benchmark)); } static primitives_YUV_benchmark* primitives_YUV_benchmark_init(primitives_YUV_benchmark* ret) { - int i = 0; prim_size_t* roi = NULL; if (!ret) return NULL; @@ -150,7 +148,7 @@ static primitives_YUV_benchmark* primitives_YUV_benchmark_init(primitives_YUV_be if (!ret->outputBuffer) goto fail; - for (i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { BYTE* buf = ret->channels[i] = calloc(roi->width, roi->height); if (!buf) @@ -172,12 +170,11 @@ static BOOL primitives_YUV_benchmark_run(primitives_YUV_benchmark* bench, primit { ULONGLONG dueDate = 0; const BYTE* channels[3] = { 0 }; - size_t i = 0; pstatus_t status = 0; *computations = 0; - for (i = 0; i < 3; i++) + for (size_t i = 0; i < 3; i++) channels[i] = bench->channels[i]; /* do a first dry run to initialize cache and such */ @@ -202,7 +199,6 @@ static BOOL primitives_YUV_benchmark_run(primitives_YUV_benchmark* bench, primit static BOOL primitives_autodetect_best(primitives_t* prims) { - size_t x = 0; BOOL ret = FALSE; UINT64 benchDuration = 150; /* 150 ms */ struct prim_benchmark @@ -245,7 +241,7 @@ static BOOL primitives_autodetect_best(primitives_t* prims) return FALSE; WLog_DBG(TAG, "primitives benchmark result:"); - for (x = 0; x < ARRAYSIZE(testcases); x++) + for (size_t x = 0; x < ARRAYSIZE(testcases); x++) { struct prim_benchmark* cur = &testcases[x]; cur->prims = primitives_get_by_type(cur->flags); diff --git a/libfreerdp/primitives/test/TestPrimitivesAlphaComp.c b/libfreerdp/primitives/test/TestPrimitivesAlphaComp.c index ab6bc4467..fc00bb352 100644 --- a/libfreerdp/primitives/test/TestPrimitivesAlphaComp.c +++ b/libfreerdp/primitives/test/TestPrimitivesAlphaComp.c @@ -92,12 +92,9 @@ static UINT32 colordist(UINT32 c1, UINT32 c2) static BOOL check(const BYTE* pSrc1, UINT32 src1Step, const BYTE* pSrc2, UINT32 src2Step, BYTE* pDst, UINT32 dstStep, UINT32 width, UINT32 height) { - UINT32 x = 0; - UINT32 y = 0; - - for (y = 0; y < height; ++y) + for (UINT32 y = 0; y < height; ++y) { - for (x = 0; x < width; ++x) + for (UINT32 x = 0; x < width; ++x) { UINT32 s1 = *PIXEL(pSrc1, src1Step, x, y); UINT32 s2 = *PIXEL(pSrc2, src2Step, x, y); @@ -124,7 +121,6 @@ static BOOL test_alphaComp_func(void) BYTE ALIGN(src2[SRC2_WIDTH * SRC2_HEIGHT * 4]) = { 0 }; BYTE ALIGN(dst1[DST_WIDTH * DST_HEIGHT * 4]) = { 0 }; UINT32* ptr = NULL; - UINT32 i = 0; winpr_RAND(src1, sizeof(src1)); /* Special-case the first two values */ src1[0] &= 0x00FFFFFFU; @@ -133,7 +129,7 @@ static BOOL test_alphaComp_func(void) /* Set the second operand to fully-opaque. */ ptr = (UINT32*)src2; - for (i = 0; i < sizeof(src2) / 4; ++i) + for (UINT32 i = 0; i < sizeof(src2) / 4; ++i) *ptr++ |= 0xFF000000U; status = generic->alphaComp_argb(src1, 4 * SRC1_WIDTH, src2, 4 * SRC2_WIDTH, dst1, @@ -167,7 +163,6 @@ static int test_alphaComp_speed(void) BYTE ALIGN(dst1[DST_WIDTH * DST_HEIGHT]) = { 0 }; char testStr[256] = { 0 }; UINT32* ptr = NULL; - UINT32 i = 0; testStr[0] = '\0'; winpr_RAND(src1, sizeof(src1)); /* Special-case the first two values */ @@ -177,7 +172,7 @@ static int test_alphaComp_speed(void) /* Set the second operand to fully-opaque. */ ptr = (UINT32*)src2; - for (i = 0; i < sizeof(src2) / 4; ++i) + for (UINT32 i = 0; i < sizeof(src2) / 4; ++i) *ptr++ |= 0xFF000000U; if (!speed_test("add16s", "aligned", g_Iterations, (speed_test_fkt)generic->alphaComp_argb, diff --git a/libfreerdp/primitives/test/TestPrimitivesAndOr.c b/libfreerdp/primitives/test/TestPrimitivesAndOr.c index 28baf6cc4..29469a594 100644 --- a/libfreerdp/primitives/test/TestPrimitivesAndOr.c +++ b/libfreerdp/primitives/test/TestPrimitivesAndOr.c @@ -26,12 +26,11 @@ static BOOL test_and_32u_impl(const char* name, __andC_32u_t fkt, const UINT32* src, const UINT32 val, UINT32* dst, size_t size) { - size_t i = 0; pstatus_t status = fkt(src, val, dst, size); if (status != PRIMITIVES_SUCCESS) return FALSE; - for (i = 0; i < size; ++i) + for (size_t i = 0; i < size; ++i) { if (dst[i] != (src[i] & val)) { @@ -91,9 +90,7 @@ static BOOL test_and_32u_speed(void) /* ========================================================================= */ static BOOL check(const UINT32* src, const UINT32* dst, UINT32 size, UINT32 value) { - UINT32 i = 0; - - for (i = 0; i < size; ++i) + for (UINT32 i = 0; i < size; ++i) { if (dst[i] != (src[i] | value)) { diff --git a/libfreerdp/primitives/test/TestPrimitivesColors.c b/libfreerdp/primitives/test/TestPrimitivesColors.c index 3cc2651f9..1b98916b4 100644 --- a/libfreerdp/primitives/test/TestPrimitivesColors.c +++ b/libfreerdp/primitives/test/TestPrimitivesColors.c @@ -27,7 +27,6 @@ static BOOL test_RGBToRGB_16s8u_P3AC4R_func(prim_size_t roi, DWORD DstFormat) INT16* b = NULL; BYTE* out1 = NULL; BYTE* out2 = NULL; - UINT64 i = 0; BOOL failed = FALSE; const INT16* ptrs[3]; const UINT32 rgbStride = roi.width * 2; @@ -47,11 +46,9 @@ static BOOL test_RGBToRGB_16s8u_P3AC4R_func(prim_size_t roi, DWORD DstFormat) #if 0 { - UINT32 x, y; - - for (y = 0; y < roi.height; y++) + for (UINT32 y = 0; y < roi.height; y++) { - for (x = 0; x < roi.width; x++) + for (UINT32 x = 0; x < roi.width; x++) { r[y * roi.width + x] = 0x01; g[y * roi.width + x] = 0x02; @@ -84,7 +81,7 @@ static BOOL test_RGBToRGB_16s8u_P3AC4R_func(prim_size_t roi, DWORD DstFormat) if (memcmp(out1, out2, dstStride * roi.height) != 0) { - for (i = 0; i < roi.width * roi.height; ++i) + for (UINT64 i = 0; i < roi.width * roi.height; ++i) { const UINT32 o1 = FreeRDPReadColor(out1 + 4 * i, DstFormat); const UINT32 o2 = FreeRDPReadColor(out2 + 4 * i, DstFormat); @@ -129,14 +126,13 @@ static BOOL test_RGBToRGB_16s8u_P3AC4R_speed(void) INT16 ALIGN(g[4096 + 1]); INT16 ALIGN(b[4096 + 1]); UINT32 ALIGN(dst[4096 + 1]); - int i = 0; INT16* ptrs[3]; winpr_RAND(r, sizeof(r)); winpr_RAND(g, sizeof(g)); winpr_RAND(b, sizeof(b)); /* clear upper bytes */ - for (i = 0; i < 4096; ++i) + for (int i = 0; i < 4096; ++i) { r[i] &= 0x00FFU; g[i] &= 0x00FFU; @@ -174,7 +170,6 @@ static BOOL test_yCbCrToRGB_16s16s_P3P3_func(void) INT16 ALIGN(r2[4096]) = { 0 }; INT16 ALIGN(g2[4096]) = { 0 }; INT16 ALIGN(b2[4096]) = { 0 }; - int i = 0; const INT16* in[3]; INT16* out1[3]; INT16* out2[3]; @@ -184,7 +179,7 @@ static BOOL test_yCbCrToRGB_16s16s_P3P3_func(void) winpr_RAND(cr, sizeof(cr)); /* Normalize to 11.5 fixed radix */ - for (i = 0; i < 4096; ++i) + for (int i = 0; i < 4096; ++i) { y[i] &= 0x1FE0U; cb[i] &= 0x1FE0U; @@ -210,7 +205,7 @@ static BOOL test_yCbCrToRGB_16s16s_P3P3_func(void) if (status != PRIMITIVES_SUCCESS) return FALSE; - for (i = 0; i < 4096; ++i) + for (int i = 0; i < 4096; ++i) { if ((ABS(r1[i] - r2[i]) > 1) || (ABS(g1[i] - g2[i]) > 1) || (ABS(b1[i] - b2[i]) > 1)) { @@ -234,7 +229,6 @@ static int test_yCbCrToRGB_16s16s_P3P3_speed(void) INT16 ALIGN(r[4096]); INT16 ALIGN(g[4096]); INT16 ALIGN(b[4096]); - int i = 0; const INT16* input[3]; INT16* output[3]; winpr_RAND(y, sizeof(y)); @@ -242,7 +236,7 @@ static int test_yCbCrToRGB_16s16s_P3P3_speed(void) winpr_RAND(cr, sizeof(cr)); /* Normalize to 11.5 fixed radix */ - for (i = 0; i < 4096; ++i) + for (int i = 0; i < 4096; ++i) { y[i] &= 0x1FE0U; cb[i] &= 0x1FE0U; @@ -270,13 +264,12 @@ int TestPrimitivesColors(int argc, char* argv[]) const DWORD formats[] = { PIXEL_FORMAT_ARGB32, PIXEL_FORMAT_XRGB32, PIXEL_FORMAT_ABGR32, PIXEL_FORMAT_XBGR32, PIXEL_FORMAT_RGBA32, PIXEL_FORMAT_RGBX32, PIXEL_FORMAT_BGRA32, PIXEL_FORMAT_BGRX32 }; - DWORD x = 0; prim_size_t roi = { 1920 / 4, 1080 / 4 }; WINPR_UNUSED(argc); WINPR_UNUSED(argv); prim_test_setup(FALSE); - for (x = 0; x < sizeof(formats) / sizeof(formats[0]); x++) + for (UINT32 x = 0; x < sizeof(formats) / sizeof(formats[0]); x++) { if (!test_RGBToRGB_16s8u_P3AC4R_func(roi, formats[x])) return 1; diff --git a/libfreerdp/primitives/test/TestPrimitivesCopy.c b/libfreerdp/primitives/test/TestPrimitivesCopy.c index db29305b1..8c681f25e 100644 --- a/libfreerdp/primitives/test/TestPrimitivesCopy.c +++ b/libfreerdp/primitives/test/TestPrimitivesCopy.c @@ -24,26 +24,20 @@ static BOOL test_copy8u_func(void) { primitives_t* prims = primitives_get(); BYTE ALIGN(data[COPY_TESTSIZE + 15]) = { 0 }; - int i = 0; - int soff = 0; winpr_RAND(data, sizeof(data)); - for (soff = 0; soff < 16; ++soff) + for (int soff = 0; soff < 16; ++soff) { - int doff = 0; - - for (doff = 0; doff < 16; ++doff) + for (int doff = 0; doff < 16; ++doff) { - int length = 0; - - for (length = 1; length <= COPY_TESTSIZE - doff; ++length) + for (int length = 1; length <= COPY_TESTSIZE - doff; ++length) { BYTE ALIGN(dest[COPY_TESTSIZE + 15]) = { 0 }; if (prims->copy_8u(data + soff, dest + doff, length) != PRIMITIVES_SUCCESS) return FALSE; - for (i = 0; i < length; ++i) + for (int i = 0; i < length; ++i) { if (dest[i + doff] != data[i + soff]) { diff --git a/libfreerdp/primitives/test/TestPrimitivesSet.c b/libfreerdp/primitives/test/TestPrimitivesSet.c index 00acc24c7..c6cefcc79 100644 --- a/libfreerdp/primitives/test/TestPrimitivesSet.c +++ b/libfreerdp/primitives/test/TestPrimitivesSet.c @@ -20,9 +20,7 @@ /* ------------------------------------------------------------------------- */ static BOOL check8(const BYTE* src, UINT32 length, UINT32 offset, BYTE value) { - UINT32 i = 0; - - for (i = 0; i < length; ++i) + for (UINT32 i = 0; i < length; ++i) { if (src[offset + i] != value) { @@ -39,15 +37,13 @@ static BOOL check8(const BYTE* src, UINT32 length, UINT32 offset, BYTE value) static BOOL test_set8u_func(void) { pstatus_t status = 0; - UINT32 off = 0; - for (off = 0; off < 16; ++off) + for (UINT32 off = 0; off < 16; ++off) { - UINT32 len = 0; BYTE dest[1024]; memset(dest, 3, sizeof(dest)); - for (len = 1; len < 48 - off; ++len) + for (UINT32 len = 1; len < 48 - off; ++len) { status = generic->set_8u(0xa5, dest + off, len); @@ -59,13 +55,12 @@ static BOOL test_set8u_func(void) } } - for (off = 0; off < 16; ++off) + for (UINT32 off = 0; off < 16; ++off) { - UINT32 len = 0; BYTE dest[1024]; memset(dest, 3, sizeof(dest)); - for (len = 1; len < 48 - off; ++len) + for (UINT32 len = 1; len < 48 - off; ++len) { status = optimized->set_8u(0xa5, dest + off, len); @@ -85,9 +80,8 @@ static BOOL test_set8u_speed(void) { BYTE dest[1024]; BYTE value = 0; - UINT32 x = 0; - for (x = 0; x < 16; x++) + for (UINT32 x = 0; x < 16; x++) { winpr_RAND(&value, sizeof(value)); @@ -101,9 +95,7 @@ static BOOL test_set8u_speed(void) static BOOL check32s(const INT32* src, UINT32 length, UINT32 offset, INT32 value) { - UINT32 i = 0; - - for (i = 0; i < length; ++i) + for (UINT32 i = 0; i < length; ++i) { if (src[offset + i] != value) { @@ -121,15 +113,13 @@ static BOOL check32s(const INT32* src, UINT32 length, UINT32 offset, INT32 value static BOOL test_set32s_func(void) { pstatus_t status = 0; - UINT32 off = 0; const INT32 value = -0x12345678; - for (off = 0; off < 16; ++off) + for (UINT32 off = 0; off < 16; ++off) { - UINT32 len = 0; INT32 dest[1024] = { 0 }; - for (len = 1; len < 48 - off; ++len) + for (UINT32 len = 1; len < 48 - off; ++len) { status = generic->set_32s(value, dest + off, len); @@ -141,12 +131,11 @@ static BOOL test_set32s_func(void) } } - for (off = 0; off < 16; ++off) + for (UINT32 off = 0; off < 16; ++off) { - UINT32 len = 0; INT32 dest[1024] = { 0 }; - for (len = 1; len < 48 - off; ++len) + for (UINT32 len = 1; len < 48 - off; ++len) { status = optimized->set_32s(value, dest + off, len); @@ -163,9 +152,7 @@ static BOOL test_set32s_func(void) static BOOL check32u(const UINT32* src, UINT32 length, UINT32 offset, UINT32 value) { - UINT32 i = 0; - - for (i = 0; i < length; ++i) + for (UINT32 i = 0; i < length; ++i) { if (src[offset + i] != value) { @@ -183,15 +170,13 @@ static BOOL check32u(const UINT32* src, UINT32 length, UINT32 offset, UINT32 val static BOOL test_set32u_func(void) { pstatus_t status = 0; - UINT32 off = 0; const UINT32 value = 0xABCDEF12; - for (off = 0; off < 16; ++off) + for (UINT32 off = 0; off < 16; ++off) { - UINT32 len = 0; UINT32 dest[1024] = { 0 }; - for (len = 1; len < 48 - off; ++len) + for (UINT32 len = 1; len < 48 - off; ++len) { status = generic->set_32u(value, dest + off, len); @@ -203,12 +188,11 @@ static BOOL test_set32u_func(void) } } - for (off = 0; off < 16; ++off) + for (UINT32 off = 0; off < 16; ++off) { - UINT32 len = 0; UINT32 dest[1024] = { 0 }; - for (len = 1; len < 48 - off; ++len) + for (UINT32 len = 1; len < 48 - off; ++len) { status = optimized->set_32u(value, dest + off, len); @@ -228,9 +212,8 @@ static BOOL test_set32u_speed(void) { UINT32 dest[1024]; BYTE value = 0; - UINT32 x = 0; - for (x = 0; x < 16; x++) + for (UINT32 x = 0; x < 16; x++) { winpr_RAND(&value, sizeof(value)); @@ -247,9 +230,8 @@ static BOOL test_set32s_speed(void) { INT32 dest[1024]; BYTE value = 0; - UINT32 x = 0; - for (x = 0; x < 16; x++) + for (UINT32 x = 0; x < 16; x++) { winpr_RAND(&value, sizeof(value)); diff --git a/libfreerdp/primitives/test/TestPrimitivesYCbCr.c b/libfreerdp/primitives/test/TestPrimitivesYCbCr.c index 8a2b3a788..64e7f9168 100644 --- a/libfreerdp/primitives/test/TestPrimitivesYCbCr.c +++ b/libfreerdp/primitives/test/TestPrimitivesYCbCr.c @@ -1490,12 +1490,11 @@ static int test_bmp_cmp_count(const BYTE* mem1, const BYTE* mem2, int size, int { int error = 0; int count = 0; - int index = 0; size /= 4; mem1 += channel; mem2 += channel; - for (index = 0; index < size; index++) + for (int index = 0; index < size; index++) { if (*mem1 != *mem2) { @@ -1517,12 +1516,11 @@ static int test_bmp_cmp_dump(const BYTE* actual, const BYTE* expected, int size, { int error[3]; int count = 0; - int index = 0; size /= 4; actual += channel; expected += channel; - for (index = 0; index < size; index++) + for (int index = 0; index < size; index++) { if (*actual != *expected) { @@ -1727,7 +1725,6 @@ int TestPrimitivesYCbCr(int argc, char* argv[]) PIXEL_FORMAT_BGRA32, PIXEL_FORMAT_BGRX32 }; const primitives_t* prims = primitives_get(); const primitives_t* generics = primitives_get_generic(); - UINT32 x = 0; WINPR_UNUSED(argv); @@ -1735,7 +1732,7 @@ int TestPrimitivesYCbCr(int argc, char* argv[]) { { /* Do content comparison. */ - for (x = 0; x < sizeof(formats) / sizeof(formats[0]); x++) + for (UINT32 x = 0; x < sizeof(formats) / sizeof(formats[0]); x++) { prim_size_t roi = { 64, 64 }; int rc = 0; @@ -1777,7 +1774,7 @@ int TestPrimitivesYCbCr(int argc, char* argv[]) roi.height %= 2048 / 4; } while (roi.height < 16); - for (x = 0; x < sizeof(formats) / sizeof(formats[0]); x++) + for (size_t x = 0; x < sizeof(formats) / sizeof(formats[0]); x++) { int rc = 0; printf("----------------------- GENERIC %s [%" PRIu32 "x%" PRIu32 @@ -1808,7 +1805,7 @@ int TestPrimitivesYCbCr(int argc, char* argv[]) { prim_size_t roi = { 1928 / 8, 1080 / 8 }; - for (x = 0; x < sizeof(formats) / sizeof(formats[0]); x++) + for (size_t x = 0; x < sizeof(formats) / sizeof(formats[0]); x++) { int rc = 0; printf("----------------------- GENERIC %s [%" PRIu32 "x%" PRIu32 diff --git a/libfreerdp/primitives/test/TestPrimitivesYCoCg.c b/libfreerdp/primitives/test/TestPrimitivesYCoCg.c index 06a31df40..11d05a81e 100644 --- a/libfreerdp/primitives/test/TestPrimitivesYCoCg.c +++ b/libfreerdp/primitives/test/TestPrimitivesYCoCg.c @@ -29,8 +29,6 @@ static BOOL test_YCoCgRToRGB_8u_AC4R_func(UINT32 width, UINT32 height) BYTE* out_sse = NULL; BYTE* in = NULL; BYTE* out_c = NULL; - UINT32 i = 0; - UINT32 x = 0; const UINT32 srcStride = width * 4; const UINT32 size = srcStride * height; const UINT32 formats[] = { PIXEL_FORMAT_ARGB32, PIXEL_FORMAT_ABGR32, PIXEL_FORMAT_RGBA32, @@ -46,7 +44,7 @@ static BOOL test_YCoCgRToRGB_8u_AC4R_func(UINT32 width, UINT32 height) winpr_RAND(in, size); - for (x = 0; x < sizeof(formats) / sizeof(formats[0]); x++) + for (size_t x = 0; x < sizeof(formats) / sizeof(formats[0]); x++) { const UINT32 format = formats[x]; const UINT32 dstStride = width * FreeRDPGetBytesPerPixel(format); @@ -71,7 +69,7 @@ static BOOL test_YCoCgRToRGB_8u_AC4R_func(UINT32 width, UINT32 height) if (memcmp(out_c, out_sse, dstStride * height) != 0) { - for (i = 0; i < width * height; ++i) + for (size_t i = 0; i < width * height; ++i) { const UINT32 c = FreeRDPReadColor(out_c + 4 * i, format); const UINT32 sse = FreeRDPReadColor(out_sse + 4 * i, format); @@ -117,9 +115,7 @@ int TestPrimitivesYCoCg(int argc, char* argv[]) /* Random resolution tests */ if (argc < 2) { - UINT32 x = 0; - - for (x = 0; x < 10; x++) + for (UINT32 x = 0; x < 10; x++) { UINT32 w = 0; UINT32 h = 0; diff --git a/libfreerdp/primitives/test/TestPrimitivesYUV.c b/libfreerdp/primitives/test/TestPrimitivesYUV.c index 46fba2efd..cd700518f 100644 --- a/libfreerdp/primitives/test/TestPrimitivesYUV.c +++ b/libfreerdp/primitives/test/TestPrimitivesYUV.c @@ -18,9 +18,7 @@ * differing by less than 2 abs equal. */ static BOOL similar(const BYTE* src, const BYTE* dst, size_t size) { - size_t x = 0; - - for (x = 0; x < size; x++) + for (size_t x = 0; x < size; x++) { int diff = src[x] - dst[x]; @@ -37,13 +35,12 @@ static BOOL similar(const BYTE* src, const BYTE* dst, size_t size) static BOOL similarRGB(const BYTE* src, const BYTE* dst, size_t size, UINT32 format, BOOL use444) { - size_t x = 0; const UINT32 bpp = FreeRDPGetBytesPerPixel(format); BYTE fill = PADDING_FILL_VALUE; if (!FreeRDPColorHasAlpha(format)) fill = 0xFF; - for (x = 0; x < size; x++) + for (size_t x = 0; x < size; x++) { const LONG maxDiff = 4; UINT32 sColor = 0; @@ -99,7 +96,6 @@ static void get_size(BOOL large, UINT32* width, UINT32* height) static BOOL check_padding(const BYTE* psrc, size_t size, size_t padding, const char* buffer) { - size_t x = 0; BOOL rc = TRUE; const BYTE* src = NULL; const BYTE* esrc = NULL; @@ -111,7 +107,7 @@ static BOOL check_padding(const BYTE* psrc, size_t size, size_t padding, const c src = psrc - halfPad; esrc = src + size + halfPad; - for (x = 0; x < halfPad; x++) + for (size_t x = 0; x < halfPad; x++) { const BYTE s = *src++; const BYTE d = *esrc++; @@ -189,9 +185,6 @@ static BOOL TestPrimitiveYUVCombine(primitives_t* prims, prim_size_t roi) const BYTE** cpv; BYTE** pv; } cnv; - UINT32 x = 0; - UINT32 y = 0; - UINT32 i = 0; UINT32 awidth = 0; UINT32 aheight = 0; BOOL rc = FALSE; @@ -222,7 +215,7 @@ static BOOL TestPrimitiveYUVCombine(primitives_t* prims, prim_size_t roi) if (!prims || !prims->YUV420CombineToYUV444) goto fail; - for (x = 0; x < 3; x++) + for (UINT32 x = 0; x < 3; x++) { size_t halfStride = ((x > 0) ? awidth / 2 : awidth); size_t size = aheight * awidth; @@ -287,7 +280,7 @@ static BOOL TestPrimitiveYUVCombine(primitives_t* prims, prim_size_t roi) PROFILER_EXIT(yuvCombine) - for (x = 0; x < 3; x++) + for (UINT32 x = 0; x < 3; x++) { size_t halfStride = ((x > 0) ? awidth / 2 : awidth); size_t size = aheight * awidth; @@ -315,7 +308,7 @@ static BOOL TestPrimitiveYUVCombine(primitives_t* prims, prim_size_t roi) PROFILER_EXIT(yuvSplit) - for (x = 0; x < 3; x++) + for (UINT32 x = 0; x < 3; x++) { size_t halfStride = ((x > 0) ? awidth / 2 : awidth); size_t size = aheight * awidth; @@ -331,9 +324,9 @@ static BOOL TestPrimitiveYUVCombine(primitives_t* prims, prim_size_t roi) goto fail; } - for (i = 0; i < 3; i++) + for (UINT32 i = 0; i < 3; i++) { - for (y = 0; y < roi.height; y++) + for (UINT32 y = 0; y < roi.height; y++) { UINT32 w = roi.width; UINT32 lstride = lumaStride[i]; @@ -378,7 +371,7 @@ fail: PROFILER_FREE(yuvCombine) PROFILER_FREE(yuvSplit) - for (x = 0; x < 3; x++) + for (UINT32 x = 0; x < 3; x++) { free_padding(yuv[x], padding); free_padding(luma[x], padding); @@ -398,8 +391,6 @@ static BOOL TestPrimitiveYUV(primitives_t* prims, prim_size_t roi, BOOL use444) BYTE** pv; } cnv; BOOL res = FALSE; - UINT32 x = 0; - UINT32 y = 0; UINT32 awidth = 0; UINT32 aheight = 0; BYTE* yuv[3] = { 0 }; @@ -460,11 +451,11 @@ static BOOL TestPrimitiveYUV(primitives_t* prims, prim_size_t roi, BOOL use444) if (!(yuv[2] = set_padding(uvsize, padding))) goto fail; - for (y = 0; y < roi.height; y++) + for (UINT32 y = 0; y < roi.height; y++) { BYTE* line = &rgb[y * stride]; - for (x = 0; x < roi.width; x++) + for (UINT32 x = 0; x < roi.width; x++) { line[x * 4 + 0] = 0x81; line[x * 4 + 1] = 0x33; @@ -477,7 +468,7 @@ static BOOL TestPrimitiveYUV(primitives_t* prims, prim_size_t roi, BOOL use444) yuv_step[1] = uvwidth; yuv_step[2] = uvwidth; - for (x = 0; x < ARRAYSIZE(formats); x++) + for (UINT32 x = 0; x < ARRAYSIZE(formats); x++) { pstatus_t rc = 0; const UINT32 DstFormat = formats[x]; @@ -574,7 +565,7 @@ static BOOL TestPrimitiveYUV(primitives_t* prims, prim_size_t roi, BOOL use444) (!check_padding(yuv[2], uvsize, padding, "V"))) goto fail; - for (y = 0; y < roi.height; y++) + for (UINT32 y = 0; y < roi.height; y++) { BYTE* srgb = &rgb[y * stride]; BYTE* drgb = &rgb_dst[y * stride]; @@ -648,9 +639,8 @@ static BOOL check_yuv420(BYTE** planes, UINT32 width, UINT32 height, UINT32 padd static BOOL check_for_mismatches(const BYTE* planeA, const BYTE* planeB, UINT32 size) { BOOL rc = FALSE; - UINT32 x = 0; - for (x = 0; x < size; x++) + for (UINT32 x = 0; x < size; x++) { const BYTE a = planeA[x]; const BYTE b = planeB[x]; @@ -697,9 +687,6 @@ static BOOL compare_yuv420(BYTE** planesA, BYTE** planesB, UINT32 width, UINT32 static BOOL TestPrimitiveRgbToLumaChroma(primitives_t* prims, prim_size_t roi, UINT32 version) { BOOL res = FALSE; - UINT32 x = 0; - UINT32 y = 0; - UINT32 cnt = 0; UINT32 awidth = 0; UINT32 aheight = 0; BYTE* luma[3] = { 0 }; @@ -777,11 +764,11 @@ static BOOL TestPrimitiveRgbToLumaChroma(primitives_t* prims, prim_size_t roi, U if (!allocate_yuv420(chromaGeneric, awidth, aheight, padding)) goto fail; - for (y = 0; y < roi.height; y++) + for (UINT32 y = 0; y < roi.height; y++) { BYTE* line = &rgb[y * stride]; - for (x = 0; x < roi.width; x++) + for (UINT32 x = 0; x < roi.width; x++) { #if 1 line[x * 4 + 0] = rand(); @@ -801,7 +788,7 @@ static BOOL TestPrimitiveRgbToLumaChroma(primitives_t* prims, prim_size_t roi, U yuv_step[1] = uvwidth; yuv_step[2] = uvwidth; - for (x = 0; x < sizeof(formats) / sizeof(formats[0]); x++) + for (UINT32 x = 0; x < sizeof(formats) / sizeof(formats[0]); x++) { pstatus_t rc = -1; const UINT32 DstFormat = formats[x]; @@ -809,7 +796,7 @@ static BOOL TestPrimitiveRgbToLumaChroma(primitives_t* prims, prim_size_t roi, U PROFILER_CREATE(rgbToYUV444, "RGBToYUV444-generic") PROFILER_CREATE(rgbToYUV444opt, "RGBToYUV444-optimized") - for (cnt = 0; cnt < 10; cnt++) + for (UINT32 cnt = 0; cnt < 10; cnt++) { PROFILER_ENTER(rgbToYUV444opt) rc = fkt(rgb, DstFormat, stride, luma, yuv_step, chroma, yuv_step, &roi); @@ -836,7 +823,7 @@ static BOOL TestPrimitiveRgbToLumaChroma(primitives_t* prims, prim_size_t roi, U goto loop_fail; } - for (cnt = 0; cnt < 10; cnt++) + for (UINT32 cnt = 0; cnt < 10; cnt++) { PROFILER_ENTER(rgbToYUV444) rc = gen(rgb, DstFormat, stride, lumaGeneric, yuv_step, chromaGeneric, yuv_step, &roi); @@ -891,14 +878,13 @@ fail: int TestPrimitivesYUV(int argc, char* argv[]) { BOOL large = (argc > 1); - UINT32 x = 0; int rc = -1; WINPR_UNUSED(argc); WINPR_UNUSED(argv); prim_test_setup(FALSE); primitives_t* prims = primitives_get(); - for (x = 0; x < 5; x++) + for (UINT32 x = 0; x < 5; x++) { prim_size_t roi; diff --git a/libfreerdp/primitives/test/prim_test.c b/libfreerdp/primitives/test/prim_test.c index d9d642de7..ede831625 100644 --- a/libfreerdp/primitives/test/prim_test.c +++ b/libfreerdp/primitives/test/prim_test.c @@ -98,12 +98,10 @@ void prim_test_setup(BOOL performance) BOOL speed_test(const char* name, const char* dsc, UINT32 iterations, pstatus_t (*fkt_generic)(), pstatus_t (*optimised)(), ...) { - UINT32 i = 0; - if (!name || !generic || !optimised || (iterations == 0)) return FALSE; - for (i = 0; i < iterations; i++) + for (UINT32 i = 0; i < iterations; i++) { } diff --git a/libfreerdp/utils/smartcard_call.c b/libfreerdp/utils/smartcard_call.c index f8d9991b2..a957e0882 100644 --- a/libfreerdp/utils/smartcard_call.c +++ b/libfreerdp/utils/smartcard_call.c @@ -592,7 +592,6 @@ static LONG smartcard_RemoveReaderFromGroupW_Call(scard_call_context* smartcard, static LONG smartcard_LocateCardsA_Call(scard_call_context* smartcard, wStream* out, SMARTCARD_OPERATION* operation) { - UINT32 x = 0; LONG status = 0; LocateCards_Return ret = { 0 }; LocateCardsA_Call* call = NULL; @@ -616,7 +615,7 @@ static LONG smartcard_LocateCardsA_Call(scard_call_context* smartcard, wStream* return STATUS_NO_MEMORY; } - for (x = 0; x < ret.cReaders; x++) + for (UINT32 x = 0; x < ret.cReaders; x++) { ret.rgReaderStates[x].dwCurrentState = call->rgReaderStates[x].dwCurrentState; ret.rgReaderStates[x].dwEventState = call->rgReaderStates[x].dwEventState; @@ -636,7 +635,6 @@ static LONG smartcard_LocateCardsA_Call(scard_call_context* smartcard, wStream* static LONG smartcard_LocateCardsW_Call(scard_call_context* smartcard, wStream* out, SMARTCARD_OPERATION* operation) { - UINT32 x = 0; LONG status = 0; LocateCards_Return ret = { 0 }; LocateCardsW_Call* call = NULL; @@ -660,7 +658,7 @@ static LONG smartcard_LocateCardsW_Call(scard_call_context* smartcard, wStream* return STATUS_NO_MEMORY; } - for (x = 0; x < ret.cReaders; x++) + for (UINT32 x = 0; x < ret.cReaders; x++) { ret.rgReaderStates[x].dwCurrentState = call->rgReaderStates[x].dwCurrentState; ret.rgReaderStates[x].dwEventState = call->rgReaderStates[x].dwEventState; @@ -889,9 +887,7 @@ static LONG smartcard_GetStatusChangeA_Call(scard_call_context* smartcard, wStre SMARTCARD_OPERATION* operation) { LONG status = STATUS_NO_MEMORY; - UINT32 index = 0; DWORD dwTimeOut = 0; - DWORD x = 0; const DWORD dwTimeStep = 100; GetStatusChange_Return ret = { 0 }; GetStatusChangeA_Call* call = NULL; @@ -913,7 +909,7 @@ static LONG smartcard_GetStatusChangeA_Call(scard_call_context* smartcard, wStre goto fail; } - for (x = 0; x < MAX(1, dwTimeOut);) + for (UINT32 x = 0; x < MAX(1, dwTimeOut);) { if (call->cReaders > 0) memcpy(rgReaderStates, call->rgReaderStates, @@ -929,7 +925,7 @@ static LONG smartcard_GetStatusChangeA_Call(scard_call_context* smartcard, wStre } scard_log_status_error(TAG, "SCardGetStatusChangeA", ret.ReturnCode); - for (index = 0; index < ret.cReaders; index++) + for (UINT32 index = 0; index < ret.cReaders; index++) { const SCARD_READERSTATEA* cur = &rgReaderStates[index]; ReaderState_Return* rout = &ret.rgReaderStates[index]; @@ -953,9 +949,7 @@ static LONG smartcard_GetStatusChangeW_Call(scard_call_context* smartcard, wStre SMARTCARD_OPERATION* operation) { LONG status = STATUS_NO_MEMORY; - UINT32 index = 0; DWORD dwTimeOut = 0; - DWORD x = 0; const DWORD dwTimeStep = 100; GetStatusChange_Return ret = { 0 }; GetStatusChangeW_Call* call = NULL; @@ -977,7 +971,7 @@ static LONG smartcard_GetStatusChangeW_Call(scard_call_context* smartcard, wStre goto fail; } - for (x = 0; x < MAX(1, dwTimeOut);) + for (UINT32 x = 0; x < MAX(1, dwTimeOut);) { if (call->cReaders > 0) memcpy(rgReaderStates, call->rgReaderStates, @@ -995,7 +989,7 @@ static LONG smartcard_GetStatusChangeW_Call(scard_call_context* smartcard, wStre } scard_log_status_error(TAG, "SCardGetStatusChangeW", ret.ReturnCode); - for (index = 0; index < ret.cReaders; index++) + for (UINT32 index = 0; index < ret.cReaders; index++) { const SCARD_READERSTATEW* cur = &rgReaderStates[index]; ReaderState_Return* rout = &ret.rgReaderStates[index]; @@ -1460,9 +1454,6 @@ static LONG smartcard_LocateCardsByATRA_Call(scard_call_context* smartcard, wStr SMARTCARD_OPERATION* operation) { LONG status = 0; - DWORD i = 0; - DWORD j = 0; - DWORD k = 0; GetStatusChange_Return ret = { 0 }; LPSCARD_READERSTATEA state = NULL; LPSCARD_READERSTATEA states = NULL; @@ -1477,7 +1468,7 @@ static LONG smartcard_LocateCardsByATRA_Call(scard_call_context* smartcard, wStr if (!states) return STATUS_NO_MEMORY; - for (i = 0; i < call->cReaders; i++) + for (UINT32 i = 0; i < call->cReaders; i++) { states[i].szReader = (LPSTR)call->rgReaderStates[i].szReader; states[i].dwCurrentState = call->rgReaderStates[i].dwCurrentState; @@ -1490,11 +1481,11 @@ static LONG smartcard_LocateCardsByATRA_Call(scard_call_context* smartcard, wStr 0x000001F4, states, call->cReaders); scard_log_status_error(TAG, "SCardGetStatusChangeA", status); - for (i = 0; i < call->cAtrs; i++) + for (UINT32 i = 0; i < call->cAtrs; i++) { - for (j = 0; j < call->cReaders; j++) + for (UINT32 j = 0; j < call->cReaders; j++) { - for (k = 0; k < call->rgAtrMasks[i].cbAtr; k++) + for (UINT32 k = 0; k < call->rgAtrMasks[i].cbAtr; k++) { if ((call->rgAtrMasks[i].rgbAtr[k] & call->rgAtrMasks[i].rgbMask[k]) != (states[j].rgbAtr[k] & call->rgAtrMasks[i].rgbMask[k])) @@ -1519,7 +1510,7 @@ static LONG smartcard_LocateCardsByATRA_Call(scard_call_context* smartcard, wStr return STATUS_NO_MEMORY; } - for (i = 0; i < ret.cReaders; i++) + for (UINT32 i = 0; i < ret.cReaders; i++) { state = &states[i]; ret.rgReaderStates[i].dwCurrentState = state->dwCurrentState; diff --git a/libfreerdp/utils/smartcard_operations.c b/libfreerdp/utils/smartcard_operations.c index 7aad8539f..fd7be8210 100644 --- a/libfreerdp/utils/smartcard_operations.c +++ b/libfreerdp/utils/smartcard_operations.c @@ -828,8 +828,7 @@ LONG smartcard_irp_device_control_decode(wStream* s, UINT32 CompletionId, UINT32 static void free_reader_states_a(LPSCARD_READERSTATEA rgReaderStates, UINT32 cReaders) { - UINT32 x = 0; - for (x = 0; x < cReaders; x++) + for (UINT32 x = 0; x < cReaders; x++) { SCARD_READERSTATEA* state = &rgReaderStates[x]; free(state->szReader); @@ -840,8 +839,7 @@ static void free_reader_states_a(LPSCARD_READERSTATEA rgReaderStates, UINT32 cRe static void free_reader_states_w(LPSCARD_READERSTATEW rgReaderStates, UINT32 cReaders) { - UINT32 x = 0; - for (x = 0; x < cReaders; x++) + for (UINT32 x = 0; x < cReaders; x++) { SCARD_READERSTATEW* state = &rgReaderStates[x]; free(state->szReader); diff --git a/libfreerdp/utils/smartcard_pack.c b/libfreerdp/utils/smartcard_pack.c index 03ae82217..58536ca3b 100644 --- a/libfreerdp/utils/smartcard_pack.c +++ b/libfreerdp/utils/smartcard_pack.c @@ -327,7 +327,6 @@ static LONG smartcard_ndr_read_u(wStream* s, UUID** data) static char* smartcard_convert_string_list(const void* in, size_t bytes, BOOL unicode) { - size_t index = 0; size_t length = 0; union { @@ -365,7 +364,7 @@ static char* smartcard_convert_string_list(const void* in, size_t bytes, BOOL un free(mszA); return NULL; } - for (index = 0; index < length - 1; index++) + for (size_t index = 0; index < length - 1; index++) { if (mszA[index] == '\0') mszA[index] = ','; @@ -409,7 +408,6 @@ static char* smartcard_msz_dump_w(const WCHAR* msz, size_t len, char* buffer, si static char* smartcard_array_dump(const void* pd, size_t len, char* buffer, size_t bufferLen) { const BYTE* data = pd; - size_t x = 0; int rc = 0; char* start = buffer; @@ -426,7 +424,7 @@ static char* smartcard_array_dump(const void* pd, size_t len, char* buffer, size buffer += rc; bufferLen -= (size_t)rc; - for (x = 0; x < len; x++) + for (size_t x = 0; x < len; x++) { rc = _snprintf(buffer, bufferLen, "%02X", data[x]); if ((rc < 0) || ((size_t)rc > bufferLen)) @@ -517,7 +515,6 @@ static void smartcard_trace_list_reader_groups_call(const ListReaderGroups_Call* static void smartcard_trace_get_status_change_w_call(const GetStatusChangeW_Call* call) { - UINT32 index = 0; char* szEventState = NULL; char* szCurrentState = NULL; @@ -530,7 +527,7 @@ static void smartcard_trace_get_status_change_w_call(const GetStatusChangeW_Call WLog_LVL(TAG, g_LogLevel, "dwTimeOut: 0x%08" PRIX32 " cReaders: %" PRIu32 "", call->dwTimeOut, call->cReaders); - for (index = 0; index < call->cReaders; index++) + for (UINT32 index = 0; index < call->cReaders; index++) { const LPSCARD_READERSTATEW readerState = &call->rgReaderStates[index]; char szReaderA[1024] = { 0 }; @@ -593,7 +590,6 @@ static void smartcard_trace_list_readers_call(const ListReaders_Call* call, BOOL static void smartcard_trace_locate_cards_by_atr_a_call(const LocateCardsByATRA_Call* call) { - UINT32 index = 0; char* szEventState = NULL; char* szCurrentState = NULL; @@ -603,7 +599,7 @@ static void smartcard_trace_locate_cards_by_atr_a_call(const LocateCardsByATRA_C WLog_LVL(TAG, g_LogLevel, "LocateCardsByATRA_Call {"); smartcard_log_context(TAG, &call->handles.hContext); - for (index = 0; index < call->cReaders; index++) + for (UINT32 index = 0; index < call->cReaders; index++) { char buffer[1024]; const LPSCARD_READERSTATEA readerState = &call->rgReaderStates[index]; @@ -758,7 +754,6 @@ static void smartcard_trace_list_readers_return(const ListReaders_Return* ret, B static void smartcard_trace_get_status_change_return(const GetStatusChange_Return* ret, BOOL unicode) { - UINT32 index = 0; char* szEventState = NULL; char* szCurrentState = NULL; @@ -770,7 +765,7 @@ static void smartcard_trace_get_status_change_return(const GetStatusChange_Retur SCardGetErrorString(ret->ReturnCode), ret->ReturnCode); WLog_LVL(TAG, g_LogLevel, " cReaders: %" PRIu32 "", ret->cReaders); - for (index = 0; index < ret->cReaders; index++) + for (UINT32 index = 0; index < ret->cReaders; index++) { char buffer[1024]; const ReaderState_Return* rgReaderState = &(ret->rgReaderStates[index]); @@ -999,7 +994,6 @@ static void smartcard_trace_transmit_call(const Transmit_Call* call) static void smartcard_trace_locate_cards_by_atr_w_call(const LocateCardsByATRW_Call* call) { - UINT32 index = 0; char* szEventState = NULL; char* szCurrentState = NULL; @@ -1009,7 +1003,7 @@ static void smartcard_trace_locate_cards_by_atr_w_call(const LocateCardsByATRW_C WLog_LVL(TAG, g_LogLevel, "LocateCardsByATRW_Call {"); smartcard_log_context(TAG, &call->handles.hContext); - for (index = 0; index < call->cReaders; index++) + for (UINT32 index = 0; index < call->cReaders; index++) { char buffer[1024] = { 0 }; char tmp[1024] = { 0 }; @@ -2176,7 +2170,6 @@ LONG smartcard_unpack_hcard_and_disposition_call(wStream* s, HCardAndDisposition static void smartcard_trace_get_status_change_a_call(const GetStatusChangeA_Call* call) { - UINT32 index = 0; char* szEventState = NULL; char* szCurrentState = NULL; LPSCARD_READERSTATEA readerState = NULL; @@ -2190,7 +2183,7 @@ static void smartcard_trace_get_status_change_a_call(const GetStatusChangeA_Call WLog_LVL(TAG, g_LogLevel, "dwTimeOut: 0x%08" PRIX32 " cReaders: %" PRIu32 "", call->dwTimeOut, call->cReaders); - for (index = 0; index < call->cReaders; index++) + for (UINT32 index = 0; index < call->cReaders; index++) { readerState = &call->rgReaderStates[index]; WLog_LVL(TAG, g_LogLevel, "\t[%" PRIu32 "]: szReader: %s cbAtr: %" PRIu32 "", index, @@ -2211,7 +2204,6 @@ static void smartcard_trace_get_status_change_a_call(const GetStatusChangeA_Call static LONG smartcard_unpack_reader_state_a(wStream* s, LPSCARD_READERSTATEA* ppcReaders, UINT32 cReaders, UINT32* ptrIndex) { - UINT32 index = 0; UINT32 len = 0; LONG status = SCARD_E_NO_MEMORY; LPSCARD_READERSTATEA rgReaderStates = NULL; @@ -2232,7 +2224,7 @@ static LONG smartcard_unpack_reader_state_a(wStream* s, LPSCARD_READERSTATEA* pp goto fail; status = ERROR_INVALID_DATA; - for (index = 0; index < cReaders; index++) + for (UINT32 index = 0; index < cReaders; index++) { UINT32 ptr = UINT32_MAX; LPSCARD_READERSTATEA readerState = &rgReaderStates[index]; @@ -2253,7 +2245,7 @@ static LONG smartcard_unpack_reader_state_a(wStream* s, LPSCARD_READERSTATEA* pp Stream_Read(s, readerState->rgbAtr, 36); /* rgbAtr [0..36] (36 bytes) */ } - for (index = 0; index < cReaders; index++) + for (UINT32 index = 0; index < cReaders; index++) { LPSCARD_READERSTATEA readerState = &rgReaderStates[index]; @@ -2271,7 +2263,7 @@ static LONG smartcard_unpack_reader_state_a(wStream* s, LPSCARD_READERSTATEA* pp fail: if (rgReaderStates) { - for (index = 0; index < cReaders; index++) + for (UINT32 index = 0; index < cReaders; index++) { LPSCARD_READERSTATEA readerState = &rgReaderStates[index]; free(readerState->szReader); @@ -2285,7 +2277,6 @@ fail: static LONG smartcard_unpack_reader_state_w(wStream* s, LPSCARD_READERSTATEW* ppcReaders, UINT32 cReaders, UINT32* ptrIndex) { - UINT32 index = 0; UINT32 len = 0; LONG status = SCARD_E_NO_MEMORY; LPSCARD_READERSTATEW rgReaderStates = NULL; @@ -2308,7 +2299,7 @@ static LONG smartcard_unpack_reader_state_w(wStream* s, LPSCARD_READERSTATEW* pp goto fail; status = ERROR_INVALID_DATA; - for (index = 0; index < cReaders; index++) + for (UINT32 index = 0; index < cReaders; index++) { UINT32 ptr = UINT32_MAX; LPSCARD_READERSTATEW readerState = &rgReaderStates[index]; @@ -2329,7 +2320,7 @@ static LONG smartcard_unpack_reader_state_w(wStream* s, LPSCARD_READERSTATEW* pp Stream_Read(s, readerState->rgbAtr, 36); /* rgbAtr [0..36] (36 bytes) */ } - for (index = 0; index < cReaders; index++) + for (UINT32 index = 0; index < cReaders; index++) { LPSCARD_READERSTATEW readerState = &rgReaderStates[index]; @@ -2348,7 +2339,7 @@ static LONG smartcard_unpack_reader_state_w(wStream* s, LPSCARD_READERSTATEW* pp fail: if (rgReaderStates) { - for (index = 0; index < cReaders; index++) + for (UINT32 index = 0; index < cReaders; index++) { LPSCARD_READERSTATEW readerState = &rgReaderStates[index]; free(readerState->szReader); diff --git a/libfreerdp/utils/string.c b/libfreerdp/utils/string.c index e67f3880d..3ee73f1f6 100644 --- a/libfreerdp/utils/string.c +++ b/libfreerdp/utils/string.c @@ -24,7 +24,6 @@ char* rdp_redirection_flags_to_string(UINT32 flags, char* buffer, size_t size) { - size_t x = 0; struct map_t { UINT32 flag; @@ -49,7 +48,7 @@ char* rdp_redirection_flags_to_string(UINT32 flags, char* buffer, size_t size) { LB_TARGET_CERTIFICATE, "LB_TARGET_CERTIFICATE" }, }; - for (x = 0; x < ARRAYSIZE(map); x++) + for (size_t x = 0; x < ARRAYSIZE(map); x++) { const struct map_t* cur = &map[x]; if (flags & cur->flag) diff --git a/libfreerdp/utils/test/TestPodArrays.c b/libfreerdp/utils/test/TestPodArrays.c index 0074fb7a0..6c88b538c 100644 --- a/libfreerdp/utils/test/TestPodArrays.c +++ b/libfreerdp/utils/test/TestPodArrays.c @@ -61,7 +61,6 @@ POD_ARRAYS_IMPL(BasicStruct, basicstruct) int TestPodArrays(int argc, char* argv[]) { int rc = -1; - UINT32 i = 0; UINT32 sum = 0; UINT32 foreach_index = 0; ArrayUINT32 uint32s = { 0 }; @@ -73,7 +72,7 @@ int TestPodArrays(int argc, char* argv[]) array_uint32_init(&uint32s); array_basicstruct_init(&basicStructs); - for (i = 0; i < 10; i++) + for (UINT32 i = 0; i < 10; i++) if (!array_uint32_append(&uint32s, i)) goto fail; diff --git a/libfreerdp/utils/test/TestRingBuffer.c b/libfreerdp/utils/test/TestRingBuffer.c index a24612e06..8e88a65fb 100644 --- a/libfreerdp/utils/test/TestRingBuffer.c +++ b/libfreerdp/utils/test/TestRingBuffer.c @@ -27,14 +27,10 @@ static BOOL test_overlaps(void) RingBuffer rb; DataChunk chunks[2]; BYTE bytes[200]; - size_t i = 0; - size_t k = 0; - int x = 0; int nchunks = 0; - int j = 0; int counter = 0; - for (i = 0; i < sizeof(bytes); i++) + for (size_t i = 0; i < sizeof(bytes); i++) bytes[i] = (BYTE)i; ringbuffer_init(&rb, 5); @@ -51,9 +47,9 @@ static BOOL test_overlaps(void) if (nchunks != 2 || chunks[0].size != 3 || chunks[1].size != 1) goto error; - for (x = 0, j = 2; x < nchunks; x++) + for (int x = 0, j = 2; x < nchunks; x++) { - for (k = 0; k < chunks[x].size; k++, j++) + for (size_t k = 0; k < chunks[x].size; k++, j++) { if (chunks[x].data[k] != (BYTE)j) goto error; @@ -88,7 +84,6 @@ int TestRingBuffer(int argc, char* argv[]) int testNo = 0; BYTE* tmpBuf = NULL; BYTE* rb_ptr = NULL; - int i = 0 /*, chunkNb, counter*/; DataChunk chunks[2]; WINPR_UNUSED(argc); @@ -104,7 +99,7 @@ int TestRingBuffer(int argc, char* argv[]) if (!tmpBuf) return -1; - for (i = 0; i < 50; i++) + for (int i = 0; i < 50; i++) tmpBuf[i] = (char)i; fprintf(stderr, "%d: basic tests...", ++testNo); @@ -130,7 +125,7 @@ int TestRingBuffer(int argc, char* argv[]) ringbuffer_commit_read_bytes(&ringBuffer, chunks[0].size); /* check retrieved bytes */ - for (i = 0; i < (int)chunks[0].size; i++) + for (size_t i = 0; i < chunks[0].size; i++) { if (chunks[0].data[i] != i % 5) { @@ -168,7 +163,7 @@ int TestRingBuffer(int argc, char* argv[]) fprintf(stderr, "ok\n"); fprintf(stderr, "%d: ensure_linear_write / read() shouldn't grow...", ++testNo); - for (i = 0; i < 1000; i++) + for (int i = 0; i < 1000; i++) { rb_ptr = ringbuffer_ensure_linear_write(&ringBuffer, 50); if (!rb_ptr) @@ -188,10 +183,10 @@ int TestRingBuffer(int argc, char* argv[]) // ringbuffer_commit_read_bytes(&ringBuffer, 25); } - for (i = 0; i < 1000; i++) + for (int i = 0; i < 1000; i++) ringbuffer_commit_read_bytes(&ringBuffer, 25); - for (i = 0; i < 1000; i++) + for (int i = 0; i < 1000; i++) ringbuffer_commit_read_bytes(&ringBuffer, 25); if (ringbuffer_capacity(&ringBuffer) != 10) @@ -203,7 +198,7 @@ int TestRingBuffer(int argc, char* argv[]) fprintf(stderr, "ok\n"); fprintf(stderr, "%d: free size is correctly computed...", ++testNo); - for (i = 0; i < 1000; i++) + for (int i = 0; i < 1000; i++) { ringbuffer_ensure_linear_write(&ringBuffer, 50); if (!ringbuffer_commit_written_bytes(&ringBuffer, 50)) diff --git a/rdtk/sample/rdtk_x11.c b/rdtk/sample/rdtk_x11.c index e3566ad40..dbcb12231 100644 --- a/rdtk/sample/rdtk_x11.c +++ b/rdtk/sample/rdtk_x11.c @@ -31,7 +31,6 @@ int main(int argc, char** argv) { GC gc = NULL; - int index = 0; int depth = 0; int x = 0; int y = 0; @@ -86,7 +85,7 @@ int main(int argc, char** argv) pfs = XListPixmapFormats(display, &pf_count); - for (index = 0; index < pf_count; index++) + for (int index = 0; index < pf_count; index++) { pf = &pfs[index]; diff --git a/scripts/LECHash.c b/scripts/LECHash.c index 947ff47b9..3464fe3fa 100644 --- a/scripts/LECHash.c +++ b/scripts/LECHash.c @@ -53,12 +53,9 @@ UINT16 minihash(UINT16 key) void buildhashtable(void) { - int i, j; - UINT16 h; - - for (i = 0; i < 293; i++) + for (int i = 0; i < 293; i++) { - h = hash(HuffCodeLEC[i]); + UINT16 h = hash(HuffCodeLEC[i]); if (HashTable[h] != 0xffff) { @@ -85,11 +82,10 @@ UINT16 getvalue(UINT16 huff) main() { - int i; buildhashtable(); printf("static UINT16 HuffIndexLEC[512] = {\n"); - for (i = 0; i < 512; i++) + for (int i = 0; i < 512; i++) { if (i == 511) printf("0x%04" PRIx16 " };\n", HashTable[i]); @@ -97,7 +93,7 @@ main() printf("0x%04" PRIx16 ", ", HashTable[i]); } - for (i = 0; i < 293; i++) + for (int i = 0; i < 293; i++) if (i != getvalue(HuffCodeLEC[i])) printf("Fail :( at %d : 0x%04" PRIx16 "\n", i, HuffCodeLEC[i]); diff --git a/scripts/LOMHash.c b/scripts/LOMHash.c index 616117d68..b3b97c309 100644 --- a/scripts/LOMHash.c +++ b/scripts/LOMHash.c @@ -24,12 +24,9 @@ BYTE minihash(UINT16 key) void buildhashtable(void) { - int i, j; - UINT16 h; - - for (i = 0; i < 32; i++) + for (int i = 0; i < 32; i++) { - h = hash(HuffCodeLOM[i]); + UINT16 h = hash(HuffCodeLOM[i]); if (HashTable[h] != 0xffff) { @@ -60,11 +57,10 @@ BYTE getvalue(UINT16 huff) main() { - int i; buildhashtable(); printf("static UINT16 HuffIndexLOM[32] = {\n"); - for (i = 0; i < 32; i++) + for (int i = 0; i < 32; i++) { if (i == 31) printf("0x%" PRIx16 " };\n", HashTable[i]); @@ -72,7 +68,7 @@ main() printf("0x%" PRIx16 ", ", HashTable[i]); } - for (i = 0; i < 32; i++) + for (int i = 0; i < 32; i++) if (i != getvalue(HuffCodeLOM[i])) printf("Fail :( at %d : 0x%04" PRIx16 " got %" PRIu8 "\n", i, HuffCodeLOM[i], getvalue(HuffCodeLOM[i])); diff --git a/server/Mac/mf_info.c b/server/Mac/mf_info.c index 7e014d9c6..ab523e148 100644 --- a/server/Mac/mf_info.c +++ b/server/Mac/mf_info.c @@ -124,7 +124,6 @@ void mf_info_peer_register(mfInfo* mfi, mfPeerContext* context) { if (mf_info_lock(mfi) > 0) { - int i; int peerId; if (mfi->peerCount == MF_INFO_MAXPEERS) @@ -144,7 +143,7 @@ void mf_info_peer_register(mfInfo* mfi, mfPeerContext* context) peerId = 0; - for (i = 0; i < MF_INFO_MAXPEERS; ++i) + for (int i = 0; i < MF_INFO_MAXPEERS; ++i) { // empty index will be our peer id if (mfi->peers[i] == NULL) diff --git a/server/Mac/mf_mountain_lion.c b/server/Mac/mf_mountain_lion.c index f754c7c7d..9db86b899 100644 --- a/server/Mac/mf_mountain_lion.c +++ b/server/Mac/mf_mountain_lion.c @@ -49,7 +49,6 @@ void (^streamHandler)(CGDisplayStreamFrameStatus, uint64_t, IOSurfaceRef, RFX_RECT rect; unsigned long offset_beg; unsigned long stride; - int i; rect.x = 0; rect.y = 0; @@ -65,7 +64,7 @@ void (^streamHandler)(CGDisplayStreamFrameStatus, uint64_t, IOSurfaceRef, stride = IOSurfaceGetBytesPerRow(frameSurface); // memcpy(localBuf, baseAddress + offset_beg, surflen); - for (i = 0; i < rect.height; i++) + for (int i = 0; i < rect.height; i++) { offset_beg = (stride * (rect.y + i) + (rect.x * 4)); memcpy(localBuf + offset_beg, baseAddress + offset_beg, rect.width * 4); @@ -217,7 +216,7 @@ int mf_mlion_get_dirty_region(RFX_RECT* invalid) int mf_mlion_peek_dirty_region(RFX_RECT* invalid) { - size_t num_rects, i; + size_t num_rects; CGRect dirtyRegion; const CGRect* rects = @@ -229,7 +228,7 @@ int mf_mlion_peek_dirty_region(RFX_RECT* invalid) } dirtyRegion = *rects; - for (i = 0; i < num_rects; i++) + for (size_t i = 0; i < num_rects; i++) { dirtyRegion = CGRectUnion(dirtyRegion, *(rects + i)); } diff --git a/server/Mac/mf_rdpsnd.c b/server/Mac/mf_rdpsnd.c index 63c208255..e1946f261 100644 --- a/server/Mac/mf_rdpsnd.c +++ b/server/Mac/mf_rdpsnd.c @@ -37,17 +37,17 @@ AQRecorderState recorderState; static void mf_peer_rdpsnd_activated(RdpsndServerContext* context) { OSStatus status; - int i, j; BOOL formatAgreed = FALSE; AUDIO_FORMAT* agreedFormat = NULL; // we should actually loop through the list of client formats here // and see if we can send the client something that it supports... WLog_DBG(TAG, "Client supports the following %d formats: ", context->num_client_formats); - for (i = 0; i < context->num_client_formats; i++) + int i = 0; + for (; i < context->num_client_formats; i++) { /* TODO: improve the way we agree on a format */ - for (j = 0; j < context->num_server_formats; j++) + for (int j = 0; j < context->num_server_formats; j++) { if ((context->client_formats[i].wFormatTag == context->server_formats[j].wFormatTag) && (context->client_formats[i].nChannels == context->server_formats[j].nChannels) && @@ -113,7 +113,7 @@ static void mf_peer_rdpsnd_activated(RdpsndServerContext* context) mf_rdpsnd_derive_buffer_size(recorderState.queue, &recorderState.dataFormat, 0.05, &recorderState.bufferByteSize); - for (i = 0; i < SND_NUMBUFFERS; ++i) + for (int i = 0; i < SND_NUMBUFFERS; ++i) { AudioQueueAllocateBuffer(recorderState.queue, recorderState.bufferByteSize, &recorderState.buffers[i]); diff --git a/server/Sample/sfreerdp.c b/server/Sample/sfreerdp.c index 57dda5d96..0cdd19d68 100644 --- a/server/Sample/sfreerdp.c +++ b/server/Sample/sfreerdp.c @@ -941,14 +941,13 @@ static BOOL tf_peer_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x static BOOL tf_peer_refresh_rect(rdpContext* context, BYTE count, const RECTANGLE_16* areas) { - BYTE i = 0; WINPR_UNUSED(context); WINPR_ASSERT(context); WINPR_ASSERT(areas || (count == 0)); WLog_DBG(TAG, "Client requested to refresh:"); - for (i = 0; i < count; i++) + for (BYTE i = 0; i < count; i++) { WLog_DBG(TAG, " (%" PRIu16 ", %" PRIu16 ") (%" PRIu16 ", %" PRIu16 ")", areas[i].left, areas[i].top, areas[i].right, areas[i].bottom); diff --git a/server/Windows/cli/wfreerdp.c b/server/Windows/cli/wfreerdp.c index bd8a0d1d7..efc1bf51b 100644 --- a/server/Windows/cli/wfreerdp.c +++ b/server/Windows/cli/wfreerdp.c @@ -50,12 +50,11 @@ int main(int argc, char* argv[]) freerdp_server_warn_unmaintained(argc, argv); BOOL screen_selected = FALSE; - int index; + int index = 1; wfServer* server; server = wfreerdp_server_new(); set_screen_id(0); // handle args - index = 1; errno = 0; while (index < argc) @@ -66,11 +65,10 @@ int main(int argc, char* argv[]) int width; int height; int bpp; - int i; WLog_INFO(TAG, "Detecting screens..."); WLog_INFO(TAG, "ID\tResolution\t\tName (Interface)"); - for (i = 0;; i++) + for (int i = 0;; i++) { _TCHAR name[128] = { 0 }; if (get_screen_info(i, name, ARRAYSIZE(name), &width, &height, &bpp) != 0) @@ -139,12 +137,11 @@ int main(int argc, char* argv[]) int width; int height; int bpp; - int i; WLog_INFO(TAG, "screen id not provided. attempting to detect..."); WLog_INFO(TAG, "Detecting screens..."); WLog_INFO(TAG, "ID\tResolution\t\tName (Interface)"); - for (i = 0;; i++) + for (int i = 0;; i++) { _TCHAR name[128] = { 0 }; if (get_screen_info(i, name, ARRAYSIZE(name), &width, &height, &bpp) != 0) diff --git a/server/Windows/wf_dxgi.c b/server/Windows/wf_dxgi.c index fe84d2d6e..899cb55e4 100644 --- a/server/Windows/wf_dxgi.c +++ b/server/Windows/wf_dxgi.c @@ -411,7 +411,6 @@ int wf_dxgi_releasePixelData(wfInfo* wfi) int wf_dxgi_getInvalidRegion(RECT* invalid) { - UINT i; HRESULT status; UINT dirty; UINT BufSize; @@ -474,7 +473,7 @@ int wf_dxgi_getInvalidRegion(RECT* invalid) pRect = (RECT*)DirtyRects; - for (i = 0; i < dirty; ++i) + for (UINT i = 0; i < dirty; ++i) { UnionRect(invalid, invalid, pRect); ++pRect; diff --git a/server/Windows/wf_info.c b/server/Windows/wf_info.c index 47c2d1f43..8a96814e7 100644 --- a/server/Windows/wf_info.c +++ b/server/Windows/wf_info.c @@ -193,7 +193,6 @@ wfInfo* wf_info_get_instance() BOOL wf_info_peer_register(wfInfo* wfi, wfPeerContext* context) { - int i; int peerId = 0; if (!wfi || !context) @@ -227,7 +226,7 @@ BOOL wf_info_peer_register(wfInfo* wfi, wfPeerContext* context) #endif // look through the array of peers until an empty slot - for (i = 0; i < FREERDP_SERVER_WIN_INFO_MAXPEERS; ++i) + for (int i = 0; i < FREERDP_SERVER_WIN_INFO_MAXPEERS; ++i) { // empty index will be our peer id if (wfi->peers[i] == NULL) @@ -308,11 +307,10 @@ void wf_info_find_invalid_region(wfInfo* wfi) #ifdef WITH_DXGI_1_2 wf_dxgi_getInvalidRegion(&wfi->invalid); #else - int i; GETCHANGESBUF* buf; buf = (GETCHANGESBUF*)wfi->changeBuffer; - for (i = wfi->lastUpdate; i != wfi->nextUpdate; i = (i + 1) % MAXCHANGES_BUF) + for (int i = wfi->lastUpdate; i != wfi->nextUpdate; i = (i + 1) % MAXCHANGES_BUF) { LPRECT lpR = &buf->buffer->pointrect[i].rect; diff --git a/server/Windows/wf_rdpsnd.c b/server/Windows/wf_rdpsnd.c index 7d2c2e260..b313c3508 100644 --- a/server/Windows/wf_rdpsnd.c +++ b/server/Windows/wf_rdpsnd.c @@ -45,16 +45,14 @@ static void wf_peer_rdpsnd_activated(RdpsndServerContext* context) { wfInfo* wfi; - size_t i; wfi = wf_info_get_instance(); wfi->agreed_format = NULL; WLog_DBG(TAG, "Client supports the following %d formats:", context->num_client_formats); - for (i = 0; i < context->num_client_formats; i++) + for (size_t i = 0; i < context->num_client_formats; i++) { - size_t j; // TODO: improve the way we agree on a format - for (j = 0; j < context->num_server_formats; j++) + for (size_t j = 0; j < context->num_server_formats; j++) { if ((context->client_formats[i].wFormatTag == context->server_formats[j].wFormatTag) && (context->client_formats[i].nChannels == context->server_formats[j].nChannels) && diff --git a/server/Windows/wf_update.c b/server/Windows/wf_update.c index 731ff0352..06d60c9b0 100644 --- a/server/Windows/wf_update.c +++ b/server/Windows/wf_update.c @@ -38,8 +38,6 @@ DWORD WINAPI wf_update_thread(LPVOID lpParam) { - int index; - int peerindex; DWORD fps; wfInfo* wfi; DWORD beg, end; @@ -62,9 +60,9 @@ DWORD WINAPI wf_update_thread(LPVOID lpParam) { wf_update_encode(wfi); // WLog_DBG(TAG, "Start of parallel sending"); - index = 0; + int index = 0; - for (peerindex = 0; peerindex < wfi->peerCount; peerindex++) + for (int peerindex = 0; peerindex < wfi->peerCount; peerindex++) { for (; index < FREERDP_SERVER_WIN_INFO_MAXPEERS; index++) { @@ -77,7 +75,7 @@ DWORD WINAPI wf_update_thread(LPVOID lpParam) } } - for (index = 0; index < wfi->activePeerCount; index++) + for (int index = 0; index < wfi->activePeerCount; index++) { // WLog_DBG(TAG, "Waiting for %d of %d", index + 1, wfi->activePeerCount); // WaitForSingleObject(wfi->updateSemaphore, INFINITE); diff --git a/server/Windows/wf_wasapi.c b/server/Windows/wf_wasapi.c index 753934606..3925f99b3 100644 --- a/server/Windows/wf_wasapi.c +++ b/server/Windows/wf_wasapi.c @@ -71,7 +71,7 @@ int wf_wasapi_get_device_string(LPWSTR pattern, LPWSTR* deviceStr) IMMDevice* pEndpoint = NULL; IPropertyStore* pProps = NULL; LPWSTR pwszID = NULL; - unsigned int count, i; + unsigned int count; CoInitialize(NULL); hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, &IID_IMMDeviceEnumerator, @@ -99,7 +99,7 @@ int wf_wasapi_get_device_string(LPWSTR pattern, LPWSTR* deviceStr) exit(1); } - for (i = 0; i < count; ++i) + for (unsigned int i = 0; i < count; ++i) { PROPVARIANT nameVar; PropVariantInit(&nameVar); diff --git a/server/common/server.c b/server/common/server.c index 30520bbaa..62f126f7c 100644 --- a/server/common/server.c +++ b/server/common/server.c @@ -92,7 +92,6 @@ size_t server_audin_get_formats(AUDIO_FORMAT** dst_formats) { WAVE_FORMAT_ALAW, 1, 22050, 22050, 2, 8, 0, NULL } }; const size_t nrDefaultFormatsMax = ARRAYSIZE(default_supported_audio_formats); - size_t x = 0; size_t nr_formats = 0; AUDIO_FORMAT* formats = audio_formats_new(nrDefaultFormatsMax); @@ -104,7 +103,7 @@ size_t server_audin_get_formats(AUDIO_FORMAT** dst_formats) if (!formats) goto fail; - for (x = 0; x < nrDefaultFormatsMax; x++) + for (size_t x = 0; x < nrDefaultFormatsMax; x++) { const AUDIO_FORMAT* format = &default_supported_audio_formats[x]; @@ -126,8 +125,6 @@ fail: size_t server_rdpsnd_get_formats(AUDIO_FORMAT** dst_formats) { - size_t x = 0; - size_t y = 0; /* Default supported audio formats */ static const AUDIO_FORMAT default_supported_audio_formats[] = { { WAVE_FORMAT_AAC_MS, 2, 44100, 176400, 4, 16, 0, NULL }, @@ -145,7 +142,8 @@ size_t server_rdpsnd_get_formats(AUDIO_FORMAT** dst_formats) if (!supported_audio_formats) goto fail; - for (x = 0; x < ARRAYSIZE(default_supported_audio_formats); x++) + size_t y = 0; + for (size_t x = 0; x < ARRAYSIZE(default_supported_audio_formats); x++) { const AUDIO_FORMAT* format = &default_supported_audio_formats[x]; diff --git a/server/proxy/channels/pf_channel_rdpdr.c b/server/proxy/channels/pf_channel_rdpdr.c index 31134878c..cb79266da 100644 --- a/server/proxy/channels/pf_channel_rdpdr.c +++ b/server/proxy/channels/pf_channel_rdpdr.c @@ -569,7 +569,6 @@ static UINT rdpdr_process_server_core_capability_request(pf_channel_client_conte wStream* s) { UINT status = CHANNEL_RC_OK; - UINT16 i = 0; UINT16 numCapabilities = 0; WINPR_ASSERT(rdpdr); @@ -581,7 +580,7 @@ static UINT rdpdr_process_server_core_capability_request(pf_channel_client_conte Stream_Read_UINT16(s, numCapabilities); Stream_Seek(s, 2); /* pad (2 bytes) */ - for (i = 0; i < numCapabilities; i++) + for (UINT16 i = 0; i < numCapabilities; i++) { RDPDR_CAPABILITY_HEADER header = { 0 }; UINT error = rdpdr_read_capset_header(rdpdr->log, s, &header); @@ -736,7 +735,6 @@ static UINT rdpdr_process_client_capability_response(pf_channel_server_context* const UINT16 packetid = PAKID_CORE_CLIENT_CAPABILITY; UINT status = CHANNEL_RC_OK; UINT16 numCapabilities = 0; - UINT16 x = 0; WINPR_ASSERT(rdpdr); if (!rdpdr_process_server_header(TRUE, rdpdr->log, s, component, packetid, 4)) @@ -745,7 +743,7 @@ static UINT rdpdr_process_client_capability_response(pf_channel_server_context* Stream_Read_UINT16(s, numCapabilities); Stream_Seek_UINT16(s); /* padding */ - for (x = 0; x < numCapabilities; x++) + for (UINT16 x = 0; x < numCapabilities; x++) { RDPDR_CAPABILITY_HEADER header = { 0 }; UINT error = rdpdr_read_capset_header(rdpdr->log, s, &header); @@ -1535,7 +1533,6 @@ static BOOL pf_channel_rdpdr_client_pass_message(pServerContext* ps, pClientCont static BOOL filter_smartcard_device_list_remove(pf_channel_server_context* rdpdr, wStream* s) { size_t pos = 0; - UINT32 x = 0; UINT32 count = 0; WINPR_ASSERT(rdpdr); @@ -1550,7 +1547,7 @@ static BOOL filter_smartcard_device_list_remove(pf_channel_server_context* rdpdr if (!Stream_CheckAndLogRequiredLengthOfSizeWLog(rdpdr->log, s, count, sizeof(UINT32))) return TRUE; - for (x = 0; x < count; x++) + for (UINT32 x = 0; x < count; x++) { UINT32 deviceID = 0; BYTE* dst = Stream_Pointer(s); diff --git a/server/proxy/pf_client.c b/server/proxy/pf_client.c index 942add55f..2f34f975b 100644 --- a/server/proxy/pf_client.c +++ b/server/proxy/pf_client.c @@ -409,13 +409,13 @@ static BOOL pf_client_load_channels(freerdp* instance) { CHANNEL_DEF* channels = (CHANNEL_DEF*)freerdp_settings_get_pointer_array_writable( settings, FreeRDP_ChannelDefArray, 0); - size_t x = 0; size_t size = freerdp_settings_get_uint32(settings, FreeRDP_ChannelCount); UINT32 id = MCS_GLOBAL_CHANNEL_ID + 1; WINPR_ASSERT(channels || (size == 0)); - for (x = 0; x < size;) + size_t x = 0; + for (; x < size;) { CHANNEL_DEF* cur = &channels[x]; proxyChannelDataEventInfo dev = { 0 }; diff --git a/server/proxy/pf_config.c b/server/proxy/pf_config.c index 397c5de14..bcce1b10a 100644 --- a/server/proxy/pf_config.c +++ b/server/proxy/pf_config.c @@ -797,17 +797,13 @@ out: static void pf_server_config_print_list(char** list, size_t count) { - size_t i = 0; - WINPR_ASSERT(list); - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) WLog_INFO(TAG, "\t\t- %s", list[i]); } void pf_server_config_print(const proxyConfig* config) { - size_t x = 0; - WINPR_ASSERT(config); WLog_INFO(TAG, "Proxy configuration:"); @@ -876,12 +872,12 @@ void pf_server_config_print(const proxyConfig* config) /* modules */ CONFIG_PRINT_SECTION_KEY(section_plugins, key_plugins_modules); - for (x = 0; x < config->ModulesCount; x++) + for (size_t x = 0; x < config->ModulesCount; x++) CONFIG_PRINT_STR(config, Modules[x]); /* Required plugins */ CONFIG_PRINT_SECTION_KEY(section_plugins, key_plugins_required); - for (x = 0; x < config->RequiredPluginsCount; x++) + for (size_t x = 0; x < config->RequiredPluginsCount; x++) CONFIG_PRINT_STR(config, RequiredPlugins[x]); CONFIG_PRINT_SECTION(section_certificates); diff --git a/server/proxy/pf_modules.c b/server/proxy/pf_modules.c index ab7439fa6..e3447cbc3 100644 --- a/server/proxy/pf_modules.c +++ b/server/proxy/pf_modules.c @@ -541,7 +541,6 @@ static void* new_plugin(const void* obj) proxyModule* pf_modules_new(const char* root_dir, const char** modules, size_t count) { - size_t i = 0; wObject* obj = NULL; char* path = NULL; proxyModule* module = calloc(1, sizeof(proxyModule)); @@ -594,7 +593,7 @@ proxyModule* pf_modules_new(const char* root_dir, const char** modules, size_t c if (winpr_PathFileExists(path)) WLog_DBG(TAG, "modules root directory: %s", path); - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) { char name[8192] = { 0 }; char* fullpath = NULL; diff --git a/server/proxy/pf_server.c b/server/proxy/pf_server.c index 1bf1ba3dd..545ab93a6 100644 --- a/server/proxy/pf_server.c +++ b/server/proxy/pf_server.c @@ -192,14 +192,13 @@ static BOOL pf_server_setup_channels(freerdp_peer* peer) { char** accepted_channels = NULL; size_t accepted_channels_count = 0; - size_t i = 0; pServerContext* ps = (pServerContext*)peer->context; accepted_channels = WTSGetAcceptedChannelNames(peer, &accepted_channels_count); if (!accepted_channels) return TRUE; - for (i = 0; i < accepted_channels_count; i++) + for (size_t i = 0; i < accepted_channels_count; i++) { pServerStaticChannelContext* channelContext = NULL; const char* cname = accepted_channels[i]; @@ -885,9 +884,7 @@ fail: static BOOL are_all_required_modules_loaded(proxyModule* module, const proxyConfig* config) { - size_t i = 0; - - for (i = 0; i < pf_config_required_plugins_count(config); i++) + for (size_t i = 0; i < pf_config_required_plugins_count(config); i++) { const char* plugin_name = pf_config_required_plugin(config, i); diff --git a/server/proxy/pf_utils.c b/server/proxy/pf_utils.c index 9a91d97b1..f8c17af9b 100644 --- a/server/proxy/pf_utils.c +++ b/server/proxy/pf_utils.c @@ -30,13 +30,12 @@ pf_utils_channel_mode pf_utils_get_channel_mode(const proxyConfig* config, const char* name) { pf_utils_channel_mode rc = PF_UTILS_CHANNEL_NOT_HANDLED; - size_t i = 0; BOOL found = FALSE; WINPR_ASSERT(config); WINPR_ASSERT(name); - for (i = 0; i < config->InterceptCount; i++) + for (size_t i = 0; i < config->InterceptCount; i++) { const char* channel_name = config->Intercept[i]; if (strcmp(name, channel_name) == 0) @@ -46,7 +45,7 @@ pf_utils_channel_mode pf_utils_get_channel_mode(const proxyConfig* config, const } } - for (i = 0; i < config->PassthroughCount; i++) + for (size_t i = 0; i < config->PassthroughCount; i++) { const char* channel_name = config->Passthrough[i]; if (strcmp(name, channel_name) == 0) diff --git a/server/shadow/Mac/mac_shadow.c b/server/shadow/Mac/mac_shadow.c index ddbda4173..ba6d2b05f 100644 --- a/server/shadow/Mac/mac_shadow.c +++ b/server/shadow/Mac/mac_shadow.c @@ -272,7 +272,6 @@ static int mac_shadow_capture_stop(macShadowSubsystem* subsystem) static int mac_shadow_capture_get_dirty_region(macShadowSubsystem* subsystem) { - size_t index; size_t numRects; const CGRect* rects; RECTANGLE_16 invalidRect; @@ -283,7 +282,7 @@ static int mac_shadow_capture_get_dirty_region(macShadowSubsystem* subsystem) if (!numRects) return -1; - for (index = 0; index < numRects; index++) + for (size_t index = 0; index < numRects; index++) { invalidRect.left = (UINT16)rects[index].origin.x; invalidRect.top = (UINT16)rects[index].origin.y; @@ -311,7 +310,6 @@ static int freerdp_image_copy_from_retina(BYTE* pDstData, DWORD DstFormat, int n { BYTE* pSrcPixel; BYTE* pDstPixel; - int x, y; int nSrcPad; int nDstPad; int srcBitsPerPixel; @@ -335,9 +333,9 @@ static int freerdp_image_copy_from_retina(BYTE* pDstData, DWORD DstFormat, int n pSrcPixel = &pSrcData[(nYSrc * nSrcStep) + (nXSrc * 4)]; pDstPixel = &pDstData[(nYDst * nDstStep) + (nXDst * 4)]; - for (y = 0; y < nHeight; y++) + for (int y = 0; y < nHeight; y++) { - for (x = 0; x < nWidth; x++) + for (int x = 0; x < nWidth; x++) { UINT32 R, G, B; UINT32 color; diff --git a/server/shadow/Win/win_dxgi.c b/server/shadow/Win/win_dxgi.c index 0d16db970..3c25a007a 100644 --- a/server/shadow/Win/win_dxgi.c +++ b/server/shadow/Win/win_dxgi.c @@ -682,7 +682,6 @@ int win_shadow_dxgi_get_next_frame(winShadowSubsystem* subsystem) int win_shadow_dxgi_get_invalid_region(winShadowSubsystem* subsystem) { - UINT i; HRESULT hr; POINT* pSrcPt; RECT* pDstRect; @@ -761,7 +760,7 @@ int win_shadow_dxgi_get_invalid_region(winShadowSubsystem* subsystem) numMoveRects = MoveRectsBufferSize / sizeof(DXGI_OUTDUPL_MOVE_RECT); - for (i = 0; i < numMoveRects; i++) + for (UINT i = 0; i < numMoveRects; i++) { pMoveRect = &pMoveRectBuffer[i]; pSrcPt = &(pMoveRect->SourcePoint); @@ -777,7 +776,7 @@ int win_shadow_dxgi_get_invalid_region(winShadowSubsystem* subsystem) numDirtyRects = DirtyRectsBufferSize / sizeof(RECT); - for (i = 0; i < numDirtyRects; i++) + for (UINT i = 0; i < numDirtyRects; i++) { pDirtyRect = &pDirtyRectsBuffer[i]; diff --git a/server/shadow/Win/win_rdp.c b/server/shadow/Win/win_rdp.c index 9d6680087..3db073da4 100644 --- a/server/shadow/Win/win_rdp.c +++ b/server/shadow/Win/win_rdp.c @@ -60,7 +60,6 @@ static BOOL shw_begin_paint(rdpContext* context) static BOOL shw_end_paint(rdpContext* context) { - int index; int ninvalid; HGDI_RGN cinvalid; RECTANGLE_16 invalidRect; @@ -71,7 +70,7 @@ static BOOL shw_end_paint(rdpContext* context) ninvalid = gdi->primary->hdc->hwnd->ninvalid; cinvalid = gdi->primary->hdc->hwnd->cinvalid; - for (index = 0; index < ninvalid; index++) + for (int index = 0; index < ninvalid; index++) { invalidRect.left = cinvalid[index].x; invalidRect.top = cinvalid[index].y; diff --git a/server/shadow/X11/x11_shadow.c b/server/shadow/X11/x11_shadow.c index 5d0af5be5..5c1fab18d 100644 --- a/server/shadow/X11/x11_shadow.c +++ b/server/shadow/X11/x11_shadow.c @@ -71,7 +71,6 @@ typedef struct static int x11_shadow_pam_conv(int num_msg, const struct pam_message** msg, struct pam_response** resp, void* appdata_ptr) { - int index = 0; int pam_status = PAM_CONV_ERR; SHADOW_PAM_AUTH_DATA* appdata = NULL; struct pam_response* response = NULL; @@ -82,7 +81,7 @@ static int x11_shadow_pam_conv(int num_msg, const struct pam_message** msg, if (!(response = (struct pam_response*)calloc((size_t)num_msg, sizeof(struct pam_response)))) return PAM_BUF_ERR; - for (index = 0; index < num_msg; index++) + for (int index = 0; index < num_msg; index++) { switch (msg[index]->msg_style) { @@ -114,7 +113,7 @@ static int x11_shadow_pam_conv(int num_msg, const struct pam_message** msg, return PAM_SUCCESS; out_fail: - for (index = 0; index < num_msg; ++index) + for (int index = 0; index < num_msg; ++index) { if (response[index].resp) { @@ -131,11 +130,10 @@ out_fail: static BOOL x11_shadow_pam_get_service_name(SHADOW_PAM_AUTH_INFO* info) { - size_t x = 0; const char* base = "/etc/pam.d"; const char* hints[] = { "lightdm", "gdm", "xdm", "login", "sshd" }; - for (x = 0; x < ARRAYSIZE(hints); x++) + for (size_t x = 0; x < ARRAYSIZE(hints); x++) { char path[MAX_PATH]; const char* hint = hints[x]; @@ -413,7 +411,6 @@ static int x11_shadow_pointer_position_update(x11ShadowSubsystem* subsystem) rdpShadowServer* server = NULL; SHADOW_MSG_OUT_POINTER_POSITION_UPDATE templateMsg; int count = 0; - size_t index = 0; if (!subsystem || !subsystem->common.server || !subsystem->common.server->clients) return -1; @@ -424,7 +421,7 @@ static int x11_shadow_pointer_position_update(x11ShadowSubsystem* subsystem) server = subsystem->common.server; ArrayList_Lock(server->clients); - for (index = 0; index < ArrayList_Count(server->clients); index++) + for (size_t index = 0; index < ArrayList_Count(server->clients); index++) { SHADOW_MSG_OUT_POINTER_POSITION_UPDATE* msg = NULL; rdpShadowClient* client = (rdpShadowClient*)ArrayList_GetItem(server->clients, index); @@ -485,7 +482,6 @@ static int x11_shadow_query_cursor(x11ShadowSubsystem* subsystem, BOOL getImage) int x = 0; int y = 0; int n = 0; - int k = 0; rdpShadowServer* server = NULL; rdpShadowSurface* surface = NULL; server = subsystem->common.server; @@ -520,7 +516,7 @@ static int x11_shadow_query_cursor(x11ShadowSubsystem* subsystem, BOOL getImage) n = ci->width * ci->height; pDstPixel = (UINT32*)subsystem->cursorPixels; - for (k = 0; k < n; k++) + for (int k = 0; k < n; k++) { /* XFixesCursorImage.pixels is in *unsigned long*, which may be 8 bytes */ *pDstPixel++ = (UINT32)ci->pixels[k]; @@ -612,8 +608,6 @@ static void x11_shadow_validate_region(x11ShadowSubsystem* subsystem, int x, int static int x11_shadow_blend_cursor(x11ShadowSubsystem* subsystem) { - UINT32 x = 0; - UINT32 y = 0; UINT32 nXSrc = 0; UINT32 nYSrc = 0; INT64 nXDst = 0; @@ -682,12 +676,12 @@ static int x11_shadow_blend_cursor(x11ShadowSubsystem* subsystem) pDstData = surface->data; nDstStep = surface->scanline; - for (y = 0; y < nHeight; y++) + for (int y = 0; y < nHeight; y++) { const BYTE* pSrcPixel = &pSrcData[((nYSrc + y) * nSrcStep) + (nXSrc * 4)]; BYTE* pDstPixel = &pDstData[((nYDst + y) * nDstStep) + (nXDst * 4)]; - for (x = 0; x < nWidth; x++) + for (int x = 0; x < nWidth; x++) { B = *pSrcPixel++; G = *pSrcPixel++; @@ -1223,8 +1217,7 @@ UINT32 x11_shadow_enum_monitors(MONITOR_DEF* monitors, UINT32 maxMonitors) if (screens && (numMonitors > 0)) { - int index = 0; - for (index = 0; index < numMonitors; index++) + for (int index = 0; index < numMonitors; index++) { MONITOR_DEF* monitor = &monitors[index]; const XineramaScreenInfo* screen = &screens[index]; @@ -1261,7 +1254,6 @@ UINT32 x11_shadow_enum_monitors(MONITOR_DEF* monitors, UINT32 maxMonitors) static int x11_shadow_subsystem_init(rdpShadowSubsystem* sub) { - int i = 0; int pf_count = 0; int vi_count = 0; int nextensions = 0; @@ -1291,7 +1283,7 @@ static int x11_shadow_subsystem_init(rdpShadowSubsystem* sub) if (!extensions || (nextensions < 0)) return -1; - for (i = 0; i < nextensions; i++) + for (int i = 0; i < nextensions; i++) { if (strcmp(extensions[i], "Composite") == 0) subsystem->composite = TRUE; @@ -1310,7 +1302,7 @@ static int x11_shadow_subsystem_init(rdpShadowSubsystem* sub) return -1; } - for (i = 0; i < pf_count; i++) + for (int i = 0; i < pf_count; i++) { pf = pfs + i; @@ -1334,7 +1326,7 @@ static int x11_shadow_subsystem_init(rdpShadowSubsystem* sub) return -1; } - for (i = 0; i < vi_count; i++) + for (int i = 0; i < vi_count; i++) { vi = vis + i; diff --git a/server/shadow/shadow_capture.c b/server/shadow/shadow_capture.c index 19bb3e587..4711dede2 100644 --- a/server/shadow/shadow_capture.c +++ b/server/shadow/shadow_capture.c @@ -85,9 +85,6 @@ int shadow_capture_compare(BYTE* pData1, UINT32 nStep1, UINT32 nWidth, UINT32 nH BOOL allEqual = 0; UINT32 tw = 0; UINT32 th = 0; - UINT32 tx = 0; - UINT32 ty = 0; - UINT32 k = 0; UINT32 nrow = 0; UINT32 ncol = 0; UINT32 l = 0; @@ -113,14 +110,14 @@ int shadow_capture_compare(BYTE* pData1, UINT32 nStep1, UINT32 nWidth, UINT32 nH t = nrow + 1; b = 0; - for (ty = 0; ty < nrow; ty++) + for (UINT32 ty = 0; ty < nrow; ty++) { th = ((ty + 1) == nrow) ? (nHeight % 16) : 16; if (!th) th = 16; - for (tx = 0; tx < ncol; tx++) + for (UINT32 tx = 0; tx < ncol; tx++) { equal = TRUE; tw = ((tx + 1) == ncol) ? (nWidth % 16) : 16; @@ -131,7 +128,7 @@ int shadow_capture_compare(BYTE* pData1, UINT32 nStep1, UINT32 nWidth, UINT32 nH p1 = &pData1[(ty * 16 * nStep1) + (tx * 16 * 4)]; p2 = &pData2[(ty * 16 * nStep2) + (tx * 16 * 4)]; - for (k = 0; k < th; k++) + for (UINT32 k = 0; k < th; k++) { if (memcmp(p1, p2, tw * 4) != 0) { @@ -200,24 +197,24 @@ int shadow_capture_compare(BYTE* pData1, UINT32 nStep1, UINT32 nWidth, UINT32 nH return 1; } - for (tx = 0; tx < ncol; tx++) + for (UINT32 tx = 0; tx < ncol; tx++) sprintf_s(&col_str[tx], size - tx, "-"); WLog_INFO(TAG, "%s", col_str); - for (tx = 0; tx < ncol; tx++) + for (UINT32 tx = 0; tx < ncol; tx++) sprintf_s(&col_str[tx], size - tx, "%c", cols[tx] ? 'O' : 'X'); WLog_INFO(TAG, "%s", col_str); - for (tx = 0; tx < ncol; tx++) + for (UINT32 tx = 0; tx < ncol; tx++) sprintf_s(&col_str[tx], size - tx, "-"); WLog_INFO(TAG, "%s", col_str); - for (ty = 0; ty < nrow; ty++) + for (UINT32 ty = 0; ty < nrow; ty++) { - for (tx = 0; tx < ncol; tx++) + for (UINT32 tx = 0; tx < ncol; tx++) sprintf_s(&col_str[tx], size - tx, "%c", cols[tx] ? 'O' : 'X'); WLog_INFO(TAG, "%s", col_str); diff --git a/server/shadow/shadow_client.c b/server/shadow/shadow_client.c index 9f8695aa5..0fd52363e 100644 --- a/server/shadow/shadow_client.c +++ b/server/shadow/shadow_client.c @@ -276,7 +276,6 @@ fail: static INLINE void shadow_client_mark_invalid(rdpShadowClient* client, UINT32 numRects, const RECTANGLE_16* rects) { - UINT32 index = 0; RECTANGLE_16 screenRegion; rdpSettings* settings = NULL; @@ -291,7 +290,7 @@ static INLINE void shadow_client_mark_invalid(rdpShadowClient* client, UINT32 nu /* Mark client invalid region. No rectangle means full screen */ if (numRects > 0) { - for (index = 0; index < numRects; index++) + for (UINT32 index = 0; index < numRects; index++) { region16_union_rect(&(client->invalidRegion), &(client->invalidRegion), &rects[index]); } @@ -530,11 +529,10 @@ static INLINE void shadow_client_convert_rects(rdpShadowClient* client, RECTANGL if (client->server->shareSubRect) { - UINT32 i = 0; UINT16 offsetX = client->server->subRect.left; UINT16 offsetY = client->server->subRect.top; - for (i = 0; i < numRects; i++) + for (UINT32 i = 0; i < numRects; i++) { const RECTANGLE_16* s = &src[i]; RECTANGLE_16* d = &dst[i]; @@ -806,7 +804,6 @@ static BOOL shadow_client_caps_test_version(RdpgfxServerContext* context, rdpSha BOOL h264, const RDPGFX_CAPSET* capsSets, UINT32 capsSetCount, UINT32 capsVersion, UINT* rc) { - UINT32 index = 0; const rdpSettings* srvSettings = NULL; rdpSettings* clientSettings = NULL; @@ -825,7 +822,7 @@ static BOOL shadow_client_caps_test_version(RdpgfxServerContext* context, rdpSha if (shadow_are_caps_filtered(srvSettings, capsVersion)) return FALSE; - for (index = 0; index < capsSetCount; index++) + for (UINT32 index = 0; index < capsSetCount; index++) { const RDPGFX_CAPSET* currentCaps = &capsSets[index]; @@ -896,7 +893,6 @@ static BOOL shadow_client_caps_test_version(RdpgfxServerContext* context, rdpSha static UINT shadow_client_rdpgfx_caps_advertise(RdpgfxServerContext* context, const RDPGFX_CAPS_ADVERTISE_PDU* capsAdvertise) { - UINT16 index = 0; UINT rc = ERROR_INTERNAL_ERROR; const rdpSettings* srvSettings = NULL; rdpSettings* clientSettings = NULL; @@ -969,7 +965,7 @@ static UINT shadow_client_rdpgfx_caps_advertise(RdpgfxServerContext* context, if (!shadow_are_caps_filtered(srvSettings, RDPGFX_CAPVERSION_81)) { - for (index = 0; index < capsAdvertise->capsSetCount; index++) + for (UINT32 index = 0; index < capsAdvertise->capsSetCount; index++) { const RDPGFX_CAPSET* currentCaps = &capsAdvertise->capsSets[index]; @@ -1009,7 +1005,7 @@ static UINT shadow_client_rdpgfx_caps_advertise(RdpgfxServerContext* context, if (!shadow_are_caps_filtered(srvSettings, RDPGFX_CAPVERSION_8)) { - for (index = 0; index < capsAdvertise->capsSetCount; index++) + for (UINT32 index = 0; index < capsAdvertise->capsSetCount; index++) { const RDPGFX_CAPSET* currentCaps = &capsAdvertise->capsSets[index]; @@ -1761,7 +1757,6 @@ static BOOL shadow_client_send_surface_update(rdpShadowClient* client, SHADOW_GF BYTE* pSrcData = NULL; UINT32 nSrcStep = 0; UINT32 SrcFormat = 0; - UINT32 index = 0; UINT32 numRects = 0; const RECTANGLE_16* rects = NULL; @@ -1788,7 +1783,7 @@ static BOOL shadow_client_send_surface_update(rdpShadowClient* client, SHADOW_GF EnterCriticalSection(&surface->lock); rects = region16_rects(&(surface->invalidRegion), &numRects); - for (index = 0; index < numRects; index++) + for (UINT32 index = 0; index < numRects; index++) region16_union_rect(&invalidRegion, &invalidRegion, &rects[index]); surfaceRect.left = 0; @@ -2560,7 +2555,6 @@ int shadow_client_boardcast_msg(rdpShadowServer* server, void* context, UINT32 t wMessage message = { 0 }; rdpShadowClient* client = NULL; int count = 0; - size_t index = 0; WINPR_ASSERT(server); WINPR_ASSERT(msg); @@ -2577,7 +2571,7 @@ int shadow_client_boardcast_msg(rdpShadowServer* server, void* context, UINT32 t WINPR_ASSERT(server->clients); ArrayList_Lock(server->clients); - for (index = 0; index < ArrayList_Count(server->clients); index++) + for (size_t index = 0; index < ArrayList_Count(server->clients); index++) { client = (rdpShadowClient*)ArrayList_GetItem(server->clients, index); @@ -2597,14 +2591,13 @@ int shadow_client_boardcast_quit(rdpShadowServer* server, int nExitCode) { wMessageQueue* queue = NULL; int count = 0; - size_t index = 0; WINPR_ASSERT(server); WINPR_ASSERT(server->clients); ArrayList_Lock(server->clients); - for (index = 0; index < ArrayList_Count(server->clients); index++) + for (size_t index = 0; index < ArrayList_Count(server->clients); index++) { queue = ((rdpShadowClient*)ArrayList_GetItem(server->clients, index))->MsgQueue; diff --git a/server/shadow/shadow_encoder.c b/server/shadow/shadow_encoder.c index 1ecc43e3e..fc1747cd3 100644 --- a/server/shadow/shadow_encoder.c +++ b/server/shadow/shadow_encoder.c @@ -80,9 +80,6 @@ UINT32 shadow_encoder_create_frame_id(rdpShadowEncoder* encoder) static int shadow_encoder_init_grid(rdpShadowEncoder* encoder) { - UINT32 i = 0; - UINT32 j = 0; - UINT32 k = 0; UINT32 tileSize = 0; UINT32 tileCount = 0; encoder->gridWidth = ((encoder->width + (encoder->maxTileWidth - 1)) / encoder->maxTileWidth); @@ -100,11 +97,11 @@ static int shadow_encoder_init_grid(rdpShadowEncoder* encoder) if (!encoder->grid) return -1; - for (i = 0; i < encoder->gridHeight; i++) + for (UINT32 i = 0; i < encoder->gridHeight; i++) { - for (j = 0; j < encoder->gridWidth; j++) + for (UINT32 j = 0; j < encoder->gridWidth; j++) { - k = (i * encoder->gridWidth) + j; + UINT32 k = (i * encoder->gridWidth) + j; encoder->grid[k] = &(encoder->gridBuffer[k * tileSize]); } } diff --git a/server/shadow/shadow_mcevent.c b/server/shadow/shadow_mcevent.c index e9a524943..4609cee35 100644 --- a/server/shadow/shadow_mcevent.c +++ b/server/shadow/shadow_mcevent.c @@ -110,7 +110,6 @@ static void _Publish(rdpShadowMultiClientEvent* event) { wArrayList* subscribers = NULL; struct rdp_shadow_multiclient_subscriber* subscriber = NULL; - size_t i = 0; subscribers = event->subscribers; @@ -118,7 +117,7 @@ static void _Publish(rdpShadowMultiClientEvent* event) /* Count subscribing clients */ ArrayList_Lock(subscribers); - for (i = 0; i < ArrayList_Count(subscribers); i++) + for (size_t i = 0; i < ArrayList_Count(subscribers); i++) { subscriber = (struct rdp_shadow_multiclient_subscriber*)ArrayList_GetItem(subscribers, i); /* Set flag to subscriber: I acknowledge and please handle */ diff --git a/server/shadow/shadow_server.c b/server/shadow/shadow_server.c index 474554046..067dcc676 100644 --- a/server/shadow/shadow_server.c +++ b/server/shadow/shadow_server.c @@ -459,7 +459,6 @@ int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** a if (arg && (arg->Flags & COMMAND_LINE_ARGUMENT_PRESENT)) { - UINT32 index = 0; UINT32 numMonitors = 0; MONITOR_DEF monitors[16] = { 0 }; numMonitors = shadow_enum_monitors(monitors, 16); @@ -478,7 +477,7 @@ int shadow_server_parse_command_line(rdpShadowServer* server, int argc, char** a { /* List monitors */ - for (index = 0; index < numMonitors; index++) + for (UINT32 index = 0; index < numMonitors; index++) { const MONITOR_DEF* monitor = &monitors[index]; const INT64 width = monitor->right - monitor->left + 1; @@ -644,7 +643,6 @@ int shadow_server_start(rdpShadowServer* server) strnlen(bind_address, sizeof(bind_address))) != 0); if (!ipc) { - size_t x = 0; size_t count = 0; char** list = CommandLineParseCommaSeparatedValuesEx(NULL, server->ipcSocket, &count); if (!list || (count <= 1)) @@ -665,7 +663,7 @@ int shadow_server_start(rdpShadowServer* server) } WINPR_ASSERT(list || (count == 0)); - for (x = 1; x < count; x++) + for (size_t x = 1; x < count; x++) { BOOL success = open_port(server, list[x]); if (!success) diff --git a/server/shadow/shadow_subsystem.c b/server/shadow/shadow_subsystem.c index 22951354f..ca73c7232 100644 --- a/server/shadow/shadow_subsystem.c +++ b/server/shadow/shadow_subsystem.c @@ -193,8 +193,6 @@ int shadow_subsystem_pointer_convert_alpha_pointer_data( BYTE* pixels, BOOL premultiplied, UINT32 width, UINT32 height, SHADOW_MSG_OUT_POINTER_ALPHA_UPDATE* pointerColor) { - UINT32 x = 0; - UINT32 y = 0; BYTE* pSrc8 = NULL; BYTE* pDst8 = NULL; UINT32 xorStep = 0; @@ -229,7 +227,7 @@ int shadow_subsystem_pointer_convert_alpha_pointer_data( return -1; } - for (y = 0; y < height; y++) + for (UINT32 y = 0; y < height; y++) { pSrc8 = &pixels[(width * 4) * (height - 1 - y)]; pDst8 = &(pointerColor->xorMaskData[y * xorStep]); @@ -237,7 +235,7 @@ int shadow_subsystem_pointer_convert_alpha_pointer_data( andBit = 0x80; andBits = &(pointerColor->andMaskData[andStep * y]); - for (x = 0; x < width; x++) + for (UINT32 x = 0; x < width; x++) { B = *pSrc8++; G = *pSrc8++; diff --git a/uwac/libuwac/uwac-display.c b/uwac/libuwac/uwac-display.c index 95353b94c..1b26e2192 100644 --- a/uwac/libuwac/uwac-display.c +++ b/uwac/libuwac/uwac-display.c @@ -462,7 +462,6 @@ int UwacDisplayDispatch(UwacDisplay* display, int timeout) { int ret = 0; int count = 0; - int i = 0; UwacTask* task = NULL; struct epoll_event ep[16]; wl_display_dispatch_pending(display->display); @@ -485,7 +484,7 @@ int UwacDisplayDispatch(UwacDisplay* display, int timeout) count = epoll_wait(display->epoll_fd, ep, ARRAY_LENGTH(ep), timeout); - for (i = 0; i < count; i++) + for (int i = 0; i < count; i++) { task = ep[i].data.ptr; task->run(task, ep[i].events); @@ -695,7 +694,6 @@ const UwacOutput* UwacDisplayGetOutput(UwacDisplay* display, int index) if (display_count <= index) return NULL; - i = 0; wl_list_for_each(ret, &display->outputs, link) { if (i == index) diff --git a/uwac/libuwac/uwac-input.c b/uwac/libuwac/uwac-input.c index 5592d10a6..5ad52aead 100644 --- a/uwac/libuwac/uwac-input.c +++ b/uwac/libuwac/uwac-input.c @@ -327,14 +327,14 @@ static int update_key_pressed(UwacSeat* seat, uint32_t key) static int update_key_released(UwacSeat* seat, uint32_t key) { - uint32_t* keyPtr = NULL; size_t toMove = 0; bool found = false; assert(seat); size_t i = 0; - for (i = 0, keyPtr = seat->pressed_keys.data; i < seat->pressed_keys.size; i++, keyPtr++) + uint32_t* keyPtr = seat->pressed_keys.data; + for (; i < seat->pressed_keys.size; i++, keyPtr++) { if (*keyPtr == key) { diff --git a/uwac/libuwac/uwac-os.c b/uwac/libuwac/uwac-os.c index 7dd7cb747..c51c5a223 100644 --- a/uwac/libuwac/uwac-os.c +++ b/uwac/libuwac/uwac-os.c @@ -121,7 +121,6 @@ static ssize_t recvmsg_cloexec_fallback(int sockfd, struct msghdr* msg, int flag ssize_t len = 0; struct cmsghdr* cmsg = NULL; unsigned char* data = NULL; - int* fd = NULL; int* end = NULL; len = recvmsg(sockfd, msg, flags); @@ -141,7 +140,7 @@ static ssize_t recvmsg_cloexec_fallback(int sockfd, struct msghdr* msg, int flag data = CMSG_DATA(cmsg); end = (int*)(data + cmsg->cmsg_len - CMSG_LEN(0)); - for (fd = (int*)data; fd < end; ++fd) + for (int* fd = (int*)data; fd < end; ++fd) *fd = set_cloexec_or_close(*fd); } diff --git a/uwac/libuwac/uwac-window.c b/uwac/libuwac/uwac-window.c index 1ad22eade..49728bd7e 100644 --- a/uwac/libuwac/uwac-window.c +++ b/uwac/libuwac/uwac-window.c @@ -58,9 +58,7 @@ static const struct wl_buffer_listener buffer_listener = { buffer_release }; static void UwacWindowDestroyBuffers(UwacWindow* w) { - int i = 0; - - for (i = 0; i < w->nbuffers; i++) + for (int i = 0; i < w->nbuffers; i++) { UwacBuffer* buffer = &w->buffers[i]; #ifdef UWAC_HAVE_PIXMAN_REGION @@ -322,7 +320,6 @@ int UwacWindowShmAllocBuffers(UwacWindow* w, int nbuffers, int allocSize, uint32 { int ret = UWAC_SUCCESS; UwacBuffer* newBuffers = NULL; - int i = 0; int fd = 0; void* data = NULL; struct wl_shm_pool* pool = NULL; @@ -361,7 +358,7 @@ int UwacWindowShmAllocBuffers(UwacWindow* w, int nbuffers, int allocSize, uint32 goto error_mmap; } - for (i = 0; i < nbuffers; i++) + for (int i = 0; i < nbuffers; i++) { int bufferIdx = w->nbuffers + i; UwacBuffer* buffer = &w->buffers[bufferIdx]; @@ -389,13 +386,13 @@ error_mmap: static UwacBuffer* UwacWindowFindFreeBuffer(UwacWindow* w, ssize_t* index) { - ssize_t i = 0; int ret = 0; if (index) *index = -1; - for (i = 0; i < w->nbuffers; i++) + size_t i = 0; + for (; i < w->nbuffers; i++) { if (!w->buffers[i].used) { @@ -683,19 +680,14 @@ static const struct wl_callback_listener frame_listener = { frame_done_cb }; static void damage_surface(UwacWindow* window, UwacBuffer* buffer, int scale) { int nrects = 0; - int i = 0; - int x = 0; - int y = 0; - int w = 0; - int h = 0; const pixman_box32_t* box = pixman_region32_rectangles(&buffer->damage, &nrects); - for (i = 0; i < nrects; i++, box++) + for (int i = 0; i < nrects; i++, box++) { - x = ((int)floor(box->x1 / scale)) - 1; - y = ((int)floor(box->y1 / scale)) - 1; - w = ((int)ceil((box->x2 - box->x1) / scale)) + 2; - h = ((int)ceil((box->y2 - box->y1) / scale)) + 2; + const int x = ((int)floor(box->x1 / scale)) - 1; + const int y = ((int)floor(box->y1 / scale)) - 1; + const int w = ((int)ceil((box->x2 - box->x1) / scale)) + 2; + const int h = ((int)ceil((box->y2 - box->y1) / scale)) + 2; wl_surface_damage(window->surface, x, y, w, h); } @@ -705,19 +697,14 @@ static void damage_surface(UwacWindow* window, UwacBuffer* buffer, int scale) static void damage_surface(UwacWindow* window, UwacBuffer* buffer, int scale) { uint32_t nrects = 0; - uint32_t i = 0; - int x = 0; - int y = 0; - int w = 0; - int h = 0; const RECTANGLE_16* box = region16_rects(&buffer->damage, &nrects); - for (i = 0; i < nrects; i++, box++) + for (UINT32 i = 0; i < nrects; i++, box++) { - x = ((int)floor(box->left / scale)) - 1; - y = ((int)floor(box->top / scale)) - 1; - w = ((int)ceil((box->right - box->left) / scale)) + 2; - h = ((int)ceil((box->bottom - box->top) / scale)) + 2; + const int x = ((int)floor(box->left / scale)) - 1; + const int y = ((int)floor(box->top / scale)) - 1; + const int w = ((int)ceil((box->right - box->left) / scale)) + 2; + const int h = ((int)ceil((box->bottom - box->top) / scale)) + 2; wl_surface_damage(window->surface, x, y, w, h); } diff --git a/winpr/libwinpr/clipboard/clipboard.c b/winpr/libwinpr/clipboard/clipboard.c index 00c0d1698..9d17fbcc4 100644 --- a/winpr/libwinpr/clipboard/clipboard.c +++ b/winpr/libwinpr/clipboard/clipboard.c @@ -73,7 +73,6 @@ const char* ClipboardGetFormatIdString(UINT32 formatId) static wClipboardFormat* ClipboardFindFormat(wClipboard* clipboard, UINT32 formatId, const char* name) { - UINT32 index = 0; wClipboardFormat* format = NULL; if (!clipboard) @@ -81,7 +80,7 @@ static wClipboardFormat* ClipboardFindFormat(wClipboard* clipboard, UINT32 forma if (formatId) { - for (index = 0; index < clipboard->numFormats; index++) + for (UINT32 index = 0; index < clipboard->numFormats; index++) { wClipboardFormat* cformat = &clipboard->formats[index]; if (formatId == cformat->formatId) @@ -93,7 +92,7 @@ static wClipboardFormat* ClipboardFindFormat(wClipboard* clipboard, UINT32 forma } else if (name) { - for (index = 0; index < clipboard->numFormats; index++) + for (UINT32 index = 0; index < clipboard->numFormats; index++) { wClipboardFormat* cformat = &clipboard->formats[index]; if (!cformat->formatName) @@ -183,7 +182,6 @@ UINT32 ClipboardCountRegisteredFormats(wClipboard* clipboard) UINT32 ClipboardGetRegisteredFormatIds(wClipboard* clipboard, UINT32** ppFormatIds) { - UINT32 index = 0; UINT32* pFormatIds = NULL; wClipboardFormat* format = NULL; @@ -205,7 +203,7 @@ UINT32 ClipboardGetRegisteredFormatIds(wClipboard* clipboard, UINT32** ppFormatI *ppFormatIds = pFormatIds; } - for (index = 0; index < clipboard->numFormats; index++) + for (UINT32 index = 0; index < clipboard->numFormats; index++) { format = &(clipboard->formats[index]); pFormatIds[index] = format->formatId; @@ -316,7 +314,6 @@ UINT32 ClipboardCountFormats(wClipboard* clipboard) UINT32 ClipboardGetFormatIds(wClipboard* clipboard, UINT32** ppFormatIds) { - UINT32 index = 0; UINT32 count = 0; UINT32* pFormatIds = NULL; wClipboardFormat* format = NULL; @@ -349,7 +346,7 @@ UINT32 ClipboardGetFormatIds(wClipboard* clipboard, UINT32** ppFormatIds) pFormatIds[0] = format->formatId; - for (index = 1; index < count; index++) + for (UINT32 index = 1; index < count; index++) { synthesizer = &(format->synthesizers[index - 1]); pFormatIds[index] = synthesizer->syntheticId; diff --git a/winpr/libwinpr/clipboard/synthetic_file.c b/winpr/libwinpr/clipboard/synthetic_file.c index 3482a2579..14219806c 100644 --- a/winpr/libwinpr/clipboard/synthetic_file.c +++ b/winpr/libwinpr/clipboard/synthetic_file.c @@ -409,8 +409,6 @@ static BOOL process_uri_list(wClipboard* clipboard, const char* data, size_t len { const char* cur = data; const char* lim = data + length; - const char* start = NULL; - const char* stop = NULL; WINPR_ASSERT(clipboard); WINPR_ASSERT(data); @@ -429,9 +427,10 @@ static BOOL process_uri_list(wClipboard* clipboard, const char* data, size_t len while (cur < lim) { BOOL comment = (*cur == '#'); - start = cur; + const char* start = cur; + const char* stop = cur; - for (stop = cur; stop < lim; stop++) + for (; stop < lim; stop++) { if (*stop == '\r') { @@ -506,7 +505,6 @@ static BOOL convert_local_file_to_filedescriptor(const struct synthetic_file* fi static FILEDESCRIPTORW* convert_local_file_list_to_filedescriptors(wArrayList* files) { - size_t i = 0; size_t count = 0; FILEDESCRIPTORW* descriptors = NULL; @@ -517,7 +515,7 @@ static FILEDESCRIPTORW* convert_local_file_list_to_filedescriptors(wArrayList* f if (!descriptors) goto error; - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) { const struct synthetic_file* file = ArrayList_GetItem(files, i); @@ -706,7 +704,6 @@ static void* convert_filedescriptors_to_file_list(wClipboard* clipboard, UINT32 const FILEDESCRIPTORW* descriptors = NULL; UINT32 nrDescriptors = 0; size_t count = 0; - size_t x = 0; size_t alloc = 0; size_t pos = 0; size_t baseLength = 0; @@ -750,7 +747,7 @@ static void* convert_filedescriptors_to_file_list(wClipboard* clipboard, UINT32 alloc = header_len; /* Get total size of file/folder names under first level folder only */ - for (x = 0; x < count; x++) + for (size_t x = 0; x < count; x++) { const FILEDESCRIPTORW* dsc = &descriptors[x]; @@ -776,7 +773,7 @@ static void* convert_filedescriptors_to_file_list(wClipboard* clipboard, UINT32 pos = header_len; - for (x = 0; x < count; x++) + for (size_t x = 0; x < count; x++) { const FILEDESCRIPTORW* dsc = &descriptors[x]; BOOL fail = TRUE; diff --git a/winpr/libwinpr/clipboard/test/TestClipboardFormats.c b/winpr/libwinpr/clipboard/test/TestClipboardFormats.c index 4c21a8b1b..615f8a036 100644 --- a/winpr/libwinpr/clipboard/test/TestClipboardFormats.c +++ b/winpr/libwinpr/clipboard/test/TestClipboardFormats.c @@ -5,7 +5,6 @@ int TestClipboardFormats(int argc, char* argv[]) { - UINT32 index = 0; UINT32 count = 0; UINT32* pFormatIds = NULL; const char* formatName = NULL; @@ -27,7 +26,7 @@ int TestClipboardFormats(int argc, char* argv[]) pFormatIds = NULL; count = ClipboardGetRegisteredFormatIds(clipboard, &pFormatIds); - for (index = 0; index < count; index++) + for (UINT32 index = 0; index < count; index++) { UINT32 formatId = pFormatIds[index]; formatName = ClipboardGetFormatName(clipboard, formatId); @@ -70,7 +69,7 @@ int TestClipboardFormats(int argc, char* argv[]) pFormatIds = NULL; count = ClipboardGetFormatIds(clipboard, &pFormatIds); - for (index = 0; index < count; index++) + for (UINT32 index = 0; index < count; index++) { UINT32 formatId = pFormatIds[index]; formatName = ClipboardGetFormatName(clipboard, formatId); diff --git a/winpr/libwinpr/comm/comm.c b/winpr/libwinpr/comm/comm.c index a77adcc33..c4e828e06 100644 --- a/winpr/libwinpr/comm/comm.c +++ b/winpr/libwinpr/comm/comm.c @@ -932,7 +932,6 @@ BOOL WaitCommEvent(HANDLE hFile, PDWORD lpEvtMask, LPOVERLAPPED lpOverlapped) */ BOOL DefineCommDevice(/* DWORD dwFlags,*/ LPCTSTR lpDeviceName, LPCTSTR lpTargetPath) { - int i = 0; LPTSTR storedDeviceName = NULL; LPTSTR storedTargetPath = NULL; @@ -963,7 +962,8 @@ BOOL DefineCommDevice(/* DWORD dwFlags,*/ LPCTSTR lpDeviceName, LPCTSTR lpTarget goto error_handle; } - for (i = 0; i < COMM_DEVICE_MAX; i++) + int i = 0; + for (; i < COMM_DEVICE_MAX; i++) { if (_CommDevices[i] != NULL) { @@ -1027,7 +1027,6 @@ error_handle: */ DWORD QueryCommDevice(LPCTSTR lpDeviceName, LPTSTR lpTargetPath, DWORD ucchMax) { - int i = 0; LPTSTR storedTargetPath = NULL; SetLastError(ERROR_SUCCESS); @@ -1049,7 +1048,7 @@ DWORD QueryCommDevice(LPCTSTR lpDeviceName, LPTSTR lpTargetPath, DWORD ucchMax) EnterCriticalSection(&_CommDevicesLock); storedTargetPath = NULL; - for (i = 0; i < COMM_DEVICE_MAX; i++) + for (int i = 0; i < COMM_DEVICE_MAX; i++) { if (_CommDevices[i] != NULL) { diff --git a/winpr/libwinpr/comm/comm_ioctl.c b/winpr/libwinpr/comm/comm_ioctl.c index a7e67d0b5..4f208ef43 100644 --- a/winpr/libwinpr/comm/comm_ioctl.c +++ b/winpr/libwinpr/comm/comm_ioctl.c @@ -53,9 +53,7 @@ const char* _comm_serial_ioctl_name(ULONG number) { - int i = 0; - - for (i = 0; _SERIAL_IOCTL_NAMES[i].number != 0; i++) + for (int i = 0; _SERIAL_IOCTL_NAMES[i].number != 0; i++) { if (_SERIAL_IOCTL_NAMES[i].number == number) { diff --git a/winpr/libwinpr/comm/comm_serial_sys.c b/winpr/libwinpr/comm/comm_serial_sys.c index 49db222ac..cae653c5d 100644 --- a/winpr/libwinpr/comm/comm_serial_sys.c +++ b/winpr/libwinpr/comm/comm_serial_sys.c @@ -158,8 +158,6 @@ static const speed_t _BAUD_TABLE[][3] = { static BOOL _get_properties(WINPR_COMM* pComm, COMMPROP* pProperties) { - int i = 0; - /* http://msdn.microsoft.com/en-us/library/windows/hardware/jj680684%28v=vs.85%29.aspx * http://msdn.microsoft.com/en-us/library/windows/desktop/aa363189%28v=vs.85%29.aspx */ @@ -200,7 +198,7 @@ static BOOL _get_properties(WINPR_COMM* pComm, COMMPROP* pProperties) SP_PARITY_CHECK | /*SP_RLSD |*/ SP_STOPBITS; pProperties->dwSettableBaud = 0; - for (i = 0; _BAUD_TABLE[i][0] < BAUD_TABLE_END; i++) + for (int i = 0; _BAUD_TABLE[i][0] < BAUD_TABLE_END; i++) { pProperties->dwSettableBaud |= _BAUD_TABLE[i][2]; } @@ -224,7 +222,6 @@ static BOOL _get_properties(WINPR_COMM* pComm, COMMPROP* pProperties) static BOOL _set_baud_rate(WINPR_COMM* pComm, const SERIAL_BAUD_RATE* pBaudRate) { - int i = 0; speed_t newSpeed = 0; struct termios futureState; @@ -236,7 +233,7 @@ static BOOL _set_baud_rate(WINPR_COMM* pComm, const SERIAL_BAUD_RATE* pBaudRate) return FALSE; } - for (i = 0; _BAUD_TABLE[i][0] < BAUD_TABLE_END; i++) + for (int i = 0; _BAUD_TABLE[i][0] < BAUD_TABLE_END; i++) { if (_BAUD_TABLE[i][1] == pBaudRate->BaudRate) { @@ -269,7 +266,6 @@ static BOOL _set_baud_rate(WINPR_COMM* pComm, const SERIAL_BAUD_RATE* pBaudRate) static BOOL _get_baud_rate(WINPR_COMM* pComm, SERIAL_BAUD_RATE* pBaudRate) { - int i = 0; speed_t currentSpeed = 0; struct termios currentState; @@ -282,7 +278,7 @@ static BOOL _get_baud_rate(WINPR_COMM* pComm, SERIAL_BAUD_RATE* pBaudRate) currentSpeed = cfgetispeed(¤tState); - for (i = 0; _BAUD_TABLE[i][0] < BAUD_TABLE_END; i++) + for (int i = 0; _BAUD_TABLE[i][0] < BAUD_TABLE_END; i++) { if (_BAUD_TABLE[i][0] == currentSpeed) { diff --git a/winpr/libwinpr/crt/string.c b/winpr/libwinpr/crt/string.c index 003d07294..93721a68c 100644 --- a/winpr/libwinpr/crt/string.c +++ b/winpr/libwinpr/crt/string.c @@ -323,11 +323,10 @@ size_t _wcslen(const WCHAR* str) size_t _wcsnlen(const WCHAR* str, size_t max) { - size_t x = 0; - WINPR_ASSERT(str); - for (x = 0; x < max; x++) + size_t x = 0; + for (; x < max; x++) { if (str[x] == 0) return x; @@ -451,7 +450,6 @@ WCHAR* wcstok_s(WCHAR* strToken, const WCHAR* strDelimit, WCHAR** context) LPSTR CharUpperA(LPSTR lpsz) { - size_t i = 0; size_t length = 0; if (!lpsz) @@ -473,7 +471,7 @@ LPSTR CharUpperA(LPSTR lpsz) return lpsz; } - for (i = 0; i < length; i++) + for (size_t i = 0; i < length; i++) { if ((lpsz[i] >= 'a') && (lpsz[i] <= 'z')) lpsz[i] = lpsz[i] - 'a' + 'A'; @@ -484,7 +482,6 @@ LPSTR CharUpperA(LPSTR lpsz) LPWSTR CharUpperW(LPWSTR lpsz) { - size_t i = 0; size_t length = 0; if (!lpsz) @@ -506,7 +503,7 @@ LPWSTR CharUpperW(LPWSTR lpsz) return lpsz; } - for (i = 0; i < length; i++) + for (size_t i = 0; i < length; i++) { if ((lpsz[i] >= L'a') && (lpsz[i] <= L'z')) lpsz[i] = lpsz[i] - L'a' + L'A'; @@ -517,12 +514,10 @@ LPWSTR CharUpperW(LPWSTR lpsz) DWORD CharUpperBuffA(LPSTR lpsz, DWORD cchLength) { - DWORD i = 0; - if (cchLength < 1) return 0; - for (i = 0; i < cchLength; i++) + for (DWORD i = 0; i < cchLength; i++) { if ((lpsz[i] >= 'a') && (lpsz[i] <= 'z')) lpsz[i] = lpsz[i] - 'a' + 'A'; @@ -533,10 +528,9 @@ DWORD CharUpperBuffA(LPSTR lpsz, DWORD cchLength) DWORD CharUpperBuffW(LPWSTR lpsz, DWORD cchLength) { - DWORD i = 0; WCHAR value = 0; - for (i = 0; i < cchLength; i++) + for (DWORD i = 0; i < cchLength; i++) { Data_Read_UINT16(&lpsz[i], value); value = WINPR_TOUPPERW(value); @@ -548,7 +542,6 @@ DWORD CharUpperBuffW(LPWSTR lpsz, DWORD cchLength) LPSTR CharLowerA(LPSTR lpsz) { - size_t i = 0; size_t length = 0; if (!lpsz) @@ -570,7 +563,7 @@ LPSTR CharLowerA(LPSTR lpsz) return lpsz; } - for (i = 0; i < length; i++) + for (size_t i = 0; i < length; i++) { if ((lpsz[i] >= 'A') && (lpsz[i] <= 'Z')) lpsz[i] = lpsz[i] - 'A' + 'a'; @@ -587,12 +580,10 @@ LPWSTR CharLowerW(LPWSTR lpsz) DWORD CharLowerBuffA(LPSTR lpsz, DWORD cchLength) { - DWORD i = 0; - if (cchLength < 1) return 0; - for (i = 0; i < cchLength; i++) + for (DWORD i = 0; i < cchLength; i++) { if ((lpsz[i] >= 'A') && (lpsz[i] <= 'Z')) lpsz[i] = lpsz[i] - 'A' + 'a'; @@ -603,10 +594,9 @@ DWORD CharLowerBuffA(LPSTR lpsz, DWORD cchLength) DWORD CharLowerBuffW(LPWSTR lpsz, DWORD cchLength) { - DWORD i = 0; WCHAR value = 0; - for (i = 0; i < cchLength; i++) + for (DWORD i = 0; i < cchLength; i++) { Data_Read_UINT16(&lpsz[i], value); value = WINPR_TOLOWERW(value); diff --git a/winpr/libwinpr/crypto/cipher.c b/winpr/libwinpr/crypto/cipher.c index 243b04088..45eca79f7 100644 --- a/winpr/libwinpr/crypto/cipher.c +++ b/winpr/libwinpr/crypto/cipher.c @@ -634,7 +634,7 @@ int winpr_Cipher_BytesToKey(int cipher, WINPR_MD_TYPE md, const void* salt, cons int rv = 0; BYTE md_buf[64]; int niv, nkey, addmd = 0; - unsigned int mds = 0, i; + unsigned int mds = 0; mbedtls_md_context_t ctx; const mbedtls_md_info_t* md_info; mbedtls_cipher_type_t cipher_type; @@ -682,7 +682,7 @@ int winpr_Cipher_BytesToKey(int cipher, WINPR_MD_TYPE md, const void* salt, cons mds = mbedtls_md_get_size(md_info); - for (i = 1; i < (unsigned int)count; i++) + for (unsigned int i = 1; i < (unsigned int)count; i++) { if (mbedtls_md_starts(&ctx) != 0) goto err; diff --git a/winpr/libwinpr/environment/environment.c b/winpr/libwinpr/environment/environment.c index 835c2fb50..c6df6bd2d 100644 --- a/winpr/libwinpr/environment/environment.c +++ b/winpr/libwinpr/environment/environment.c @@ -318,7 +318,6 @@ LPCH MergeEnvironmentStrings(PCSTR original, PCSTR merge) const char** mergeStrings = NULL; size_t mergeStringLength = 0; size_t mergeArraySize = 128; - size_t run = 0; size_t mergeLength = 0; size_t foundMerge = 0; char* foundEquals = NULL; @@ -392,7 +391,7 @@ LPCH MergeEnvironmentStrings(PCSTR original, PCSTR merge) // check if this value is in the mergeStrings foundMerge = 0; - for (run = 0; run < mergeStringLength; run++) + for (size_t run = 0; run < mergeStringLength; run++) { if (!mergeStrings[run]) continue; @@ -449,7 +448,7 @@ LPCH MergeEnvironmentStrings(PCSTR original, PCSTR merge) } // now merge the not already merged env - for (run = 0; run < mergeStringLength; run++) + for (size_t run = 0; run < mergeStringLength; run++) { if (!mergeStrings[run]) continue; diff --git a/winpr/libwinpr/error/test/TestErrorSetLastError.c b/winpr/libwinpr/error/test/TestErrorSetLastError.c index 872ea2321..a3d57af02 100644 --- a/winpr/libwinpr/error/test/TestErrorSetLastError.c +++ b/winpr/libwinpr/error/test/TestErrorSetLastError.c @@ -62,7 +62,6 @@ int TestErrorSetLastError(int argc, char* argv[]) { DWORD error = 0; HANDLE threads[4]; - int i = 0; WINPR_UNUSED(argc); WINPR_UNUSED(argv); @@ -91,7 +90,7 @@ int TestErrorSetLastError(int argc, char* argv[]) } *pLoopCount = 0; - for (i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { if (!(threads[i] = CreateThread(NULL, 0, test_error_thread, (void*)(size_t)0, 0, NULL))) { diff --git a/winpr/libwinpr/file/file.c b/winpr/libwinpr/file/file.c index 753e69787..01328b8a8 100644 --- a/winpr/libwinpr/file/file.c +++ b/winpr/libwinpr/file/file.c @@ -1075,8 +1075,6 @@ BOOL GetDiskFreeSpaceW(LPCWSTR lpwRootPathName, LPDWORD lpSectorsPerCluster, */ BOOL ValidFileNameComponent(LPCWSTR lpFileName) { - LPCWSTR c = NULL; - if (!lpFileName) return FALSE; @@ -1137,7 +1135,7 @@ BOOL ValidFileNameComponent(LPCWSTR lpFileName) } /* Reserved characters */ - for (c = lpFileName; *c; c++) + for (LPCWSTR c = lpFileName; *c; c++) { if ((*c == L'<') || (*c == L'>') || (*c == L':') || (*c == L'"') || (*c == L'/') || (*c == L'\\') || (*c == L'|') || (*c == L'?') || (*c == L'*')) diff --git a/winpr/libwinpr/file/generic.c b/winpr/libwinpr/file/generic.c index 2d0eb38bb..e1437ecce 100644 --- a/winpr/libwinpr/file/generic.c +++ b/winpr/libwinpr/file/generic.c @@ -233,8 +233,6 @@ HANDLE CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) { - size_t i = 0; - if (!lpFileName) return INVALID_HANDLE_VALUE; @@ -252,7 +250,7 @@ HANDLE CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, ArrayList_Lock(_HandleCreators); - for (i = 0; i <= ArrayList_Count(_HandleCreators); i++) + for (size_t i = 0; i <= ArrayList_Count(_HandleCreators); i++) { HANDLE_CREATOR* creator = ArrayList_GetItem(_HandleCreators, i); diff --git a/winpr/libwinpr/file/test/TestSetFileAttributes.c b/winpr/libwinpr/file/test/TestSetFileAttributes.c index bd85c7623..f423ec296 100644 --- a/winpr/libwinpr/file/test/TestSetFileAttributes.c +++ b/winpr/libwinpr/file/test/TestSetFileAttributes.c @@ -36,13 +36,12 @@ static BOOL test_SetFileAttributesA(void) { BOOL rc = FALSE; HANDLE handle = NULL; - DWORD x = 0; const DWORD flags[] = { 0, FILE_ATTRIBUTE_READONLY }; char* name = GetKnownSubPath(KNOWN_PATH_TEMP, "afsklhjwe4oq5iu432oijrlkejadlkhjaklhfdkahfd"); if (!name) goto fail; - for (x = 0; x < ARRAYSIZE(allflags); x++) + for (size_t x = 0; x < ARRAYSIZE(allflags); x++) { const DWORD flag = allflags[x]; const BOOL brc = SetFileAttributesA(NULL, flag); @@ -60,7 +59,7 @@ static BOOL test_SetFileAttributesA(void) goto fail; CloseHandle(handle); - for (x = 0; x < ARRAYSIZE(flags); x++) + for (size_t x = 0; x < ARRAYSIZE(flags); x++) { DWORD attr = 0; const DWORD flag = flags[x]; @@ -89,7 +88,6 @@ static BOOL test_SetFileAttributesW(void) BOOL rc = FALSE; WCHAR* name = NULL; HANDLE handle = NULL; - DWORD x = 0; const DWORD flags[] = { 0, FILE_ATTRIBUTE_READONLY }; char* base = GetKnownSubPath(KNOWN_PATH_TEMP, "afsklhjwe4oq5iu432oijrlkejadlkhjaklhfdkahfd"); if (!base) @@ -99,7 +97,7 @@ static BOOL test_SetFileAttributesW(void) if (!name) goto fail; - for (x = 0; x < ARRAYSIZE(allflags); x++) + for (size_t x = 0; x < ARRAYSIZE(allflags); x++) { const DWORD flag = allflags[x]; const BOOL brc = SetFileAttributesW(NULL, flag); @@ -117,7 +115,7 @@ static BOOL test_SetFileAttributesW(void) goto fail; CloseHandle(handle); - for (x = 0; x < ARRAYSIZE(flags); x++) + for (size_t x = 0; x < ARRAYSIZE(flags); x++) { DWORD attr = 0; const DWORD flag = flags[x]; diff --git a/winpr/libwinpr/input/keycode.c b/winpr/libwinpr/input/keycode.c index 6883b0116..cf6172416 100644 --- a/winpr/libwinpr/input/keycode.c +++ b/winpr/libwinpr/input/keycode.c @@ -879,7 +879,6 @@ DWORD GetVirtualKeyCodeFromKeycode(DWORD keycode, WINPR_KEYCODE_TYPE type) DWORD GetKeycodeFromVirtualKeyCode(DWORD vkcode, WINPR_KEYCODE_TYPE type) { - DWORD index = 0; DWORD* targetArray = NULL; size_t targetSize = 0; @@ -901,7 +900,7 @@ DWORD GetKeycodeFromVirtualKeyCode(DWORD vkcode, WINPR_KEYCODE_TYPE type) return 0; } - for (index = 0; index < targetSize; index++) + for (DWORD index = 0; index < targetSize; index++) { if (vkcode == targetArray[index]) return index; diff --git a/winpr/libwinpr/input/virtualkey.c b/winpr/libwinpr/input/virtualkey.c index 89490ac37..66f9b0951 100644 --- a/winpr/libwinpr/input/virtualkey.c +++ b/winpr/libwinpr/input/virtualkey.c @@ -432,9 +432,7 @@ const char* GetVirtualKeyName(DWORD vkcode) DWORD GetVirtualKeyCodeFromName(const char* vkname) { - unsigned long i = 0; - - for (i = 0; i < ARRAYSIZE(VIRTUAL_KEY_CODE_TABLE); i++) + for (size_t i = 0; i < ARRAYSIZE(VIRTUAL_KEY_CODE_TABLE); i++) { if (VIRTUAL_KEY_CODE_TABLE[i].name) { @@ -448,9 +446,7 @@ DWORD GetVirtualKeyCodeFromName(const char* vkname) DWORD GetVirtualKeyCodeFromXkbKeyName(const char* xkbname) { - unsigned long i = 0; - - for (i = 0; i < ARRAYSIZE(XKB_KEYNAME_TABLE); i++) + for (size_t i = 0; i < ARRAYSIZE(XKB_KEYNAME_TABLE); i++) { if (XKB_KEYNAME_TABLE[i].name) { diff --git a/winpr/libwinpr/interlocked/test/TestInterlockedAccess.c b/winpr/libwinpr/interlocked/test/TestInterlockedAccess.c index d8af2d3a0..0ecd85095 100644 --- a/winpr/libwinpr/interlocked/test/TestInterlockedAccess.c +++ b/winpr/libwinpr/interlocked/test/TestInterlockedAccess.c @@ -5,7 +5,6 @@ int TestInterlockedAccess(int argc, char* argv[]) { - int index = 0; LONG* Addend = NULL; LONG* Target = NULL; LONG oldValue = 0; @@ -25,7 +24,7 @@ int TestInterlockedAccess(int argc, char* argv[]) *Addend = 0; - for (index = 0; index < 10; index++) + for (int index = 0; index < 10; index++) InterlockedIncrement(Addend); if (*Addend != 10) @@ -36,7 +35,7 @@ int TestInterlockedAccess(int argc, char* argv[]) /* InterlockedDecrement */ - for (index = 0; index < 10; index++) + for (int index = 0; index < 10; index++) InterlockedDecrement(Addend); if (*Addend != 0) diff --git a/winpr/libwinpr/ncrypt/ncrypt_pkcs11.c b/winpr/libwinpr/ncrypt/ncrypt_pkcs11.c index dbd41a230..08e6274b6 100644 --- a/winpr/libwinpr/ncrypt/ncrypt_pkcs11.c +++ b/winpr/libwinpr/ncrypt/ncrypt_pkcs11.c @@ -130,9 +130,7 @@ static void fix_padded_string(char* str, size_t maxlen) static BOOL attributes_have_unallocated_buffers(CK_ATTRIBUTE_PTR attributes, CK_ULONG count) { - CK_ULONG i = 0; - - for (i = 0; i < count; i++) + for (CK_ULONG i = 0; i < count; i++) { if (!attributes[i].pValue && (attributes[i].ulValueLen != CK_UNAVAILABLE_INFORMATION)) return TRUE; @@ -161,10 +159,9 @@ static BOOL attribute_allocate_buffer(CK_ATTRIBUTE_PTR attribute) static BOOL attributes_allocate_buffers(CK_ATTRIBUTE_PTR attributes, CK_ULONG count) { - CK_ULONG i = 0; BOOL ret = TRUE; - for (i = 0; i < count; i++) + for (CK_ULONG i = 0; i < count; i++) { if (attributes[i].pValue || (attributes[i].ulValueLen == CK_UNAVAILABLE_INFORMATION)) continue; @@ -534,19 +531,18 @@ static void wprintKeyName(LPWSTR str, CK_SLOT_ID slotId, CK_BYTE* id, CK_ULONG i char asciiName[128] = { 0 }; char* ptr = asciiName; const CK_BYTE* bytePtr = NULL; - CK_ULONG i = 0; *ptr = '\\'; ptr++; bytePtr = ((CK_BYTE*)&slotId); - for (i = 0; i < sizeof(slotId); i++, bytePtr++, ptr += 2) + for (CK_ULONG i = 0; i < sizeof(slotId); i++, bytePtr++, ptr += 2) snprintf(ptr, 3, "%.2x", *bytePtr); *ptr = '\\'; ptr++; - for (i = 0; i < idLen; i++, id++, ptr += 2) + for (CK_ULONG i = 0; i < idLen; i++, id++, ptr += 2) snprintf(ptr, 3, "%.2x", *id); ConvertUtf8NToWChar(asciiName, ARRAYSIZE(asciiName), str, @@ -557,7 +553,7 @@ static size_t parseHex(const char* str, const char* end, CK_BYTE* target) { int ret = 0; - for (ret = 0; str != end && *str; str++, ret++, target++) + for (; str != end && *str; str++, ret++, target++) { CK_BYTE v = 0; if (*str <= '9' && *str >= '0') diff --git a/winpr/libwinpr/ncrypt/test/TestNCryptProviders.c b/winpr/libwinpr/ncrypt/test/TestNCryptProviders.c index ec7750db6..8381e68d8 100644 --- a/winpr/libwinpr/ncrypt/test/TestNCryptProviders.c +++ b/winpr/libwinpr/ncrypt/test/TestNCryptProviders.c @@ -28,7 +28,6 @@ int TestNCryptProviders(int argc, char* argv[]) { SECURITY_STATUS status = 0; DWORD nproviders = 0; - DWORD i = 0; NCryptProviderName* providers = NULL; WINPR_UNUSED(argc); @@ -38,7 +37,7 @@ int TestNCryptProviders(int argc, char* argv[]) if (status != ERROR_SUCCESS) return -1; - for (i = 0; i < nproviders; i++) + for (DWORD i = 0; i < nproviders; i++) { const NCryptProviderName* provider = &providers[i]; char providerNameStr[256] = { 0 }; diff --git a/winpr/libwinpr/ncrypt/test/TestNCryptSmartcard.c b/winpr/libwinpr/ncrypt/test/TestNCryptSmartcard.c index 5126b3b27..247a03342 100644 --- a/winpr/libwinpr/ncrypt/test/TestNCryptSmartcard.c +++ b/winpr/libwinpr/ncrypt/test/TestNCryptSmartcard.c @@ -64,7 +64,6 @@ bio_release: int TestNCryptSmartcard(int argc, char* argv[]) { SECURITY_STATUS status = 0; - size_t j = 0; DWORD providerCount = 0; NCryptProviderName* names = NULL; @@ -72,7 +71,7 @@ int TestNCryptSmartcard(int argc, char* argv[]) if (status != ERROR_SUCCESS) return -1; - for (j = 0; j < providerCount; j++) + for (size_t j = 0; j < providerCount; j++) { const NCryptProviderName* name = &names[j]; NCRYPT_PROV_HANDLE provider = 0; diff --git a/winpr/libwinpr/nt/ntstatus.c b/winpr/libwinpr/nt/ntstatus.c index b215569b9..e2f174e61 100644 --- a/winpr/libwinpr/nt/ntstatus.c +++ b/winpr/libwinpr/nt/ntstatus.c @@ -4625,8 +4625,7 @@ const char* NtStatus2Tag(DWORD ntstatus) return NULL; return found->tag; #else - size_t x; - for (x = 0; x < ARRAYSIZE(ntstatusmap); x++) + for (size_t x = 0; x < ARRAYSIZE(ntstatusmap); x++) { const struct ntstatus_map* cur = &ntstatusmap[x]; if (cur->code == ntstatus) @@ -4649,8 +4648,7 @@ const char* Win32ErrorCode2Tag(UINT16 code) return NULL; return found->tag; #else - size_t x; - for (x = 0; x < ARRAYSIZE(win32errmap); x++) + for (size_t x = 0; x < ARRAYSIZE(win32errmap); x++) { const struct ntstatus_map* cur = &win32errmap[x]; if (cur->code == ntstatus) diff --git a/winpr/libwinpr/path/path.c b/winpr/libwinpr/path/path.c index aed979316..82e6be1b6 100644 --- a/winpr/libwinpr/path/path.c +++ b/winpr/libwinpr/path/path.c @@ -783,11 +783,9 @@ HRESULT PathCchRemoveFileSpecW(PWSTR pszPath, size_t cchPath) HRESULT PathCchConvertStyleA(PSTR pszPath, size_t cchPath, unsigned long dwFlags) { - size_t index = 0; - if (dwFlags == PATH_STYLE_WINDOWS) { - for (index = 0; index < cchPath; index++) + for (size_t index = 0; index < cchPath; index++) { if (pszPath[index] == PATH_SLASH_CHR) pszPath[index] = PATH_BACKSLASH_CHR; @@ -795,7 +793,7 @@ HRESULT PathCchConvertStyleA(PSTR pszPath, size_t cchPath, unsigned long dwFlags } else if (dwFlags == PATH_STYLE_UNIX) { - for (index = 0; index < cchPath; index++) + for (size_t index = 0; index < cchPath; index++) { if (pszPath[index] == PATH_BACKSLASH_CHR) pszPath[index] = PATH_SLASH_CHR; @@ -806,7 +804,7 @@ HRESULT PathCchConvertStyleA(PSTR pszPath, size_t cchPath, unsigned long dwFlags #if (PATH_SEPARATOR_CHR == PATH_BACKSLASH_CHR) /* Unix-style to Windows-style */ - for (index = 0; index < cchPath; index++) + for (size_t index = 0; index < cchPath; index++) { if (pszPath[index] == PATH_SLASH_CHR) pszPath[index] = PATH_BACKSLASH_CHR; @@ -814,7 +812,7 @@ HRESULT PathCchConvertStyleA(PSTR pszPath, size_t cchPath, unsigned long dwFlags #elif (PATH_SEPARATOR_CHR == PATH_SLASH_CHR) /* Windows-style to Unix-style */ - for (index = 0; index < cchPath; index++) + for (size_t index = 0; index < cchPath; index++) { if (pszPath[index] == PATH_BACKSLASH_CHR) pszPath[index] = PATH_SLASH_CHR; @@ -835,11 +833,9 @@ HRESULT PathCchConvertStyleA(PSTR pszPath, size_t cchPath, unsigned long dwFlags HRESULT PathCchConvertStyleW(PWSTR pszPath, size_t cchPath, unsigned long dwFlags) { - size_t index = 0; - if (dwFlags == PATH_STYLE_WINDOWS) { - for (index = 0; index < cchPath; index++) + for (size_t index = 0; index < cchPath; index++) { if (pszPath[index] == PATH_SLASH_CHR) pszPath[index] = PATH_BACKSLASH_CHR; @@ -847,7 +843,7 @@ HRESULT PathCchConvertStyleW(PWSTR pszPath, size_t cchPath, unsigned long dwFlag } else if (dwFlags == PATH_STYLE_UNIX) { - for (index = 0; index < cchPath; index++) + for (size_t index = 0; index < cchPath; index++) { if (pszPath[index] == PATH_BACKSLASH_CHR) pszPath[index] = PATH_SLASH_CHR; @@ -859,7 +855,7 @@ HRESULT PathCchConvertStyleW(PWSTR pszPath, size_t cchPath, unsigned long dwFlag { /* Unix-style to Windows-style */ - for (index = 0; index < cchPath; index++) + for (size_t index = 0; index < cchPath; index++) { if (pszPath[index] == PATH_SLASH_CHR) pszPath[index] = PATH_BACKSLASH_CHR; @@ -869,7 +865,7 @@ HRESULT PathCchConvertStyleW(PWSTR pszPath, size_t cchPath, unsigned long dwFlag { /* Windows-style to Unix-style */ - for (index = 0; index < cchPath; index++) + for (size_t index = 0; index < cchPath; index++) { if (pszPath[index] == PATH_BACKSLASH_CHR) pszPath[index] = PATH_SLASH_CHR; diff --git a/winpr/libwinpr/path/shell.c b/winpr/libwinpr/path/shell.c index be2b207be..4380a9b6d 100644 --- a/winpr/libwinpr/path/shell.c +++ b/winpr/libwinpr/path/shell.c @@ -480,7 +480,6 @@ BOOL PathMakePathA(LPCSTR path, LPSECURITY_ATTRIBUTES lpAttributes) #else const char delim = PathGetSeparatorA(PATH_STYLE_NATIVE); char* dup = NULL; - char* p = NULL; BOOL result = TRUE; /* we only operate on a non-null, absolute path */ #if defined(__OS2__) @@ -503,7 +502,7 @@ BOOL PathMakePathA(LPCSTR path, LPSECURITY_ATTRIBUTES lpAttributes) while (p) #else - for (p = dup; p;) + for (char* p = dup; p;) #endif { if ((p = strchr(p + 1, delim))) @@ -535,7 +534,6 @@ BOOL PathMakePathW(LPCWSTR path, LPSECURITY_ATTRIBUTES lpAttributes) const WCHAR wdelim = PathGetSeparatorW(PATH_STYLE_NATIVE); const char delim = PathGetSeparatorA(PATH_STYLE_NATIVE); char* dup = NULL; - char* p = NULL; BOOL result = TRUE; /* we only operate on a non-null, absolute path */ #if defined(__OS2__) @@ -559,7 +557,7 @@ BOOL PathMakePathW(LPCWSTR path, LPSECURITY_ATTRIBUTES lpAttributes) while (p) #else - for (p = dup; p;) + for (char* p = dup; p;) #endif { if ((p = strchr(p + 1, delim))) diff --git a/winpr/libwinpr/path/test/TestPathCchAppend.c b/winpr/libwinpr/path/test/TestPathCchAppend.c index fc22dcd4f..93524cac5 100644 --- a/winpr/libwinpr/path/test/TestPathCchAppend.c +++ b/winpr/libwinpr/path/test/TestPathCchAppend.c @@ -15,7 +15,6 @@ int TestPathCchAppend(int argc, char* argv[]) { HRESULT status = 0; TCHAR Path[PATHCCH_MAX_CCH]; - size_t i = 0; WINPR_UNUSED(argc); WINPR_UNUSED(argv); @@ -135,7 +134,7 @@ int TestPathCchAppend(int argc, char* argv[]) /* Resulting file must not exceed PATHCCH_MAX_CCH */ - for (i = 0; i < PATHCCH_MAX_CCH - 1; i++) + for (size_t i = 0; i < PATHCCH_MAX_CCH - 1; i++) Path[i] = _T('X'); Path[PATHCCH_MAX_CCH - 1] = 0; diff --git a/winpr/libwinpr/path/test/TestPathCchStripPrefix.c b/winpr/libwinpr/path/test/TestPathCchStripPrefix.c index 42382ebb9..aaec4bc1c 100644 --- a/winpr/libwinpr/path/test/TestPathCchStripPrefix.c +++ b/winpr/libwinpr/path/test/TestPathCchStripPrefix.c @@ -21,7 +21,6 @@ int TestPathCchStripPrefix(int argc, char* argv[]) { HRESULT status = 0; TCHAR Path[PATHCCH_MAX_CCH]; - int i = 0; WINPR_UNUSED(argc); WINPR_UNUSED(argv); @@ -81,7 +80,7 @@ int TestPathCchStripPrefix(int argc, char* argv[]) } /* Invalid cchPath values: 0, 1, 2, 3 and > PATHCCH_MAX_CCH */ - for (i = 0; i < 5; i++) + for (int i = 0; i < 5; i++) { _tcscpy(Path, testPathPrefixFileNamespace); if (i == 4) @@ -98,7 +97,7 @@ int TestPathCchStripPrefix(int argc, char* argv[]) /* Minimum Path that would get successfully stripped on windows */ _tcscpy(Path, testPathPrefixFileNamespaceMinimum); - i = sizeof(testPathPrefixFileNamespaceMinimum) / sizeof(TCHAR); + size_t i = sizeof(testPathPrefixFileNamespaceMinimum) / sizeof(TCHAR); i = i - 1; /* include testing of a non-null terminated string */ status = PathCchStripPrefix(Path, i); if (status != S_OK) diff --git a/winpr/libwinpr/path/test/TestPathMakePath.c b/winpr/libwinpr/path/test/TestPathMakePath.c index 5e244c0aa..488cab3c6 100644 --- a/winpr/libwinpr/path/test/TestPathMakePath.c +++ b/winpr/libwinpr/path/test/TestPathMakePath.c @@ -8,7 +8,6 @@ int TestPathMakePath(int argc, char* argv[]) { - int x = 0; size_t baseLen = 0; BOOL success = 0; char tmp[64] = { 0 }; @@ -29,7 +28,7 @@ int TestPathMakePath(int argc, char* argv[]) baseLen = strlen(base); srand(time(NULL)); - for (x = 0; x < 5; x++) + for (int x = 0; x < 5; x++) { sprintf_s(tmp, ARRAYSIZE(tmp), "%08X", rand()); path = GetCombinedPath(base, tmp); diff --git a/winpr/libwinpr/path/test/TestPathShell.c b/winpr/libwinpr/path/test/TestPathShell.c index 669119c4a..1925fea78 100644 --- a/winpr/libwinpr/path/test/TestPathShell.c +++ b/winpr/libwinpr/path/test/TestPathShell.c @@ -16,12 +16,11 @@ int TestPathShell(int argc, char* argv[]) "KNOWN_PATH_XDG_CACHE_HOME", "KNOWN_PATH_XDG_RUNTIME_DIR", "KNOWN_PATH_XDG_CONFIG_HOME" }; int rc = 0; - size_t x = 0; WINPR_UNUSED(argc); WINPR_UNUSED(argv); - for (x = 0; x < sizeof(paths) / sizeof(paths[0]); x++) + for (size_t x = 0; x < sizeof(paths) / sizeof(paths[0]); x++) { const int id = paths[x]; const char* name = names[x]; diff --git a/winpr/libwinpr/pipe/pipe.c b/winpr/libwinpr/pipe/pipe.c index 75f7bcca4..dba1bf3e5 100644 --- a/winpr/libwinpr/pipe/pipe.c +++ b/winpr/libwinpr/pipe/pipe.c @@ -514,7 +514,6 @@ BOOL CreatePipe(PHANDLE hReadPipe, PHANDLE hWritePipe, LPSECURITY_ATTRIBUTES lpP static void winpr_unref_named_pipe(WINPR_NAMED_PIPE* pNamedPipe) { - size_t index = 0; NamedPipeServerSocketEntry* baseSocket = NULL; if (!pNamedPipe) @@ -525,7 +524,7 @@ static void winpr_unref_named_pipe(WINPR_NAMED_PIPE* pNamedPipe) // WLog_VRB(TAG, "%p (%s)", (void*) pNamedPipe, pNamedPipe->name); ArrayList_Lock(g_NamedPipeServerSockets); - for (index = 0; index < ArrayList_Count(g_NamedPipeServerSockets); index++) + for (size_t index = 0; index < ArrayList_Count(g_NamedPipeServerSockets); index++) { baseSocket = (NamedPipeServerSocketEntry*)ArrayList_GetItem(g_NamedPipeServerSockets, index); @@ -557,7 +556,6 @@ HANDLE CreateNamedPipeA(LPCSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD DWORD nOutBufferSize, DWORD nInBufferSize, DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES lpSecurityAttributes) { - size_t index = 0; char* lpPipePath = NULL; WINPR_NAMED_PIPE* pNamedPipe = NULL; int serverfd = -1; @@ -608,7 +606,7 @@ HANDLE CreateNamedPipeA(LPCSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD pNamedPipe->ServerMode = TRUE; pNamedPipe->common.ops = &namedOps; - for (index = 0; index < ArrayList_Count(g_NamedPipeServerSockets); index++) + for (size_t index = 0; index < ArrayList_Count(g_NamedPipeServerSockets); index++) { baseSocket = (NamedPipeServerSocketEntry*)ArrayList_GetItem(g_NamedPipeServerSockets, index); diff --git a/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipe.c b/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipe.c index a3579afba..8c8ead2c0 100644 --- a/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipe.c +++ b/winpr/libwinpr/pipe/test/TestPipeCreateNamedPipe.c @@ -195,13 +195,12 @@ static DWORD WINAPI named_pipe_single_thread(LPVOID arg) HANDLE clients[TESTNUMPIPESST] = { 0 }; DWORD dwRead = 0; DWORD dwWritten = 0; - int i = 0; int numPipes = 0; BOOL bSuccess = FALSE; numPipes = TESTNUMPIPESST; WaitForSingleObject(ReadyEvent, INFINITE); - for (i = 0; i < numPipes; i++) + for (int i = 0; i < numPipes; i++) { if (!(servers[i] = CreateNamedPipe(lpszPipeNameSt, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT, @@ -215,7 +214,7 @@ static DWORD WINAPI named_pipe_single_thread(LPVOID arg) #ifndef _WIN32 - for (i = 0; i < numPipes; i++) + for (int i = 0; i < numPipes; i++) { WINPR_NAMED_PIPE* p = (WINPR_NAMED_PIPE*)servers[i]; @@ -249,7 +248,7 @@ static DWORD WINAPI named_pipe_single_thread(LPVOID arg) #endif - for (i = 0; i < numPipes; i++) + for (int i = 0; i < numPipes; i++) { BOOL fConnected = 0; if ((clients[i] = CreateFile(lpszPipeNameSt, GENERIC_READ | GENERIC_WRITE, 0, NULL, @@ -279,7 +278,7 @@ static DWORD WINAPI named_pipe_single_thread(LPVOID arg) #ifndef _WIN32 - for (i = 0; i < numPipes; i++) + for (int i = 0; i < numPipes; i++) { WINPR_NAMED_PIPE* p = servers[i]; @@ -297,7 +296,7 @@ static DWORD WINAPI named_pipe_single_thread(LPVOID arg) } } - for (i = 0; i < numPipes; i++) + for (int i = 0; i < numPipes; i++) { { char sndbuf[PIPE_BUFFER_SIZE] = { 0 }; @@ -358,7 +357,7 @@ static DWORD WINAPI named_pipe_single_thread(LPVOID arg) * After DisconnectNamedPipe on server end * ReadFile/WriteFile must fail on client end */ - i = numPipes - 1; + int i = numPipes - 1; DisconnectNamedPipe(servers[i]); { char sndbuf[PIPE_BUFFER_SIZE] = { 0 }; @@ -445,7 +444,7 @@ static DWORD WINAPI named_pipe_single_thread(LPVOID arg) numPipes--; /* Close all remaining pipes */ - for (i = 0; i < numPipes; i++) + for (int i = 0; i < numPipes; i++) { DisconnectNamedPipe(servers[i]); CloseHandle(servers[i]); diff --git a/winpr/libwinpr/pool/pool.c b/winpr/libwinpr/pool/pool.c index 5e199f1b3..6c66b423a 100644 --- a/winpr/libwinpr/pool/pool.c +++ b/winpr/libwinpr/pool/pool.c @@ -104,7 +104,6 @@ static void threads_close(void* thread) static BOOL InitializeThreadpool(PTP_POOL pool) { BOOL rc = FALSE; - int index = 0; wObject* obj = NULL; HANDLE thread = NULL; @@ -129,7 +128,7 @@ static BOOL InitializeThreadpool(PTP_POOL pool) obj = ArrayList_Object(pool->Threads); obj->fnObjectFree = threads_close; - for (index = 0; index < 4; index++) + for (int index = 0; index < 4; index++) { if (!(thread = CreateThread(NULL, 0, thread_pool_work_func, (void*)pool, 0, NULL))) { diff --git a/winpr/libwinpr/pool/test/TestPoolWork.c b/winpr/libwinpr/pool/test/TestPoolWork.c index 779e9e001..ec50a229e 100644 --- a/winpr/libwinpr/pool/test/TestPoolWork.c +++ b/winpr/libwinpr/pool/test/TestPoolWork.c @@ -8,11 +8,10 @@ static LONG count = 0; static void CALLBACK test_WorkCallback(PTP_CALLBACK_INSTANCE instance, void* context, PTP_WORK work) { - int index = 0; printf("Hello %s: %03" PRId32 " (thread: 0x%08" PRIX32 ")\n", (char*)context, InterlockedIncrement(&count), GetCurrentThreadId()); - for (index = 0; index < 100; index++) + for (int index = 0; index < 100; index++) { BYTE a[1024]; BYTE b[1024]; @@ -28,7 +27,6 @@ static void CALLBACK test_WorkCallback(PTP_CALLBACK_INSTANCE instance, void* con static BOOL test1(void) { - int index = 0; PTP_WORK work = NULL; printf("Global Thread Pool\n"); work = CreateThreadpoolWork(test_WorkCallback, "world", NULL); @@ -45,7 +43,7 @@ static BOOL test1(void) * thread pool may throttle the threads. */ - for (index = 0; index < 10; index++) + for (int index = 0; index < 10; index++) SubmitThreadpoolWork(work); WaitForThreadpoolWorkCallbacks(work, FALSE); @@ -56,7 +54,6 @@ static BOOL test1(void) static BOOL test2(void) { BOOL rc = FALSE; - int index = 0; PTP_POOL pool = NULL; PTP_WORK work = NULL; PTP_CLEANUP_GROUP cleanupGroup = NULL; @@ -95,7 +92,7 @@ static BOOL test2(void) goto fail; } - for (index = 0; index < 10; index++) + for (int index = 0; index < 10; index++) SubmitThreadpoolWork(work); WaitForThreadpoolWorkCallbacks(work, FALSE); diff --git a/winpr/libwinpr/registry/registry_reg.c b/winpr/libwinpr/registry/registry_reg.c index 42d1a7f54..a1803b649 100644 --- a/winpr/libwinpr/registry/registry_reg.c +++ b/winpr/libwinpr/registry/registry_reg.c @@ -132,7 +132,6 @@ static void reg_load_finish(Reg* reg) static RegVal* reg_load_value(const Reg* reg, RegKey* key) { - size_t index = 0; const char* p[5] = { 0 }; size_t length = 0; char* name = NULL; @@ -179,7 +178,7 @@ static RegVal* reg_load_value(const Reg* reg, RegKey* key) value->name = name; value->type = REG_NONE; - for (index = 0; index < ARRAYSIZE(REG_DATA_TYPE_TABLE); index++) + for (size_t index = 0; index < ARRAYSIZE(REG_DATA_TYPE_TABLE); index++) { const struct reg_data_type* current = ®_DATA_TYPE_TABLE[index]; WINPR_ASSERT(current->tag); diff --git a/winpr/libwinpr/rpc/rpc.c b/winpr/libwinpr/rpc/rpc.c index 9977fd89c..99c2c7ebd 100644 --- a/winpr/libwinpr/rpc/rpc.c +++ b/winpr/libwinpr/rpc/rpc.c @@ -731,7 +731,6 @@ RPC_STATUS UuidToStringW(const UUID* Uuid, RPC_WSTR* StringUuid) RPC_STATUS UuidFromStringA(RPC_CSTR StringUuid, UUID* Uuid) { - int index = 0; BYTE bin[36]; if (!StringUuid) @@ -746,7 +745,7 @@ RPC_STATUS UuidFromStringA(RPC_CSTR StringUuid, UUID* Uuid) return RPC_S_INVALID_STRING_UUID; } - for (index = 0; index < 36; index++) + for (int index = 0; index < 36; index++) { if ((index == 8) || (index == 13) || (index == 18) || (index == 23)) continue; @@ -784,7 +783,6 @@ RPC_STATUS UuidFromStringW(RPC_WSTR StringUuid, UUID* Uuid) signed int UuidCompare(const UUID* Uuid1, const UUID* Uuid2, RPC_STATUS* Status) { - int index = 0; *Status = RPC_S_OK; if (!Uuid1) @@ -802,7 +800,7 @@ signed int UuidCompare(const UUID* Uuid1, const UUID* Uuid2, RPC_STATUS* Status) if (Uuid1->Data3 != Uuid2->Data3) return (Uuid1->Data3 < Uuid2->Data3) ? -1 : 1; - for (index = 0; index < 8; index++) + for (int index = 0; index < 8; index++) { if (Uuid1->Data4[index] != Uuid2->Data4[index]) return (Uuid1->Data4[index] < Uuid2->Data4[index]) ? -1 : 1; diff --git a/winpr/libwinpr/smartcard/smartcard_pcsc.c b/winpr/libwinpr/smartcard/smartcard_pcsc.c index 99c1e429a..fb04d5684 100644 --- a/winpr/libwinpr/smartcard/smartcard_pcsc.c +++ b/winpr/libwinpr/smartcard/smartcard_pcsc.c @@ -1048,9 +1048,7 @@ static PcscKnownAtr knownAtrs[] = { static const char* findCardByAtr(LPCBYTE pbAtr) { - size_t i = 0; - - for (i = 0; i < ARRAY_LENGTH(knownAtrs); i++) + for (size_t i = 0; i < ARRAY_LENGTH(knownAtrs); i++) { if (memcmp(knownAtrs[i].atr, pbAtr, knownAtrs[i].atrLen) == 0) return knownAtrs[i].cardName; @@ -1524,8 +1522,6 @@ static LONG WINAPI PCSC_SCardGetStatusChange_Internal(SCARDCONTEXT hContext, DWO LPSCARD_READERSTATEA rgReaderStates, DWORD cReaders) { - PCSC_DWORD i = 0; - PCSC_DWORD j = 0; INT64* map = NULL; PCSC_DWORD cMappedReaders = 0; PCSC_SCARD_READERSTATE* states = NULL; @@ -1567,7 +1563,8 @@ static LONG WINAPI PCSC_SCardGetStatusChange_Internal(SCARDCONTEXT hContext, DWO return SCARD_E_NO_MEMORY; } - for (i = j = 0; i < pcsc_cReaders; i++) + PCSC_DWORD j = 0; + for (PCSC_DWORD i = 0; i < pcsc_cReaders; i++) { if (!g_PnP_Notification) { @@ -1602,12 +1599,12 @@ static LONG WINAPI PCSC_SCardGetStatusChange_Internal(SCARDCONTEXT hContext, DWO status = SCARD_S_SUCCESS; } - for (i = 0; i < pcsc_cReaders; i++) + for (PCSC_DWORD i = 0; i < pcsc_cReaders; i++) { if (map[i] < 0) continue; /* unmapped */ - j = (PCSC_DWORD)map[i]; + 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); @@ -1638,7 +1635,6 @@ static LONG WINAPI PCSC_SCardGetStatusChangeA(SCARDCONTEXT hContext, DWORD dwTim static LONG WINAPI PCSC_SCardGetStatusChangeW(SCARDCONTEXT hContext, DWORD dwTimeout, LPSCARD_READERSTATEW rgReaderStates, DWORD cReaders) { - DWORD index = 0; LPSCARD_READERSTATEA states = NULL; LONG status = SCARD_S_SUCCESS; @@ -1656,7 +1652,7 @@ static LONG WINAPI PCSC_SCardGetStatusChangeW(SCARDCONTEXT hContext, DWORD dwTim return SCARD_E_NO_MEMORY; } - for (index = 0; index < cReaders; index++) + for (DWORD index = 0; index < cReaders; index++) { const LPSCARD_READERSTATEW curReader = &rgReaderStates[index]; LPSCARD_READERSTATEA cur = &states[index]; @@ -1671,7 +1667,7 @@ static LONG WINAPI PCSC_SCardGetStatusChangeW(SCARDCONTEXT hContext, DWORD dwTim status = PCSC_SCardGetStatusChange_Internal(hContext, dwTimeout, states, cReaders); - for (index = 0; index < cReaders; index++) + for (DWORD index = 0; index < cReaders; index++) { free((void*)states[index].szReader); rgReaderStates[index].pvUserData = states[index].pvUserData; @@ -2315,7 +2311,6 @@ static LONG WINAPI PCSC_SCardControl(SCARDHANDLE hCard, DWORD dwControlCode, LPC if (getFeatureRequest) { - UINT32 index = 0; UINT32 count = 0; PCSC_TLV_STRUCTURE* tlv = (PCSC_TLV_STRUCTURE*)lpOutBuffer; @@ -2324,7 +2319,7 @@ static LONG WINAPI PCSC_SCardControl(SCARDHANDLE hCard, DWORD dwControlCode, LPC count = *lpBytesReturned / sizeof(PCSC_TLV_STRUCTURE); - for (index = 0; index < count; index++) + for (DWORD index = 0; index < count; index++) { if (tlv[index].length != 4) return SCARD_E_UNEXPECTED; diff --git a/winpr/libwinpr/sspi/NTLM/ntlm.c b/winpr/libwinpr/sspi/NTLM/ntlm.c index 36671d534..6a2ee6a3c 100644 --- a/winpr/libwinpr/sspi/NTLM/ntlm.c +++ b/winpr/libwinpr/sspi/NTLM/ntlm.c @@ -579,9 +579,7 @@ ntlm_AcceptSecurityContext(PCredHandle phCredential, PCtxtHandle phContext, PSec if (pOutput) { - ULONG i = 0; - - for (i = 0; i < pOutput->cBuffers; i++) + for (ULONG i = 0; i < pOutput->cBuffers; i++) { pOutput->pBuffers[i].cbBuffer = 0; pOutput->pBuffers[i].BufferType = SECBUFFER_TOKEN; diff --git a/winpr/libwinpr/sspi/NTLM/ntlm_message.c b/winpr/libwinpr/sspi/NTLM/ntlm_message.c index 89e57e55c..511ca4765 100644 --- a/winpr/libwinpr/sspi/NTLM/ntlm_message.c +++ b/winpr/libwinpr/sspi/NTLM/ntlm_message.c @@ -127,11 +127,9 @@ static void ntlm_print_message_fields(const NTLM_MESSAGE_FIELDS* fields, const c static void ntlm_print_negotiate_flags(UINT32 flags) { - int i = 0; - WLog_VRB(TAG, "negotiateFlags \"0x%08" PRIX32 "\"", flags); - for (i = 31; i >= 0; i--) + for (int i = 31; i >= 0; i--) { if ((flags >> i) & 1) { diff --git a/winpr/libwinpr/sspi/sspi_winpr.c b/winpr/libwinpr/sspi/sspi_winpr.c index f990dac47..197865003 100644 --- a/winpr/libwinpr/sspi/sspi_winpr.c +++ b/winpr/libwinpr/sspi/sspi_winpr.c @@ -155,10 +155,9 @@ static void sspi_ContextBufferAllocTableFree(void) static void* sspi_ContextBufferAlloc(UINT32 allocatorIndex, size_t size) { - UINT32 index = 0; void* contextBuffer = NULL; - for (index = 0; index < ContextBufferAllocTable.cMaxEntries; index++) + for (UINT32 index = 0; index < ContextBufferAllocTable.cMaxEntries; index++) { if (!ContextBufferAllocTable.entries[index].contextBuffer) { @@ -931,10 +930,9 @@ int sspi_CopyAuthIdentity(SEC_WINNT_AUTH_IDENTITY* identity, PSecBuffer sspi_FindSecBuffer(PSecBufferDesc pMessage, ULONG BufferType) { - ULONG index = 0; PSecBuffer pSecBuffer = NULL; - for (index = 0; index < pMessage->cBuffers; index++) + for (UINT32 index = 0; index < pMessage->cBuffers; index++) { if (pMessage->pBuffers[index].BufferType == BufferType) { @@ -989,11 +987,9 @@ void sspi_GlobalFinish(void) static const SecurityFunctionTableA* sspi_GetSecurityFunctionTableAByNameA(const SEC_CHAR* Name) { - int index = 0; - UINT32 cPackages = 0; - cPackages = sizeof(SecPkgInfoA_LIST) / sizeof(*(SecPkgInfoA_LIST)); + size_t cPackages = sizeof(SecPkgInfoA_LIST) / sizeof(*(SecPkgInfoA_LIST)); - for (index = 0; index < (int)cPackages; index++) + for (size_t index = 0; index < cPackages; index++) { if (strcmp(Name, SecurityFunctionTableA_NAME_LIST[index].Name) == 0) { @@ -1007,11 +1003,9 @@ static const SecurityFunctionTableA* sspi_GetSecurityFunctionTableAByNameA(const static const SecurityFunctionTableW* sspi_GetSecurityFunctionTableWByNameW(const SEC_WCHAR* Name) { - int index = 0; - UINT32 cPackages = 0; - cPackages = sizeof(SecPkgInfoW_LIST) / sizeof(*(SecPkgInfoW_LIST)); + size_t cPackages = sizeof(SecPkgInfoW_LIST) / sizeof(*(SecPkgInfoW_LIST)); - for (index = 0; index < (int)cPackages; index++) + for (size_t index = 0; index < cPackages; index++) { if (_wcscmp(Name, SecurityFunctionTableW_NAME_LIST[index].Name) == 0) { @@ -1046,10 +1040,9 @@ static void FreeContextBuffer_QuerySecurityPackageInfo(void* contextBuffer); static void sspi_ContextBufferFree(void* contextBuffer) { - UINT32 index = 0; UINT32 allocatorIndex = 0; - for (index = 0; index < ContextBufferAllocTable.cMaxEntries; index++) + for (size_t index = 0; index < ContextBufferAllocTable.cMaxEntries; index++) { if (contextBuffer == ContextBufferAllocTable.entries[index].contextBuffer) { @@ -1082,7 +1075,6 @@ static void sspi_ContextBufferFree(void* contextBuffer) static SECURITY_STATUS SEC_ENTRY winpr_EnumerateSecurityPackagesW(ULONG* pcPackages, PSecPkgInfoW* ppPackageInfo) { - int index = 0; size_t size = 0; UINT32 cPackages = 0; SecPkgInfoW* pPackageInfo = NULL; @@ -1093,7 +1085,7 @@ static SECURITY_STATUS SEC_ENTRY winpr_EnumerateSecurityPackagesW(ULONG* pcPacka if (!pPackageInfo) return SEC_E_INSUFFICIENT_MEMORY; - for (index = 0; index < (int)cPackages; index++) + for (size_t index = 0; index < cPackages; index++) { pPackageInfo[index].fCapabilities = SecPkgInfoW_LIST[index]->fCapabilities; pPackageInfo[index].wVersion = SecPkgInfoW_LIST[index]->wVersion; @@ -1111,7 +1103,6 @@ static SECURITY_STATUS SEC_ENTRY winpr_EnumerateSecurityPackagesW(ULONG* pcPacka static SECURITY_STATUS SEC_ENTRY winpr_EnumerateSecurityPackagesA(ULONG* pcPackages, PSecPkgInfoA* ppPackageInfo) { - int index = 0; size_t size = 0; UINT32 cPackages = 0; SecPkgInfoA* pPackageInfo = NULL; @@ -1122,7 +1113,7 @@ static SECURITY_STATUS SEC_ENTRY winpr_EnumerateSecurityPackagesA(ULONG* pcPacka if (!pPackageInfo) return SEC_E_INSUFFICIENT_MEMORY; - for (index = 0; index < (int)cPackages; index++) + for (size_t index = 0; index < cPackages; index++) { pPackageInfo[index].fCapabilities = SecPkgInfoA_LIST[index]->fCapabilities; pPackageInfo[index].wVersion = SecPkgInfoA_LIST[index]->wVersion; @@ -1145,7 +1136,6 @@ static SECURITY_STATUS SEC_ENTRY winpr_EnumerateSecurityPackagesA(ULONG* pcPacka static void FreeContextBuffer_EnumerateSecurityPackages(void* contextBuffer) { - int index = 0; UINT32 cPackages = 0; SecPkgInfoA* pPackageInfo = (SecPkgInfoA*)contextBuffer; cPackages = sizeof(SecPkgInfoA_LIST) / sizeof(*(SecPkgInfoA_LIST)); @@ -1153,7 +1143,7 @@ static void FreeContextBuffer_EnumerateSecurityPackages(void* contextBuffer) if (!pPackageInfo) return; - for (index = 0; index < (int)cPackages; index++) + for (size_t index = 0; index < cPackages; index++) { free(pPackageInfo[index].Name); free(pPackageInfo[index].Comment); @@ -1175,13 +1165,11 @@ SecurityFunctionTableA* SEC_ENTRY winpr_InitSecurityInterfaceA(void) static SECURITY_STATUS SEC_ENTRY winpr_QuerySecurityPackageInfoW(SEC_WCHAR* pszPackageName, PSecPkgInfoW* ppPackageInfo) { - int index = 0; size_t size = 0; - UINT32 cPackages = 0; SecPkgInfoW* pPackageInfo = NULL; - cPackages = sizeof(SecPkgInfoW_LIST) / sizeof(*(SecPkgInfoW_LIST)); + size_t cPackages = sizeof(SecPkgInfoW_LIST) / sizeof(*(SecPkgInfoW_LIST)); - for (index = 0; index < (int)cPackages; index++) + for (size_t index = 0; index < cPackages; index++) { if (_wcscmp(pszPackageName, SecPkgInfoW_LIST[index]->Name) == 0) { @@ -1210,13 +1198,11 @@ static SECURITY_STATUS SEC_ENTRY winpr_QuerySecurityPackageInfoW(SEC_WCHAR* pszP static SECURITY_STATUS SEC_ENTRY winpr_QuerySecurityPackageInfoA(SEC_CHAR* pszPackageName, PSecPkgInfoA* ppPackageInfo) { - int index = 0; size_t size = 0; - UINT32 cPackages = 0; SecPkgInfoA* pPackageInfo = NULL; - cPackages = sizeof(SecPkgInfoA_LIST) / sizeof(*(SecPkgInfoA_LIST)); + size_t cPackages = sizeof(SecPkgInfoA_LIST) / sizeof(*(SecPkgInfoA_LIST)); - for (index = 0; index < (int)cPackages; index++) + for (size_t index = 0; index < cPackages; index++) { if (strcmp(pszPackageName, SecPkgInfoA_LIST[index]->Name) == 0) { diff --git a/winpr/libwinpr/sspi/test/TestEnumerateSecurityPackages.c b/winpr/libwinpr/sspi/test/TestEnumerateSecurityPackages.c index 316403ba1..9de23c09e 100644 --- a/winpr/libwinpr/sspi/test/TestEnumerateSecurityPackages.c +++ b/winpr/libwinpr/sspi/test/TestEnumerateSecurityPackages.c @@ -7,7 +7,6 @@ int TestEnumerateSecurityPackages(int argc, char* argv[]) { - int index = 0; ULONG cPackages = 0; SECURITY_STATUS status = 0; SecPkgInfo* pPackageInfo = NULL; @@ -29,7 +28,7 @@ int TestEnumerateSecurityPackages(int argc, char* argv[]) _tprintf(_T("\nEnumerateSecurityPackages (%") _T(PRIu32) _T("):\n"), cPackages); - for (index = 0; index < (int)cPackages; index++) + for (size_t index = 0; index < cPackages; index++) { _tprintf(_T("\"%s\", \"%s\"\n"), pPackageInfo[index].Name, pPackageInfo[index].Comment); } diff --git a/winpr/libwinpr/sspi/test/TestSchannel.c b/winpr/libwinpr/sspi/test/TestSchannel.c index 5b377f94a..3f9751a98 100644 --- a/winpr/libwinpr/sspi/test/TestSchannel.c +++ b/winpr/libwinpr/sspi/test/TestSchannel.c @@ -592,7 +592,6 @@ out_fail: int TestSchannel(int argc, char* argv[]) { int count; - DWORD index; ALG_ID algId; HANDLE thread; BYTE* lpTokenIn; @@ -682,7 +681,7 @@ int TestSchannel(int argc, char* argv[]) */ printf("SupportedAlgs: %" PRIu32 "\n", SupportedAlgs.cSupportedAlgs); - for (index = 0; index < SupportedAlgs.cSupportedAlgs; index++) + for (DWORD index = 0; index < SupportedAlgs.cSupportedAlgs; index++) { algId = SupportedAlgs.palgSupportedAlgs[index]; printf("\t0x%08" PRIX32 " CLASS: %" PRIu32 " TYPE: %" PRIu32 " SID: %" PRIu32 "\n", algId, @@ -831,7 +830,7 @@ int TestSchannel(int argc, char* argv[]) sizeof(test_DummyMessage)) < 0) break; - for (index = 0; index < sizeof(test_DummyMessage); index++) + for (DWORD index = 0; index < sizeof(test_DummyMessage); index++) { BYTE b, ln, hn; b = test_DummyMessage[index]; diff --git a/winpr/libwinpr/synch/event.c b/winpr/libwinpr/synch/event.c index 12c42389c..7204add28 100644 --- a/winpr/libwinpr/synch/event.c +++ b/winpr/libwinpr/synch/event.c @@ -56,13 +56,12 @@ static void dump_event(WINPR_EVENT* event, size_t index) { char** msg = NULL; size_t used = 0; - size_t i = 0; #if 0 void* stack = winpr_backtrace(20); WLog_DBG(TAG, "Called from:"); msg = winpr_backtrace_symbols(stack, &used); - for (i = 0; i < used; i++) + for (size_t i = 0; i < used; i++) WLog_DBG(TAG, "[%" PRIdz "]: %s", i, msg[i]); free(msg); @@ -71,7 +70,7 @@ static void dump_event(WINPR_EVENT* event, size_t index) WLog_DBG(TAG, "Event handle created still not closed! [%" PRIuz ", %p]", index, event); msg = winpr_backtrace_symbols(event->create_stack, &used); - for (i = 2; i < used; i++) + for (size_t i = 2; i < used; i++) WLog_DBG(TAG, "[%" PRIdz "]: %s", i, msg[i]); free(msg); @@ -564,9 +563,8 @@ void DumpEventHandles_(const char* fkt, const char* file, size_t line) int rc = getrlimit(RLIMIT_NOFILE, &r); if (rc >= 0) { - rlim_t x = 0; size_t count = 0; - for (x = 0; x < r.rlim_cur; x++) + for (rlim_t x = 0; x < r.rlim_cur; x++) { int flags = fcntl(x, F_GETFD); if (flags >= 0) diff --git a/winpr/libwinpr/synch/mutex.c b/winpr/libwinpr/synch/mutex.c index 7db58c26d..6a85db676 100644 --- a/winpr/libwinpr/synch/mutex.c +++ b/winpr/libwinpr/synch/mutex.c @@ -70,7 +70,6 @@ BOOL MutexCloseHandle(HANDLE handle) #if defined(WITH_DEBUG_MUTEX) { size_t used = 0; - size_t i = 0; void* stack = winpr_backtrace(20); char** msg = NULL; @@ -79,7 +78,7 @@ BOOL MutexCloseHandle(HANDLE handle) if (msg) { - for (i = 0; i < used; i++) + for (size_t i = 0; i < used; i++) WLog_ERR(TAG, "%2" PRIdz ": %s", i, msg[i]); } diff --git a/winpr/libwinpr/synch/test/TestSynchBarrier.c b/winpr/libwinpr/synch/test/TestSynchBarrier.c index f4c33331f..b1c91c9a5 100644 --- a/winpr/libwinpr/synch/test/TestSynchBarrier.c +++ b/winpr/libwinpr/synch/test/TestSynchBarrier.c @@ -26,7 +26,6 @@ static DWORD WINAPI test_synch_barrier_thread(LPVOID lpParam) { BOOL status = FALSE; struct test_params* p = (struct test_params*)lpParam; - DWORD i = 0; InterlockedIncrement(&p->threadCount); @@ -41,7 +40,7 @@ static DWORD WINAPI test_synch_barrier_thread(LPVOID lpParam) // printf("Thread #%03u unblocked.\n", tnum); - for (i = 0; i < p->loops && gErrorCount == 0; i++) + for (DWORD i = 0; i < p->loops && gErrorCount == 0; i++) { /* simulate different execution times before the barrier */ Sleep(1 + abs((rand() % MAX_SLEEP_MS))); @@ -66,7 +65,6 @@ static BOOL TestSynchBarrierWithFlags(DWORD dwFlags, DWORD dwThreads, DWORD dwLo DWORD dwStatus = 0; DWORD expectedTrueCount = 0; DWORD expectedFalseCount = 0; - DWORD i = 0; p.threadCount = 0; p.trueCount = 0; p.falseCount = 0; @@ -101,7 +99,8 @@ static BOOL TestSynchBarrierWithFlags(DWORD dwFlags, DWORD dwThreads, DWORD dwLo return FALSE; } - for (i = 0; i < dwThreads; i++) + DWORD i = 0; + for (; i < dwThreads; i++) { if (!(threads[i] = CreateThread(NULL, 0, test_synch_barrier_thread, &p, 0, NULL))) { diff --git a/winpr/libwinpr/synch/test/TestSynchCritical.c b/winpr/libwinpr/synch/test/TestSynchCritical.c index 670b33712..9d56356ef 100644 --- a/winpr/libwinpr/synch/test/TestSynchCritical.c +++ b/winpr/libwinpr/synch/test/TestSynchCritical.c @@ -44,8 +44,6 @@ static BOOL TestSynchCritical_TriggerAndCheckRaceCondition(HANDLE OwningThread, * FALSE */ static DWORD WINAPI TestSynchCritical_Test1(LPVOID arg) { - int i = 0; - int j = 0; int rc = 0; HANDLE hThread = (HANDLE)(ULONG_PTR)GetCurrentThreadId(); @@ -61,14 +59,14 @@ static DWORD WINAPI TestSynchCritical_Test1(LPVOID arg) return 1; /* add some random recursion level */ - j = rand() % 5; - for (i = 0; i < j; i++) + int j = rand() % 5; + for (int i = 0; i < j; i++) { if (!TestSynchCritical_TriggerAndCheckRaceCondition(hThread, rc++)) return 2; EnterCriticalSection(&critical); } - for (i = 0; i < j; i++) + for (int i = 0; i < j; i++) { if (!TestSynchCritical_TriggerAndCheckRaceCondition(hThread, rc--)) return 2; @@ -99,8 +97,6 @@ static DWORD WINAPI TestSynchCritical_Test2(LPVOID arg) static DWORD WINAPI TestSynchCritical_Main(LPVOID arg) { - int i = 0; - int j = 0; SYSTEM_INFO sysinfo; DWORD dwPreviousSpinCount = 0; DWORD dwSpinCount = 0; @@ -159,7 +155,8 @@ static DWORD WINAPI TestSynchCritical_Main(LPVOID arg) InitializeCriticalSection(&critical); - for (i = 0; i < 10; i++) + int i = 0; + for (; i < 10; i++) { if (critical.RecursionCount != i) { @@ -218,7 +215,7 @@ static DWORD WINAPI TestSynchCritical_Main(LPVOID arg) goto fail; } - for (j = 0; j < TEST_SYNC_CRITICAL_TEST1_RUNS; j++) + for (int j = 0; j < TEST_SYNC_CRITICAL_TEST1_RUNS; j++) { dwSpinCount = j * 100; InitializeCriticalSectionAndSpinCount(&critical, dwSpinCount); @@ -228,7 +225,7 @@ static DWORD WINAPI TestSynchCritical_Main(LPVOID arg) /* the TestSynchCritical_Test1 threads shall run until bTest1Running is FALSE */ bTest1Running = TRUE; - for (i = 0; i < (int)dwThreadCount; i++) + for (int i = 0; i < (int)dwThreadCount; i++) { if (!(hThreads[i] = CreateThread(NULL, 0, TestSynchCritical_Test1, &bTest1Running, 0, NULL))) @@ -242,7 +239,7 @@ static DWORD WINAPI TestSynchCritical_Main(LPVOID arg) Sleep(TEST_SYNC_CRITICAL_TEST1_RUNTIME_MS); bTest1Running = FALSE; - for (i = 0; i < (int)dwThreadCount; i++) + for (int i = 0; i < (int)dwThreadCount; i++) { if (WaitForSingleObject(hThreads[i], INFINITE) != WAIT_OBJECT_0) { @@ -317,7 +314,6 @@ int TestSynchCritical(int argc, char* argv[]) HANDLE hThread = NULL; DWORD dwThreadExitCode = 0; DWORD dwDeadLockDetectionTimeMs = 0; - DWORD i = 0; WINPR_UNUSED(argc); WINPR_UNUSED(argv); @@ -341,7 +337,7 @@ int TestSynchCritical(int argc, char* argv[]) * Workaround checking the value of bThreadTerminated which is passed in the thread arg */ - for (i = 0; i < dwDeadLockDetectionTimeMs; i += 10) + for (DWORD i = 0; i < dwDeadLockDetectionTimeMs; i += 10) { if (bThreadTerminated) break; diff --git a/winpr/libwinpr/synch/test/TestSynchEvent.c b/winpr/libwinpr/synch/test/TestSynchEvent.c index 1c6a670e2..083282ca4 100644 --- a/winpr/libwinpr/synch/test/TestSynchEvent.c +++ b/winpr/libwinpr/synch/test/TestSynchEvent.c @@ -5,7 +5,6 @@ int TestSynchEvent(int argc, char* argv[]) { HANDLE event = NULL; - int i = 0; WINPR_UNUSED(argc); WINPR_UNUSED(argv); if (ResetEvent(NULL)) @@ -65,7 +64,7 @@ int TestSynchEvent(int argc, char* argv[]) return -1; } - for (i = 0; i < 10000; i++) + for (int i = 0; i < 10000; i++) { if (!SetEvent(event)) { diff --git a/winpr/libwinpr/synch/test/TestSynchInit.c b/winpr/libwinpr/synch/test/TestSynchInit.c index 5230a9f36..20da41515 100644 --- a/winpr/libwinpr/synch/test/TestSynchInit.c +++ b/winpr/libwinpr/synch/test/TestSynchInit.c @@ -69,7 +69,6 @@ int TestSynchInit(int argc, char* argv[]) { HANDLE hThreads[TEST_NUM_THREADS]; DWORD dwCreatedThreads = 0; - DWORD i = 0; BOOL result = FALSE; WINPR_UNUSED(argc); @@ -99,7 +98,7 @@ int TestSynchInit(int argc, char* argv[]) goto out; } - for (i = 0; i < TEST_NUM_THREADS; i++) + for (DWORD i = 0; i < TEST_NUM_THREADS; i++) { if (!(hThreads[i] = CreateThread(NULL, 0, TestThreadFunction, NULL, 0, NULL))) { @@ -113,7 +112,7 @@ int TestSynchInit(int argc, char* argv[]) Sleep(100); SetEvent(hStartEvent); - for (i = 0; i < dwCreatedThreads; i++) + for (DWORD i = 0; i < dwCreatedThreads; i++) { if (WaitForSingleObject(hThreads[i], INFINITE) != WAIT_OBJECT_0) { @@ -148,7 +147,7 @@ out: CloseHandle(hStartEvent); - for (i = 0; i < dwCreatedThreads; i++) + for (DWORD i = 0; i < dwCreatedThreads; i++) { CloseHandle(hThreads[i]); } diff --git a/winpr/libwinpr/synch/test/TestSynchMutex.c b/winpr/libwinpr/synch/test/TestSynchMutex.c index 7255d5dc4..296c3714a 100644 --- a/winpr/libwinpr/synch/test/TestSynchMutex.c +++ b/winpr/libwinpr/synch/test/TestSynchMutex.c @@ -47,7 +47,6 @@ static BOOL test_mutex_recursive(void) { HANDLE mutex = NULL; DWORD rc = 0; - DWORD i = 0; DWORD cnt = 50; if (!(mutex = CreateMutex(NULL, TRUE, NULL))) @@ -56,7 +55,7 @@ static BOOL test_mutex_recursive(void) return FALSE; } - for (i = 0; i < cnt; i++) + for (UINT32 i = 0; i < cnt; i++) { rc = WaitForSingleObject(mutex, INFINITE); @@ -68,7 +67,7 @@ static BOOL test_mutex_recursive(void) } } - for (i = 0; i < cnt; i++) + for (UINT32 i = 0; i < cnt; i++) { if (!ReleaseMutex(mutex)) { diff --git a/winpr/libwinpr/synch/test/TestSynchThread.c b/winpr/libwinpr/synch/test/TestSynchThread.c index 3ba1edd82..58f7cb080 100644 --- a/winpr/libwinpr/synch/test/TestSynchThread.c +++ b/winpr/libwinpr/synch/test/TestSynchThread.c @@ -15,7 +15,6 @@ int TestSynchThread(int argc, char* argv[]) { DWORD rc = 0; HANDLE thread = NULL; - int i = 0; WINPR_UNUSED(argc); WINPR_UNUSED(argv); @@ -56,7 +55,7 @@ int TestSynchThread(int argc, char* argv[]) } /* check that WaitForSingleObject works multiple times on a terminated thread */ - for (i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { rc = WaitForSingleObject(thread, 0); if (WAIT_OBJECT_0 != rc) diff --git a/winpr/libwinpr/synch/test/TestSynchTimerQueue.c b/winpr/libwinpr/synch/test/TestSynchTimerQueue.c index 1e513facf..08cc95738 100644 --- a/winpr/libwinpr/synch/test/TestSynchTimerQueue.c +++ b/winpr/libwinpr/synch/test/TestSynchTimerQueue.c @@ -52,7 +52,6 @@ static VOID CALLBACK TimerRoutine(PVOID lpParam, BOOLEAN TimerOrWaitFired) int TestSynchTimerQueue(int argc, char* argv[]) { - DWORD index = 0; HANDLE hTimerQueue = NULL; HANDLE hTimers[TIMER_COUNT]; APC_DATA apcData[TIMER_COUNT]; @@ -68,7 +67,7 @@ int TestSynchTimerQueue(int argc, char* argv[]) return -1; } - for (index = 0; index < TIMER_COUNT; index++) + for (DWORD index = 0; index < TIMER_COUNT; index++) { apcData[index].TimerId = index; apcData[index].StartTime = GetTickCount(); @@ -92,7 +91,7 @@ int TestSynchTimerQueue(int argc, char* argv[]) } } - for (index = 0; index < TIMER_COUNT; index++) + for (DWORD index = 0; index < TIMER_COUNT; index++) { if (WaitForSingleObject(apcData[index].CompletionEvent, 2000) != WAIT_OBJECT_0) { @@ -102,7 +101,7 @@ int TestSynchTimerQueue(int argc, char* argv[]) } } - for (index = 0; index < TIMER_COUNT; index++) + for (DWORD index = 0; index < TIMER_COUNT; index++) { /** * Note: If the CompletionEvent parameter is INVALID_HANDLE_VALUE, the function waits diff --git a/winpr/libwinpr/synch/wait.c b/winpr/libwinpr/synch/wait.c index 561a62325..3bef657a2 100644 --- a/winpr/libwinpr/synch/wait.c +++ b/winpr/libwinpr/synch/wait.c @@ -351,7 +351,6 @@ DWORD WaitForMultipleObjectsEx(DWORD nCount, const HANDLE* lpHandles, BOOL bWait DWORD poll_map[MAXIMUM_WAIT_OBJECTS] = { 0 }; BOOL signalled_handles[MAXIMUM_WAIT_OBJECTS] = { FALSE }; int fd = -1; - DWORD index = 0; int status = -1; ULONG Type = 0; WINPR_HANDLE* Object = NULL; @@ -408,7 +407,8 @@ DWORD WaitForMultipleObjectsEx(DWORD nCount, const HANDLE* lpHandles, BOOL bWait polled = 0; /* first collect file descriptors to poll */ - for (index = 0; index < nCount; index++) + DWORD index = 0; + for (; index < nCount; index++) { if (bWaitAll) { @@ -493,7 +493,7 @@ DWORD WaitForMultipleObjectsEx(DWORD nCount, const HANDLE* lpHandles, BOOL bWait /* then treat pollset */ if (status) { - for (index = 0; index < polled; index++) + for (DWORD index = 0; index < polled; index++) { DWORD handlesIndex = 0; BOOL signal_set = FALSE; diff --git a/winpr/libwinpr/sysinfo/cpufeatures/cpu-features.c b/winpr/libwinpr/sysinfo/cpufeatures/cpu-features.c index b13832d25..8415d64de 100644 --- a/winpr/libwinpr/sysinfo/cpufeatures/cpu-features.c +++ b/winpr/libwinpr/sysinfo/cpufeatures/cpu-features.c @@ -428,7 +428,7 @@ static void cpulist_parse(CpuList* list, const char* line, int line_len) */ while (p < end && *p != '\n') { - int val, start_value, end_value; + int start_value, end_value; /* Find the end of current item, and put it into 'q' */ q = memchr(p, ',', end - p); @@ -457,7 +457,7 @@ static void cpulist_parse(CpuList* list, const char* line, int line_len) } /* Set bits CPU list bits */ - for (val = start_value; val <= end_value; val++) + for (int val = start_value; val <= end_value; val++) { cpulist_set(list, val); } @@ -973,10 +973,9 @@ static void android_cpuInit(void) { "CPU part", 'x', 4, 12 }, { "CPU revision", 'd', 0, 4 }, }; - size_t i; D("Parsing /proc/cpuinfo to recover CPUID\n"); - for (i = 0; i < sizeof(cpu_id_entries) / sizeof(cpu_id_entries[0]); ++i) + for (size_t i = 0; i < sizeof(cpu_id_entries) / sizeof(cpu_id_entries[0]); ++i) { const struct CpuIdEntry* entry = &cpu_id_entries[i]; char* value = extract_cpuinfo_field(cpuinfo, cpuinfo_len, entry->field); @@ -1022,9 +1021,8 @@ static void android_cpuInit(void) { 0x510006f2, ANDROID_CPU_ARM_FEATURE_IDIV_ARM | ANDROID_CPU_ARM_FEATURE_IDIV_THUMB2 }, { 0x510006f3, ANDROID_CPU_ARM_FEATURE_IDIV_ARM | ANDROID_CPU_ARM_FEATURE_IDIV_THUMB2 }, }; - size_t n; - for (n = 0; n < sizeof(cpu_fixes) / sizeof(cpu_fixes[0]); ++n) + for (size_t n = 0; n < sizeof(cpu_fixes) / sizeof(cpu_fixes[0]); ++n) { const struct CpuFix* entry = &cpu_fixes[n]; diff --git a/winpr/libwinpr/thread/apc.c b/winpr/libwinpr/thread/apc.c index b05eb8d62..96ff8c30f 100644 --- a/winpr/libwinpr/thread/apc.c +++ b/winpr/libwinpr/thread/apc.c @@ -187,7 +187,6 @@ out: int apc_executeCompletions(WINPR_THREAD* thread, WINPR_POLL_SET* set, size_t idx) { APC_QUEUE* apc = NULL; - WINPR_APC_ITEM* item = NULL; WINPR_APC_ITEM* nextItem = NULL; int ret = 0; @@ -200,7 +199,7 @@ int apc_executeCompletions(WINPR_THREAD* thread, WINPR_POLL_SET* set, size_t idx apc->treatingCompletions = TRUE; /* first pass to compute signaled items */ - for (item = apc->head; item; item = item->next) + for (WINPR_APC_ITEM* item = apc->head; item; item = item->next) { item->isSignaled = item->alwaysSignaled || pollset_isSignaled(set, idx); if (!item->alwaysSignaled) @@ -208,7 +207,7 @@ int apc_executeCompletions(WINPR_THREAD* thread, WINPR_POLL_SET* set, size_t idx } /* second pass: run completions */ - for (item = apc->head; item; item = nextItem) + for (WINPR_APC_ITEM* item = apc->head; item; item = nextItem) { if (item->isSignaled) { @@ -221,7 +220,7 @@ int apc_executeCompletions(WINPR_THREAD* thread, WINPR_POLL_SET* set, size_t idx } /* third pass: to do final cleanup */ - for (item = apc->head; item; item = nextItem) + for (WINPR_APC_ITEM* item = apc->head; item; item = nextItem) { nextItem = item->next; diff --git a/winpr/libwinpr/thread/argv.c b/winpr/libwinpr/thread/argv.c index da6099d82..3eedc411a 100644 --- a/winpr/libwinpr/thread/argv.c +++ b/winpr/libwinpr/thread/argv.c @@ -118,7 +118,6 @@ LPSTR* CommandLineToArgvA(LPCSTR lpCmdLine, int* pNumArgs) if (strstr(lpCmdLine, "\\\"")) { - size_t i = 0; size_t n = 0; const char* pLastEnd = NULL; lpEscapedCmdLine = (char*)calloc(cmdLineLength + 1, sizeof(char)); @@ -164,7 +163,7 @@ LPSTR* CommandLineToArgvA(LPCSTR lpCmdLine, int* pNumArgs) pOutput += length; p += length; - for (i = 0; i < (n / 2); i++) + for (size_t i = 0; i < (n / 2); i++) *pOutput++ = '\\'; p += n + 1; diff --git a/winpr/libwinpr/thread/process.c b/winpr/libwinpr/thread/process.c index 3701b8acc..0dbd9405b 100644 --- a/winpr/libwinpr/thread/process.c +++ b/winpr/libwinpr/thread/process.c @@ -224,8 +224,6 @@ static BOOL _CreateProcessExA(HANDLE hToken, DWORD dwLogonFlags, LPCSTR lpApplic #ifndef __sun int maxfd = 0; #endif - int fd = 0; - int sig = 0; sigset_t set = { 0 }; struct sigaction act = { 0 }; /* set default signal handlers */ @@ -233,7 +231,7 @@ static BOOL _CreateProcessExA(HANDLE hToken, DWORD dwLogonFlags, LPCSTR lpApplic act.sa_flags = 0; sigemptyset(&act.sa_mask); - for (sig = 1; sig < NSIG; sig++) + for (int sig = 1; sig < NSIG; sig++) sigaction(sig, &act, NULL); /* unblock all signals */ @@ -268,7 +266,7 @@ static BOOL _CreateProcessExA(HANDLE hToken, DWORD dwLogonFlags, LPCSTR lpApplic maxfd = sysconf(_SC_OPEN_MAX); #endif - for (fd = 3; fd < maxfd; fd++) + for (int fd = 3; fd < maxfd; fd++) close(fd); #endif // __sun diff --git a/winpr/libwinpr/thread/test/TestThreadCommandLineToArgv.c b/winpr/libwinpr/thread/test/TestThreadCommandLineToArgv.c index 62cd42892..33d0c94f4 100644 --- a/winpr/libwinpr/thread/test/TestThreadCommandLineToArgv.c +++ b/winpr/libwinpr/thread/test/TestThreadCommandLineToArgv.c @@ -34,7 +34,6 @@ static const char* test_args_list_7[] = { "app.exe", "a\\\\b c", "d", "e", static int test_command_line_parsing_case(const char* line, const char** list) { - int i = 0; LPSTR* pArgs = NULL; int numArgs = 0; @@ -47,7 +46,7 @@ static int test_command_line_parsing_case(const char* line, const char** list) printf("pNumArgs: %d\n", numArgs); - for (i = 0; i < numArgs; i++) + for (int i = 0; i < numArgs; i++) { printf("argv[%d] = %s\n", i, pArgs[i]); } diff --git a/winpr/libwinpr/thread/test/TestThreadExitThread.c b/winpr/libwinpr/thread/test/TestThreadExitThread.c index f7484dddb..015bb85f4 100644 --- a/winpr/libwinpr/thread/test/TestThreadExitThread.c +++ b/winpr/libwinpr/thread/test/TestThreadExitThread.c @@ -17,14 +17,13 @@ int TestThreadExitThread(int argc, char* argv[]) { HANDLE thread = NULL; DWORD waitResult = 0; - int i = 0; WINPR_UNUSED(argc); WINPR_UNUSED(argv); /* FIXME: create some noise to better guaranty the test validity and * decrease the number of loops */ - for (i = 0; i < 100; i++) + for (int i = 0; i < 100; i++) { thread = CreateThread(NULL, 0, thread_func, NULL, 0, NULL); diff --git a/winpr/libwinpr/thread/thread.c b/winpr/libwinpr/thread/thread.c index be2beec7d..edf5639ce 100644 --- a/winpr/libwinpr/thread/thread.c +++ b/winpr/libwinpr/thread/thread.c @@ -363,11 +363,10 @@ static void dump_thread(WINPR_THREAD* thread) void* stack = winpr_backtrace(20); char** msg = NULL; size_t used = 0; - size_t i = 0; WLog_DBG(TAG, "Called from:"); msg = winpr_backtrace_symbols(stack, &used); - for (i = 0; i < used; i++) + for (size_t i = 0; i < used; i++) WLog_DBG(TAG, "[%" PRIdz "]: %s", i, msg[i]); free(msg); @@ -375,7 +374,7 @@ static void dump_thread(WINPR_THREAD* thread) WLog_DBG(TAG, "Thread handle created still not closed!"); msg = winpr_backtrace_symbols(thread->create_stack, &used); - for (i = 0; i < used; i++) + for (size_t i = 0; i < used; i++) WLog_DBG(TAG, "[%" PRIdz "]: %s", i, msg[i]); free(msg); @@ -393,7 +392,7 @@ static void dump_thread(WINPR_THREAD* thread) WLog_DBG(TAG, "Thread exited at:"); msg = winpr_backtrace_symbols(thread->exit_stack, &used); - for (i = 0; i < used; i++) + for (size_t i = 0; i < used; i++) WLog_DBG(TAG, "[%" PRIdz "]: %s", i, msg[i]); free(msg); @@ -981,12 +980,11 @@ VOID DumpThreadHandles(void) #if defined(WITH_DEBUG_THREADS) char** msg = NULL; size_t used = 0; - size_t i = 0; void* stack = winpr_backtrace(20); WLog_DBG(TAG, "---------------- Called from ----------------------------"); msg = winpr_backtrace_symbols(stack, &used); - for (i = 0; i < used; i++) + for (size_t i = 0; i < used; i++) { WLog_DBG(TAG, "[%" PRIdz "]: %s", i, msg[i]); } @@ -1007,13 +1005,13 @@ VOID DumpThreadHandles(void) int x, count = ListDictionary_GetKeys(thread_list, &keys); WLog_DBG(TAG, "Dumping %d elements", count); - for (x = 0; x < count; x++) + for (size_t x = 0; x < count; x++) { WINPR_THREAD* thread = ListDictionary_GetItemValue(thread_list, (void*)keys[x]); WLog_DBG(TAG, "Thread [%d] handle created still not closed!", x); msg = winpr_backtrace_symbols(thread->create_stack, &used); - for (i = 0; i < used; i++) + for (size_t i = 0; i < used; i++) { WLog_DBG(TAG, "[%" PRIdz "]: %s", i, msg[i]); } @@ -1029,7 +1027,7 @@ VOID DumpThreadHandles(void) WLog_DBG(TAG, "Thread [%d] exited at:", x); msg = winpr_backtrace_symbols(thread->exit_stack, &used); - for (i = 0; i < used; i++) + for (size_t i = 0; i < used; i++) WLog_DBG(TAG, "[%" PRIdz "]: %s", i, msg[i]); free(msg); diff --git a/winpr/libwinpr/timezone/timezone.c b/winpr/libwinpr/timezone/timezone.c index 1cb4bbdf6..f6d987499 100644 --- a/winpr/libwinpr/timezone/timezone.c +++ b/winpr/libwinpr/timezone/timezone.c @@ -102,7 +102,6 @@ static char* winpr_read_unix_timezone_identifier_from_file(FILE* fp) static char* winpr_get_timezone_from_link(const char* links[], size_t count) { const char* _links[] = { "/etc/localtime", "/etc/TZ" }; - size_t x = 0; if (links == NULL) { @@ -117,7 +116,7 @@ static char* winpr_get_timezone_from_link(const char* links[], size_t count) * Some distributions do have to symlink at /etc/TZ. */ - for (x = 0; x < count; x++) + for (size_t x = 0; x < count; x++) { char* tzid = NULL; const char* link = links[x]; @@ -125,14 +124,13 @@ static char* winpr_get_timezone_from_link(const char* links[], size_t count) if (buf) { - size_t i = 0; size_t sep = 0; size_t alloc = 0; size_t pos = 0; size_t len = pos = strlen(buf); /* find the position of the 2nd to last "/" */ - for (i = 1; i <= len; i++) + for (size_t i = 1; i <= len; i++) { const size_t curpos = len - i; const char cur = buf[curpos]; @@ -296,8 +294,6 @@ static BOOL winpr_match_unix_timezone_identifier_with_list(const char* tzid, con static TIME_ZONE_ENTRY* winpr_detect_windows_time_zone(void) { - size_t i = 0; - size_t j = 0; char* tzid = NULL; char* ntzid = NULL; LPCSTR tz = "TZ"; @@ -340,11 +336,11 @@ static TIME_ZONE_ENTRY* winpr_detect_windows_time_zone(void) WLog_INFO(TAG, "tzid: %s", tzid); - for (i = 0; i < TimeZoneTableNrElements; i++) + for (size_t i = 0; i < TimeZoneTableNrElements; i++) { const TIME_ZONE_ENTRY* tze = &TimeZoneTable[i]; - for (j = 0; j < WindowsTimeZoneIdTableNrElements; j++) + for (size_t j = 0; j < WindowsTimeZoneIdTableNrElements; j++) { const WINDOWS_TZID_ENTRY* wzid = &WindowsTimeZoneIdTable[j]; @@ -373,11 +369,10 @@ static TIME_ZONE_ENTRY* winpr_detect_windows_time_zone(void) static const TIME_ZONE_RULE_ENTRY* winpr_get_current_time_zone_rule(const TIME_ZONE_RULE_ENTRY* rules, UINT32 count) { - UINT32 i = 0; UINT64 windows_time = 0; windows_time = winpr_windows_gmtime(); - for (i = 0; i < count; i++) + for (UINT32 i = 0; i < count; i++) { if ((rules[i].TicksStart >= windows_time) && (windows_time >= rules[i].TicksEnd)) { diff --git a/winpr/libwinpr/utils/asn1/asn1.c b/winpr/libwinpr/utils/asn1/asn1.c index fdf2446cf..201f23c3b 100644 --- a/winpr/libwinpr/utils/asn1/asn1.c +++ b/winpr/libwinpr/utils/asn1/asn1.c @@ -391,7 +391,6 @@ BOOL WinPrAsn1EncContextualOctetStringContainer(WinPrAsn1Encoder* enc, WinPrAsn1 size_t WinPrAsn1EncEndContainer(WinPrAsn1Encoder* enc) { size_t innerLen = 0; - size_t i = 0; size_t unused = 0; size_t innerHeaderBytes = 0; size_t outerHeaderBytes = 0; @@ -407,7 +406,7 @@ size_t WinPrAsn1EncEndContainer(WinPrAsn1Encoder* enc) /* compute inner length */ container = &enc->containers[enc->freeContainerIndex - 1]; innerLen = 0; - for (i = container->headerChunkId + 1; i < enc->freeChunkId; i++) + for (size_t i = container->headerChunkId + 1; i < enc->freeChunkId; i++) innerLen += enc->chunks[i].used; /* compute effective headerLength */ @@ -824,7 +823,6 @@ size_t WinPrAsn1EncContextualUtcTime(WinPrAsn1Encoder* enc, WinPrAsn1_tagId tagI BOOL WinPrAsn1EncStreamSize(WinPrAsn1Encoder* enc, size_t* s) { size_t finalSize = 0; - size_t i = 0; WINPR_ASSERT(enc); WINPR_ASSERT(s); @@ -835,7 +833,7 @@ BOOL WinPrAsn1EncStreamSize(WinPrAsn1Encoder* enc, size_t* s) return FALSE; } - for (i = 0; i < enc->freeChunkId; i++) + for (size_t i = 0; i < enc->freeChunkId; i++) finalSize += enc->chunks[i].used; *s = finalSize; return TRUE; @@ -844,7 +842,6 @@ BOOL WinPrAsn1EncStreamSize(WinPrAsn1Encoder* enc, size_t* s) BOOL WinPrAsn1EncToStream(WinPrAsn1Encoder* enc, wStream* s) { size_t finalSize = 0; - size_t i = 0; WINPR_ASSERT(enc); WINPR_ASSERT(s); @@ -855,7 +852,7 @@ BOOL WinPrAsn1EncToStream(WinPrAsn1Encoder* enc, wStream* s) if (!Stream_EnsureRemainingCapacity(s, finalSize)) return FALSE; - for (i = 0; i < enc->freeChunkId; i++) + for (size_t i = 0; i < enc->freeChunkId; i++) { BYTE* src = Stream_Buffer(enc->pool) + enc->chunks[i].poolOffset; Stream_Write(s, src, enc->chunks[i].used); diff --git a/winpr/libwinpr/utils/cmdline.c b/winpr/libwinpr/utils/cmdline.c index 52d748107..3d93c0a5a 100644 --- a/winpr/libwinpr/utils/cmdline.c +++ b/winpr/libwinpr/utils/cmdline.c @@ -57,12 +57,10 @@ int CommandLineParseArgumentsA(int argc, LPSTR* argv, COMMAND_LINE_ARGUMENT_A* o void* context, COMMAND_LINE_PRE_FILTER_FN_A preFilter, COMMAND_LINE_POST_FILTER_FN_A postFilter) { - int i = 0; - int j = 0; int status = 0; int count = 0; size_t length = 0; - BOOL notescaped = 0; + BOOL notescaped = FALSE; const char* sigil = NULL; size_t sigil_length = 0; char* keyword = NULL; @@ -71,8 +69,6 @@ int CommandLineParseArgumentsA(int argc, LPSTR* argv, COMMAND_LINE_ARGUMENT_A* o char* separator = NULL; char* value = NULL; int toggle = 0; - status = 0; - notescaped = FALSE; if (!argv) return status; @@ -87,7 +83,7 @@ int CommandLineParseArgumentsA(int argc, LPSTR* argv, COMMAND_LINE_ARGUMENT_A* o return status; } - for (i = 1; i < argc; i++) + for (int i = 1; i < argc; i++) { BOOL found = FALSE; BOOL escaped = TRUE; @@ -213,7 +209,7 @@ int CommandLineParseArgumentsA(int argc, LPSTR* argv, COMMAND_LINE_ARGUMENT_A* o if (!escaped) continue; - for (j = 0; options[j].Name != NULL; j++) + for (int j = 0; options[j].Name != NULL; j++) { COMMAND_LINE_ARGUMENT_A* cur = &options[j]; BOOL match = FALSE; @@ -397,9 +393,7 @@ int CommandLineParseArgumentsW(int argc, LPWSTR* argv, COMMAND_LINE_ARGUMENT_W* int CommandLineClearArgumentsA(COMMAND_LINE_ARGUMENT_A* options) { - size_t i = 0; - - for (i = 0; options[i].Name != NULL; i++) + for (size_t i = 0; options[i].Name != NULL; i++) { options[i].Flags &= COMMAND_LINE_INPUT_FLAG_MASK; options[i].Value = NULL; @@ -410,9 +404,7 @@ int CommandLineClearArgumentsA(COMMAND_LINE_ARGUMENT_A* options) int CommandLineClearArgumentsW(COMMAND_LINE_ARGUMENT_W* options) { - int i = 0; - - for (i = 0; options[i].Name != NULL; i++) + for (int i = 0; options[i].Name != NULL; i++) { options[i].Flags &= COMMAND_LINE_INPUT_FLAG_MASK; options[i].Value = NULL; @@ -424,12 +416,10 @@ int CommandLineClearArgumentsW(COMMAND_LINE_ARGUMENT_W* options) const COMMAND_LINE_ARGUMENT_A* CommandLineFindArgumentA(const COMMAND_LINE_ARGUMENT_A* options, LPCSTR Name) { - size_t i = 0; - WINPR_ASSERT(options); WINPR_ASSERT(Name); - for (i = 0; options[i].Name != NULL; i++) + for (size_t i = 0; options[i].Name != NULL; i++) { if (strcmp(options[i].Name, Name) == 0) return &options[i]; @@ -447,12 +437,10 @@ const COMMAND_LINE_ARGUMENT_A* CommandLineFindArgumentA(const COMMAND_LINE_ARGUM const COMMAND_LINE_ARGUMENT_W* CommandLineFindArgumentW(const COMMAND_LINE_ARGUMENT_W* options, LPCWSTR Name) { - size_t i = 0; - WINPR_ASSERT(options); WINPR_ASSERT(Name); - for (i = 0; options[i].Name != NULL; i++) + for (size_t i = 0; options[i].Name != NULL; i++) { if (_wcscmp(options[i].Name, Name) == 0) return &options[i]; @@ -657,7 +645,6 @@ char** CommandLineParseCommaSeparatedValuesEx(const char* name, const char* list char** p = NULL; char* str = NULL; size_t nArgs = 0; - size_t index = 0; size_t prefix = 0; size_t len = 0; size_t namelen = 0; @@ -751,7 +738,7 @@ char** CommandLineParseCommaSeparatedValuesEx(const char* name, const char* list p[0] = namestr; } - for (index = name ? 1 : 0; index < nArgs; index++) + for (size_t index = name ? 1 : 0; index < nArgs; index++) { char* ptr = str; const int quote = is_quoted(*ptr); @@ -816,10 +803,9 @@ char* CommandLineToCommaSeparatedValues(int argc, char* argv[]) static const char* filtered(const char* arg, const char* filters[], size_t number) { - size_t x = 0; if (number == 0) return arg; - for (x = 0; x < number; x++) + for (size_t x = 0; x < number; x++) { const char* filter = filters[x]; size_t len = strlen(filter); @@ -832,20 +818,19 @@ static const char* filtered(const char* arg, const char* filters[], size_t numbe char* CommandLineToCommaSeparatedValuesEx(int argc, char* argv[], const char* filters[], size_t number) { - int x = 0; char* str = NULL; size_t offset = 0; size_t size = argc + 1; if ((argc <= 0) || !argv) return NULL; - for (x = 0; x < argc; x++) + for (int x = 0; x < argc; x++) size += strlen(argv[x]); str = calloc(size, sizeof(char)); if (!str) return NULL; - for (x = 0; x < argc; x++) + for (int x = 0; x < argc; x++) { int rc = 0; const char* arg = filtered(argv[x], filters, number); diff --git a/winpr/libwinpr/utils/collections/ArrayList.c b/winpr/libwinpr/utils/collections/ArrayList.c index 8a1120166..5595edb84 100644 --- a/winpr/libwinpr/utils/collections/ArrayList.c +++ b/winpr/libwinpr/utils/collections/ArrayList.c @@ -254,12 +254,10 @@ static BOOL ArrayList_Shift(wArrayList* arrayList, size_t index, SSIZE_T count) void ArrayList_Clear(wArrayList* arrayList) { - size_t index = 0; - WINPR_ASSERT(arrayList); ArrayList_Lock_Conditional(arrayList); - for (index = 0; index < arrayList->size; index++) + for (size_t index = 0; index < arrayList->size; index++) { if (arrayList->object.fnObjectFree) arrayList->object.fnObjectFree(arrayList->array[index]); @@ -278,13 +276,12 @@ void ArrayList_Clear(wArrayList* arrayList) BOOL ArrayList_Contains(wArrayList* arrayList, const void* obj) { - size_t index = 0; BOOL rc = FALSE; WINPR_ASSERT(arrayList); ArrayList_Lock_Conditional(arrayList); - for (index = 0; index < arrayList->size; index++) + for (size_t index = 0; index < arrayList->size; index++) { rc = arrayList->object.fnObjectEquals(arrayList->array[index], obj); @@ -365,14 +362,14 @@ BOOL ArrayList_Insert(wArrayList* arrayList, size_t index, const void* obj) BOOL ArrayList_Remove(wArrayList* arrayList, const void* obj) { - size_t index = 0; BOOL found = FALSE; BOOL ret = TRUE; WINPR_ASSERT(arrayList); ArrayList_Lock_Conditional(arrayList); - for (index = 0; index < arrayList->size; index++) + size_t index = 0; + for (; index < arrayList->size; index++) { if (arrayList->object.fnObjectEquals(arrayList->array[index], obj)) { @@ -433,7 +430,6 @@ BOOL ArrayList_RemoveAt(wArrayList* arrayList, size_t index) SSIZE_T ArrayList_IndexOf(wArrayList* arrayList, const void* obj, SSIZE_T startIndex, SSIZE_T count) { - SSIZE_T index = 0; SSIZE_T sindex = 0; SSIZE_T cindex = 0; BOOL found = FALSE; @@ -449,7 +445,8 @@ SSIZE_T ArrayList_IndexOf(wArrayList* arrayList, const void* obj, SSIZE_T startI if (count < 0) cindex = arrayList->size; - for (index = sindex; index < sindex + cindex; index++) + SSIZE_T index = sindex; + for (; index < sindex + cindex; index++) { if (arrayList->object.fnObjectEquals(arrayList->array[index], obj)) { @@ -482,7 +479,6 @@ SSIZE_T ArrayList_IndexOf(wArrayList* arrayList, const void* obj, SSIZE_T startI SSIZE_T ArrayList_LastIndexOf(wArrayList* arrayList, const void* obj, SSIZE_T startIndex, SSIZE_T count) { - SSIZE_T index = 0; SSIZE_T sindex = 0; SSIZE_T cindex = 0; BOOL found = FALSE; @@ -498,7 +494,8 @@ SSIZE_T ArrayList_LastIndexOf(wArrayList* arrayList, const void* obj, SSIZE_T st if (count < 0) cindex = arrayList->size; - for (index = sindex + cindex; index > sindex; index--) + SSIZE_T index = sindex + cindex; + for (; index > sindex; index--) { if (arrayList->object.fnObjectEquals(arrayList->array[index - 1], obj)) { @@ -539,8 +536,6 @@ BOOL ArrayList_ForEach(wArrayList* arrayList, ArrayList_ForEachFkt fkt, ...) BOOL ArrayList_ForEachAP(wArrayList* arrayList, ArrayList_ForEachFkt fkt, va_list ap) { - size_t index = 0; - size_t count = 0; BOOL rc = FALSE; va_list cap; @@ -548,8 +543,8 @@ BOOL ArrayList_ForEachAP(wArrayList* arrayList, ArrayList_ForEachFkt fkt, va_lis WINPR_ASSERT(fkt); ArrayList_Lock_Conditional(arrayList); - count = ArrayList_Count(arrayList); - for (index = 0; index < count; index++) + size_t count = ArrayList_Count(arrayList); + for (size_t index = 0; index < count; index++) { BOOL rs = 0; void* obj = ArrayList_GetItem(arrayList, index); diff --git a/winpr/libwinpr/utils/collections/BitStream.c b/winpr/libwinpr/utils/collections/BitStream.c index bbbb09ecd..e57af947f 100644 --- a/winpr/libwinpr/utils/collections/BitStream.c +++ b/winpr/libwinpr/utils/collections/BitStream.c @@ -95,7 +95,6 @@ static const char* BYTE_BIT_STRINGS_MSB[256] = { void BitDump(const char* tag, UINT32 level, const BYTE* buffer, UINT32 length, UINT32 flags) { - DWORD i = 0; const char** strs = (flags & BITDUMP_MSB_FIRST) ? BYTE_BIT_STRINGS_MSB : BYTE_BIT_STRINGS_LSB; char pbuffer[64 * 8 + 1] = { 0 }; size_t pos = 0; @@ -103,7 +102,8 @@ void BitDump(const char* tag, UINT32 level, const BYTE* buffer, UINT32 length, U WINPR_ASSERT(tag); WINPR_ASSERT(buffer || (length == 0)); - for (i = 0; i < length; i += 8) + DWORD i = 0; + for (; i < length; i += 8) { const char* str = strs[buffer[i / 8]]; const int nbits = (length - i) > 8 ? 8 : (length - i); diff --git a/winpr/libwinpr/utils/collections/BufferPool.c b/winpr/libwinpr/utils/collections/BufferPool.c index a176e42a2..ebdf4f13b 100644 --- a/winpr/libwinpr/utils/collections/BufferPool.c +++ b/winpr/libwinpr/utils/collections/BufferPool.c @@ -178,7 +178,6 @@ SSIZE_T BufferPool_GetPoolSize(wBufferPool* pool) SSIZE_T BufferPool_GetBufferSize(wBufferPool* pool, const void* buffer) { SSIZE_T size = 0; - SSIZE_T index = 0; BOOL found = FALSE; BufferPool_Lock(pool); @@ -193,7 +192,7 @@ SSIZE_T BufferPool_GetBufferSize(wBufferPool* pool, const void* buffer) { /* variable size buffers */ - for (index = 0; index < pool->uSize; index++) + for (SSIZE_T index = 0; index < pool->uSize; index++) { if (pool->uArray[index].buffer == buffer) { @@ -215,7 +214,6 @@ SSIZE_T BufferPool_GetBufferSize(wBufferPool* pool, const void* buffer) void* BufferPool_Take(wBufferPool* pool, SSIZE_T size) { - SSIZE_T index = 0; SSIZE_T maxSize = 0; SSIZE_T maxIndex = 0; SSIZE_T foundIndex = -1; @@ -252,7 +250,7 @@ void* BufferPool_Take(wBufferPool* pool, SSIZE_T size) if (size < 1) size = pool->fixedSize; - for (index = 0; index < pool->aSize; index++) + for (SSIZE_T index = 0; index < pool->aSize; index++) { if (pool->aArray[index].size > maxSize) { @@ -353,7 +351,6 @@ BOOL BufferPool_Return(wBufferPool* pool, void* buffer) { BOOL rc = FALSE; SSIZE_T size = 0; - SSIZE_T index = 0; BOOL found = FALSE; BufferPool_Lock(pool); @@ -379,7 +376,8 @@ BOOL BufferPool_Return(wBufferPool* pool, void* buffer) { /* variable size buffers */ - for (index = 0; index < pool->uSize; index++) + SSIZE_T index = 0; + for (; index < pool->uSize; index++) { if (pool->uArray[index].buffer == buffer) { diff --git a/winpr/libwinpr/utils/collections/HashTable.c b/winpr/libwinpr/utils/collections/HashTable.c index ee3ff9927..7782b2bf0 100644 --- a/winpr/libwinpr/utils/collections/HashTable.c +++ b/winpr/libwinpr/utils/collections/HashTable.c @@ -106,9 +106,7 @@ void HashTable_StringFree(void* str) static INLINE BOOL HashTable_IsProbablePrime(size_t oddNumber) { - size_t i = 0; - - for (i = 3; i < 51; i += 2) + for (size_t i = 3; i < 51; i += 2) { if (oddNumber == i) return TRUE; @@ -139,9 +137,7 @@ static INLINE size_t HashTable_CalculateIdealNumOfBuckets(wHashTable* table) static INLINE void HashTable_Rehash(wHashTable* table, size_t numOfBuckets) { - size_t index = 0; UINT32 hashValue = 0; - wKeyValuePair* pair = NULL; wKeyValuePair* nextPair = NULL; wKeyValuePair** newBucketArray = NULL; @@ -163,9 +159,9 @@ static INLINE void HashTable_Rehash(wHashTable* table, size_t numOfBuckets) return; } - for (index = 0; index < table->numOfBuckets; index++) + for (size_t index = 0; index < table->numOfBuckets; index++) { - pair = table->bucketArray[index]; + wKeyValuePair* pair = table->bucketArray[index]; while (pair) { @@ -508,8 +504,6 @@ BOOL HashTable_SetItemValue(wHashTable* table, const void* key, const void* valu void HashTable_Clear(wHashTable* table) { - size_t index = 0; - wKeyValuePair* pair = NULL; wKeyValuePair* nextPair = NULL; WINPR_ASSERT(table); @@ -517,9 +511,9 @@ void HashTable_Clear(wHashTable* table) if (table->synchronized) EnterCriticalSection(&table->lock); - for (index = 0; index < table->numOfBuckets; index++) + for (size_t index = 0; index < table->numOfBuckets; index++) { - pair = table->bucketArray[index]; + wKeyValuePair* pair = table->bucketArray[index]; while (pair) { @@ -557,9 +551,7 @@ size_t HashTable_GetKeys(wHashTable* table, ULONG_PTR** ppKeys) { size_t iKey = 0; size_t count = 0; - size_t index = 0; ULONG_PTR* pKeys = NULL; - wKeyValuePair* pair = NULL; wKeyValuePair* nextPair = NULL; WINPR_ASSERT(table); @@ -589,9 +581,9 @@ size_t HashTable_GetKeys(wHashTable* table, ULONG_PTR** ppKeys) return 0; } - for (index = 0; index < table->numOfBuckets; index++) + for (size_t index = 0; index < table->numOfBuckets; index++) { - pair = table->bucketArray[index]; + wKeyValuePair* pair = table->bucketArray[index]; while (pair) { @@ -615,8 +607,6 @@ size_t HashTable_GetKeys(wHashTable* table, ULONG_PTR** ppKeys) BOOL HashTable_Foreach(wHashTable* table, HASH_TABLE_FOREACH_FN fn, VOID* arg) { BOOL ret = TRUE; - size_t index = 0; - wKeyValuePair* pair = NULL; WINPR_ASSERT(table); WINPR_ASSERT(fn); @@ -625,9 +615,9 @@ BOOL HashTable_Foreach(wHashTable* table, HASH_TABLE_FOREACH_FN fn, VOID* arg) EnterCriticalSection(&table->lock); table->foreachRecursionLevel++; - for (index = 0; index < table->numOfBuckets; index++) + for (size_t index = 0; index < table->numOfBuckets; index++) { - for (pair = table->bucketArray[index]; pair; pair = pair->next) + for (wKeyValuePair* pair = table->bucketArray[index]; pair; pair = pair->next) { if (!pair->markedForRemove && !fn(pair->key, pair->value, arg)) { @@ -642,11 +632,11 @@ BOOL HashTable_Foreach(wHashTable* table, HASH_TABLE_FOREACH_FN fn, VOID* arg) { /* if we're the last recursive foreach call, let's do the cleanup if needed */ wKeyValuePair** prevPtr = NULL; - for (index = 0; index < table->numOfBuckets; index++) + for (size_t index = 0; index < table->numOfBuckets; index++) { wKeyValuePair* nextPair = NULL; prevPtr = &table->bucketArray[index]; - for (pair = table->bucketArray[index]; pair;) + for (wKeyValuePair* pair = table->bucketArray[index]; pair;) { nextPair = pair->next; @@ -727,9 +717,7 @@ BOOL HashTable_ContainsKey(wHashTable* table, const void* key) BOOL HashTable_ContainsValue(wHashTable* table, const void* value) { - size_t index = 0; BOOL status = FALSE; - wKeyValuePair* pair = NULL; WINPR_ASSERT(table); if (!value) @@ -738,9 +726,9 @@ BOOL HashTable_ContainsValue(wHashTable* table, const void* value) if (table->synchronized) EnterCriticalSection(&table->lock); - for (index = 0; index < table->numOfBuckets; index++) + for (size_t index = 0; index < table->numOfBuckets; index++) { - pair = table->bucketArray[index]; + wKeyValuePair* pair = table->bucketArray[index]; while (pair) { @@ -801,7 +789,6 @@ fail: void HashTable_Free(wHashTable* table) { - size_t index = 0; wKeyValuePair* pair = NULL; wKeyValuePair* nextPair = NULL; @@ -810,7 +797,7 @@ void HashTable_Free(wHashTable* table) if (table->bucketArray) { - for (index = 0; index < table->numOfBuckets; index++) + for (size_t index = 0; index < table->numOfBuckets; index++) { pair = table->bucketArray[index]; diff --git a/winpr/libwinpr/utils/collections/PubSub.c b/winpr/libwinpr/utils/collections/PubSub.c index 8715585e3..0efffb741 100644 --- a/winpr/libwinpr/utils/collections/PubSub.c +++ b/winpr/libwinpr/utils/collections/PubSub.c @@ -71,12 +71,11 @@ void PubSub_Unlock(wPubSub* pubSub) wEventType* PubSub_FindEventType(wPubSub* pubSub, const char* EventName) { - size_t index = 0; wEventType* event = NULL; WINPR_ASSERT(pubSub); WINPR_ASSERT(EventName); - for (index = 0; index < pubSub->count; index++) + for (size_t index = 0; index < pubSub->count; index++) { if (strcmp(pubSub->events[index].EventName, EventName) == 0) { @@ -149,7 +148,6 @@ int PubSub_Subscribe(wPubSub* pubSub, const char* EventName, ...) int PubSub_Unsubscribe(wPubSub* pubSub, const char* EventName, ...) { - size_t index = 0; wEventType* event = NULL; int status = -1; WINPR_ASSERT(pubSub); @@ -168,7 +166,7 @@ int PubSub_Unsubscribe(wPubSub* pubSub, const char* EventName, ...) { status = 0; - for (index = 0; index < event->EventHandlerCount; index++) + for (size_t index = 0; index < event->EventHandlerCount; index++) { if (event->EventHandlers[index] == EventHandler) { @@ -190,7 +188,6 @@ int PubSub_Unsubscribe(wPubSub* pubSub, const char* EventName, ...) int PubSub_OnEvent(wPubSub* pubSub, const char* EventName, void* context, const wEventArgs* e) { - size_t index = 0; wEventType* event = NULL; int status = -1; @@ -210,7 +207,7 @@ int PubSub_OnEvent(wPubSub* pubSub, const char* EventName, void* context, const { status = 0; - for (index = 0; index < event->EventHandlerCount; index++) + for (size_t index = 0; index < event->EventHandlerCount; index++) { if (event->EventHandlers[index]) { diff --git a/winpr/libwinpr/utils/collections/Queue.c b/winpr/libwinpr/utils/collections/Queue.c index dd5f48842..d24e1dd52 100644 --- a/winpr/libwinpr/utils/collections/Queue.c +++ b/winpr/libwinpr/utils/collections/Queue.c @@ -119,11 +119,9 @@ wObject* Queue_Object(wQueue* queue) void Queue_Clear(wQueue* queue) { - size_t index = 0; - Queue_Lock(queue); - for (index = queue->head; index != queue->tail; index = (index + 1) % queue->capacity) + for (size_t index = queue->head; index != queue->tail; index = (index + 1) % queue->capacity) { if (queue->object.fnObjectFree) queue->object.fnObjectFree(queue->array[index]); @@ -143,12 +141,11 @@ void Queue_Clear(wQueue* queue) BOOL Queue_Contains(wQueue* queue, const void* obj) { - size_t index = 0; BOOL found = FALSE; Queue_Lock(queue); - for (index = 0; index < queue->tail; index++) + for (size_t index = 0; index < queue->tail; index++) { if (queue->object.fnObjectEquals(queue->array[index], obj)) { diff --git a/winpr/libwinpr/utils/collections/Stack.c b/winpr/libwinpr/utils/collections/Stack.c index 55aad3695..f8b5c5e3f 100644 --- a/winpr/libwinpr/utils/collections/Stack.c +++ b/winpr/libwinpr/utils/collections/Stack.c @@ -86,13 +86,11 @@ wObject* Stack_Object(wStack* stack) void Stack_Clear(wStack* stack) { - size_t index = 0; - WINPR_ASSERT(stack); if (stack->synchronized) EnterCriticalSection(&stack->lock); - for (index = 0; index < stack->size; index++) + for (size_t index = 0; index < stack->size; index++) { if (stack->object.fnObjectFree) stack->object.fnObjectFree(stack->array[index]); @@ -112,14 +110,13 @@ void Stack_Clear(wStack* stack) BOOL Stack_Contains(wStack* stack, const void* obj) { - size_t i = 0; BOOL found = FALSE; WINPR_ASSERT(stack); if (stack->synchronized) EnterCriticalSection(&stack->lock); - for (i = 0; i < stack->size; i++) + for (size_t i = 0; i < stack->size; i++) { if (stack->object.fnObjectEquals(stack->array[i], obj)) { diff --git a/winpr/libwinpr/utils/collections/StreamPool.c b/winpr/libwinpr/utils/collections/StreamPool.c index 31838a4b7..910309f6a 100644 --- a/winpr/libwinpr/utils/collections/StreamPool.c +++ b/winpr/libwinpr/utils/collections/StreamPool.c @@ -143,21 +143,15 @@ static void StreamPool_AddUsed(wStreamPool* pool, wStream* s) static void StreamPool_RemoveUsed(wStreamPool* pool, wStream* s) { - size_t index = 0; - BOOL found = FALSE; - WINPR_ASSERT(pool); - for (index = 0; index < pool->uSize; index++) + for (size_t index = 0; index < pool->uSize; index++) { if (pool->uArray[index] == s) { - found = TRUE; + StreamPool_ShiftUsed(pool, index, -1); break; } } - - if (found) - StreamPool_ShiftUsed(pool, index, -1); } static void StreamPool_ShiftAvailable(wStreamPool* pool, size_t index, INT64 count) @@ -192,8 +186,7 @@ static void StreamPool_ShiftAvailable(wStreamPool* pool, size_t index, INT64 cou wStream* StreamPool_Take(wStreamPool* pool, size_t size) { - size_t index = 0; - SSIZE_T foundIndex = 0; + SSIZE_T foundIndex = -1; wStream* s = NULL; StreamPool_Lock(pool); @@ -201,9 +194,7 @@ wStream* StreamPool_Take(wStreamPool* pool, size_t size) if (size == 0) size = pool->defaultSize; - foundIndex = -1; - - for (index = 0; index < pool->aSize; index++) + for (size_t index = 0; index < pool->aSize; index++) { s = pool->aArray[index]; @@ -311,13 +302,12 @@ void Stream_Release(wStream* s) wStream* StreamPool_Find(wStreamPool* pool, BYTE* ptr) { - size_t index = 0; wStream* s = NULL; BOOL found = FALSE; StreamPool_Lock(pool); - for (index = 0; index < pool->uSize; index++) + for (size_t index = 0; index < pool->uSize; index++) { s = pool->uArray[index]; diff --git a/winpr/libwinpr/utils/corkscrew/debug.c b/winpr/libwinpr/utils/corkscrew/debug.c index 5cf1366e8..0fc2fd6ed 100644 --- a/winpr/libwinpr/utils/corkscrew/debug.c +++ b/winpr/libwinpr/utils/corkscrew/debug.c @@ -228,7 +228,6 @@ char** winpr_corkscrew_backtrace_symbols(void* buffer, size_t* used) else { size_t line_len = (data->max > 1024) ? data->max : 1024; - size_t i; size_t array_size = data->used * sizeof(char*); size_t lines_size = data->used * line_len; char** vlines = calloc(1, array_size + lines_size); @@ -242,12 +241,12 @@ char** winpr_corkscrew_backtrace_symbols(void* buffer, size_t* used) } /* Set the pointers in the allocated buffer's initial array section */ - for (i = 0; i < data->used; i++) + for (size_t i = 0; i < data->used; i++) vlines[i] = (char*)vlines + array_size + i * line_len; fkt->get_backtrace_symbols(data->buffer, data->used, symbols); - for (i = 0; i < data->used; i++) + for (size_t i = 0; i < data->used; i++) fkt->format_backtrace_line(i, &data->buffer[i], &symbols[i], vlines[i], line_len); fkt->free_backtrace_symbols(symbols, data->used); diff --git a/winpr/libwinpr/utils/debug.c b/winpr/libwinpr/utils/debug.c index df68cdcea..a7c9a1374 100644 --- a/winpr/libwinpr/utils/debug.c +++ b/winpr/libwinpr/utils/debug.c @@ -200,7 +200,6 @@ void winpr_log_backtrace(const char* tag, DWORD level, DWORD size) void winpr_log_backtrace_ex(wLog* log, DWORD level, DWORD size) { size_t used = 0; - size_t x = 0; char** msg = NULL; void* stack = winpr_backtrace(20); @@ -214,7 +213,7 @@ void winpr_log_backtrace_ex(wLog* log, DWORD level, DWORD size) if (msg) { - for (x = 0; x < used; x++) + for (size_t x = 0; x < used; x++) WLog_Print(log, level, "%" PRIuz ": %s", x, msg[x]); } free(msg); diff --git a/winpr/libwinpr/utils/image.c b/winpr/libwinpr/utils/image.c index 95af5ea5f..cc2e2ad15 100644 --- a/winpr/libwinpr/utils/image.c +++ b/winpr/libwinpr/utils/image.c @@ -369,7 +369,6 @@ int winpr_image_write_ex(wImage* image, UINT32 format, const char* filename) static int winpr_image_bitmap_read_buffer(wImage* image, const BYTE* buffer, size_t size) { int rc = -1; - UINT32 index = 0; BOOL vFlip = 0; WINPR_BITMAP_FILE_HEADER bf = { 0 }; WINPR_BITMAP_INFO_HEADER bi = { 0 }; @@ -449,7 +448,7 @@ static int winpr_image_bitmap_read_buffer(wImage* image, const BYTE* buffer, siz { BYTE* pDstData = &(image->data[(image->height - 1ull) * image->scanline]); - for (index = 0; index < image->height; index++) + for (size_t index = 0; index < image->height; index++) { Stream_Read(s, pDstData, image->scanline); pDstData -= image->scanline; diff --git a/winpr/libwinpr/utils/print.c b/winpr/libwinpr/utils/print.c index ec1854878..5f0c4a65c 100644 --- a/winpr/libwinpr/utils/print.c +++ b/winpr/libwinpr/utils/print.c @@ -43,7 +43,6 @@ void winpr_HexDump(const char* tag, UINT32 level, const void* data, size_t lengt void winpr_HexLogDump(wLog* log, UINT32 lvl, const void* data, size_t length) { const BYTE* p = data; - size_t i = 0; size_t line = 0; size_t offset = 0; const size_t maxlen = 20; /* 64bit SIZE_MAX as decimal */ @@ -89,7 +88,8 @@ void winpr_HexLogDump(wLog* log, UINT32 lvl, const void* data, size_t length) if (line > WINPR_HEXDUMP_LINE_LENGTH) line = WINPR_HEXDUMP_LINE_LENGTH; - for (i = 0; i < line; i++) + size_t i = 0; + for (; i < line; i++) { rc = _snprintf(&buffer[pos], blen - pos, "%02" PRIx8 " ", p[i]); @@ -109,7 +109,7 @@ void winpr_HexLogDump(wLog* log, UINT32 lvl, const void* data, size_t length) pos += (size_t)rc; } - for (i = 0; i < line; i++) + for (size_t i = 0; i < line; i++) { rc = _snprintf(&buffer[pos], blen - pos, "%c", (p[i] >= 0x20 && p[i] < 0x7F) ? (char)p[i] : '.'); @@ -134,7 +134,6 @@ fail: void winpr_CArrayDump(const char* tag, UINT32 level, const void* data, size_t length, size_t width) { const BYTE* p = data; - size_t i = 0; size_t offset = 0; const size_t llen = ((length > width) ? width : length) * 4ull + 1ull; size_t pos = 0; @@ -157,7 +156,7 @@ void winpr_CArrayDump(const char* tag, UINT32 level, const void* data, size_t le pos = 0; - for (i = 0; i < line; i++) + for (size_t i = 0; i < line; i++) { const int rc = _snprintf(&buffer[pos], llen - pos, "\\x%02" PRIX8 "", p[i]); if (rc < 0) @@ -187,14 +186,13 @@ static BYTE value(char c) size_t winpr_HexStringToBinBuffer(const char* str, size_t strLength, BYTE* data, size_t dataLength) { - size_t x = 0; size_t y = 0; size_t maxStrLen = 0; if (!str || !data || (strLength == 0) || (dataLength == 0)) return 0; maxStrLen = strnlen(str, strLength); - for (x = 0; x < maxStrLen;) + for (size_t x = 0; x < maxStrLen;) { BYTE val = value(str[x++]); if (x < maxStrLen) @@ -217,12 +215,11 @@ size_t winpr_BinToHexStringBuffer(const BYTE* data, size_t length, char* dstStr, const size_t n = space ? 3 : 2; const char bin2hex[] = "0123456789ABCDEF"; const size_t maxLength = MIN(length, dstSize / n); - size_t i = 0; if (!data || !dstStr || (length == 0) || (dstSize == 0)) return 0; - for (i = 0; i < maxLength; i++) + for (size_t i = 0; i < maxLength; i++) { const int ln = data[i] & 0xF; const int hn = (data[i] >> 4) & 0xF; diff --git a/winpr/libwinpr/utils/ssl.c b/winpr/libwinpr/utils/ssl.c index 47913aee0..87649695f 100644 --- a/winpr/libwinpr/utils/ssl.c +++ b/winpr/libwinpr/utils/ssl.c @@ -121,7 +121,7 @@ static void _winpr_openssl_dynlock_destroy(struct CRYPTO_dynlock_value* dynlock, static BOOL _winpr_openssl_initialize_locking(void) { - int i, count; + int count; /* OpenSSL static locking */ @@ -141,7 +141,7 @@ static BOOL _winpr_openssl_initialize_locking(void) return FALSE; } - for (i = 0; i < count; i++) + for (int i = 0; i < count; i++) { if (!(locks[i] = CreateMutex(NULL, FALSE, NULL))) { @@ -199,10 +199,9 @@ static BOOL _winpr_openssl_cleanup_locking(void) /* undo our static locking modifications */ if (CRYPTO_get_locking_callback() == _winpr_openssl_locking) { - int i; CRYPTO_set_locking_callback(NULL); - for (i = 0; i < g_winpr_openssl_num_locks; i++) + for (int i = 0; i < g_winpr_openssl_num_locks; i++) { CloseHandle(g_winpr_openssl_locks[i]); } diff --git a/winpr/libwinpr/utils/stream.c b/winpr/libwinpr/utils/stream.c index 62b304f9d..4c7696f74 100644 --- a/winpr/libwinpr/utils/stream.c +++ b/winpr/libwinpr/utils/stream.c @@ -283,8 +283,6 @@ size_t Stream_GetRemainingLength(const wStream* _s) BOOL Stream_Write_UTF16_String(wStream* s, const WCHAR* src, size_t length) { - size_t x = 0; - WINPR_ASSERT(s); WINPR_ASSERT(src || (length == 0)); if (!s || !src) @@ -293,7 +291,7 @@ BOOL Stream_Write_UTF16_String(wStream* s, const WCHAR* src, size_t length) if (!Stream_CheckAndLogRequiredCapacityOfSize(STREAM_TAG, (s), length, sizeof(WCHAR))) return FALSE; - for (x = 0; x < length; x++) + for (size_t x = 0; x < length; x++) Stream_Write_UINT16(s, src[x]); return TRUE; @@ -301,15 +299,13 @@ BOOL Stream_Write_UTF16_String(wStream* s, const WCHAR* src, size_t length) BOOL Stream_Read_UTF16_String(wStream* s, WCHAR* dst, size_t length) { - size_t x = 0; - WINPR_ASSERT(s); WINPR_ASSERT(dst); if (!Stream_CheckAndLogRequiredLengthOfSize(STREAM_TAG, s, length, sizeof(WCHAR))) return FALSE; - for (x = 0; x < length; x++) + for (size_t x = 0; x < length; x++) Stream_Read_UINT16(s, dst[x]); return TRUE; diff --git a/winpr/libwinpr/utils/strlst.c b/winpr/libwinpr/utils/strlst.c index 18c38c607..c83e29cfe 100644 --- a/winpr/libwinpr/utils/strlst.c +++ b/winpr/libwinpr/utils/strlst.c @@ -27,9 +27,7 @@ void string_list_free(char** string_list) { - int i = 0; - - for (i = 0; string_list[i]; i++) + for (size_t i = 0; string_list[i]; i++) { free(string_list[i]); } @@ -40,8 +38,7 @@ void string_list_free(char** string_list) int string_list_length(const char* const* string_list) { int i = 0; - - for (i = 0; string_list[i]; i++) + for (; string_list[i]; i++) ; return i; @@ -49,7 +46,6 @@ int string_list_length(const char* const* string_list) char** string_list_copy(const char* const* string_list) { - int i = 0; int length = string_list_length(string_list); char** copy = calloc(length + 1, sizeof(char*)); @@ -58,7 +54,7 @@ char** string_list_copy(const char* const* string_list) return 0; } - for (i = 0; i < length; i++) + for (int i = 0; i < length; i++) { copy[i] = _strdup(string_list[i]); } @@ -69,9 +65,7 @@ char** string_list_copy(const char* const* string_list) void string_list_print(FILE* out, const char* const* string_list) { - int j = 0; - - for (j = 0; string_list[j]; j++) + for (int j = 0; string_list[j]; j++) { fprintf(out, "[%2d]: %s\n", j, string_list[j]); } diff --git a/winpr/libwinpr/utils/test/TestASN1.c b/winpr/libwinpr/utils/test/TestASN1.c index 6db0e94ae..d54bdbc98 100644 --- a/winpr/libwinpr/utils/test/TestASN1.c +++ b/winpr/libwinpr/utils/test/TestASN1.c @@ -141,7 +141,6 @@ static WinPrAsn1_OID oid4 = { sizeof(oid4_val), oid4_val }; int TestASN1Write(int argc, char* argv[]) { - size_t i = 0; wStream* s = NULL; size_t expectedOuputSz = 0; int retCode = 100; @@ -300,7 +299,7 @@ int TestASN1Write(int argc, char* argv[]) WinPrAsn1Encoder_Reset(enc); retCode = 203; - for (i = 0; i < 1000; i++) + for (size_t i = 0; i < 1000; i++) { if (!WinPrAsn1EncSeqContainer(enc)) goto out; @@ -311,7 +310,7 @@ int TestASN1Write(int argc, char* argv[]) goto out; retCode = 205; - for (i = 0; i < 1000; i++) + for (size_t i = 0; i < 1000; i++) { if (!WinPrAsn1EncEndContainer(enc)) goto out; diff --git a/winpr/libwinpr/utils/test/TestArrayList.c b/winpr/libwinpr/utils/test/TestArrayList.c index b2c3a331a..069394cbc 100644 --- a/winpr/libwinpr/utils/test/TestArrayList.c +++ b/winpr/libwinpr/utils/test/TestArrayList.c @@ -5,7 +5,6 @@ int TestArrayList(int argc, char* argv[]) { - size_t index = 0; int count = 0; int rc = 0; size_t val = 0; @@ -19,7 +18,7 @@ int TestArrayList(int argc, char* argv[]) if (!arrayList) return -1; - for (index = 0; index < elemsToInsert; index++) + for (size_t index = 0; index < elemsToInsert; index++) { if (!ArrayList_Append(arrayList, (void*)index)) return -1; @@ -29,7 +28,7 @@ int TestArrayList(int argc, char* argv[]) printf("ArrayList count: %d\n", count); - index = ArrayList_IndexOf(arrayList, (void*)(size_t)6, -1, -1); + SSIZE_T index = ArrayList_IndexOf(arrayList, (void*)(size_t)6, -1, -1); printf("ArrayList index: %" PRIdz "\n", index); @@ -52,7 +51,7 @@ int TestArrayList(int argc, char* argv[]) if (rc != 6) return -1; - for (index = 0; index < elemsToInsert; index++) + for (size_t index = 0; index < elemsToInsert; index++) { val = (size_t)ArrayList_GetItem(arrayList, 0); if (!ArrayList_RemoveAt(arrayList, 0)) diff --git a/winpr/libwinpr/utils/test/TestBacktrace.c b/winpr/libwinpr/utils/test/TestBacktrace.c index a6855acb5..5fea333ec 100644 --- a/winpr/libwinpr/utils/test/TestBacktrace.c +++ b/winpr/libwinpr/utils/test/TestBacktrace.c @@ -5,7 +5,6 @@ int TestBacktrace(int argc, char* argv[]) { int rc = -1; size_t used = 0; - size_t x = 0; char** msg = NULL; void* stack = winpr_backtrace(20); @@ -22,7 +21,7 @@ int TestBacktrace(int argc, char* argv[]) if (msg) { - for (x = 0; x < used; x++) + for (size_t x = 0; x < used; x++) printf("%" PRIuz ": %s\n", x, msg[x]); rc = 0; diff --git a/winpr/libwinpr/utils/test/TestBitStream.c b/winpr/libwinpr/utils/test/TestBitStream.c index e4390e863..83c911cb6 100644 --- a/winpr/libwinpr/utils/test/TestBitStream.c +++ b/winpr/libwinpr/utils/test/TestBitStream.c @@ -6,15 +6,13 @@ static void BitStrGen(void) { - DWORD i = 0; - DWORD j = 0; - char str[64]; + char str[64] = { 0 }; - for (i = 0; i < 256;) + for (DWORD i = 0; i < 256;) { printf("\t"); - for (j = 0; j < 4; j++) + for (DWORD j = 0; j < 4; j++) { if (0) { diff --git a/winpr/libwinpr/utils/test/TestCmdLine.c b/winpr/libwinpr/utils/test/TestCmdLine.c index 5aebdb64e..b6657f5c6 100644 --- a/winpr/libwinpr/utils/test/TestCmdLine.c +++ b/winpr/libwinpr/utils/test/TestCmdLine.c @@ -76,12 +76,10 @@ static BOOL checkResult(size_t index, char** actual, size_t actualCount) } else { - size_t x = 0; - if (!actual) return FALSE; - for (x = 0; x < actualCount; x++) + for (size_t x = 0; x < actualCount; x++) { const char* a = result[x]; const char* b = actual[x]; @@ -96,12 +94,10 @@ static BOOL checkResult(size_t index, char** actual, size_t actualCount) static BOOL TestCommandLineParseCommaSeparatedValuesEx(void) { - size_t x = 0; - WINPR_ASSERT(ARRAYSIZE(testListArgs) == ARRAYSIZE(testListArgsResult)); WINPR_ASSERT(ARRAYSIZE(testListArgs) == ARRAYSIZE(testListArgsCount)); - for (x = 0; x < ARRAYSIZE(testListArgs); x++) + for (size_t x = 0; x < ARRAYSIZE(testListArgs); x++) { const char* list = testListArgs[x]; size_t count = 42; diff --git a/winpr/libwinpr/utils/test/TestPrint.c b/winpr/libwinpr/utils/test/TestPrint.c index 955adfd84..f60b90333 100644 --- a/winpr/libwinpr/utils/test/TestPrint.c +++ b/winpr/libwinpr/utils/test/TestPrint.c @@ -346,7 +346,7 @@ int TestPrint(int argc, char* argv[]) * 300 148.889 */ - for (a = 0; a <= 300; a = a + 20) + for (int a = 0; a <= 300; a = a + 20) _printf("%3d %06.3f\n", a, (5.0 / 9.0) * (a - 32)); /** diff --git a/winpr/libwinpr/utils/test/TestQueue.c b/winpr/libwinpr/utils/test/TestQueue.c index 396055d4f..9c65af5f4 100644 --- a/winpr/libwinpr/utils/test/TestQueue.c +++ b/winpr/libwinpr/utils/test/TestQueue.c @@ -6,7 +6,6 @@ int TestQueue(int argc, char* argv[]) { size_t item = 0; - size_t index = 0; size_t count = 0; wQueue* queue = NULL; @@ -17,7 +16,7 @@ int TestQueue(int argc, char* argv[]) if (!queue) return -1; - for (index = 1; index <= 10; index++) + for (size_t index = 1; index <= 10; index++) { Queue_Enqueue(queue, (void*)(size_t)index); } @@ -25,7 +24,7 @@ int TestQueue(int argc, char* argv[]) count = Queue_Count(queue); printf("queue count: %" PRIuz "\n", count); - for (index = 1; index <= 10; index++) + for (size_t index = 1; index <= 10; index++) { item = (size_t)Queue_Dequeue(queue); diff --git a/winpr/libwinpr/utils/test/TestStream.c b/winpr/libwinpr/utils/test/TestStream.c index 8f344a736..00130ae3e 100644 --- a/winpr/libwinpr/utils/test/TestStream.c +++ b/winpr/libwinpr/utils/test/TestStream.c @@ -130,17 +130,14 @@ static BOOL TestStream_Static(void) static BOOL TestStream_Create(size_t count, BOOL selfAlloc) { - size_t i = 0; size_t len = 0; size_t cap = 0; - size_t pos = 0; wStream* s = NULL; void* buffer = NULL; - for (i = 0; i < count; i++) + for (size_t i = 0; i < count; i++) { len = cap = i + 1; - pos = 0; if (selfAlloc) { @@ -157,12 +154,12 @@ static BOOL TestStream_Create(size_t count, BOOL selfAlloc) goto fail; } - if (!TestStream_Verify(s, cap, len, pos)) + if (!TestStream_Verify(s, cap, len, 0)) { goto fail; } - for (pos = 0; pos < len; pos++) + for (size_t pos = 0; pos < len; pos++) { Stream_SetPosition(s, pos); Stream_SealLength(s); @@ -202,7 +199,6 @@ fail: static BOOL TestStream_Extent(UINT32 maxSize) { - UINT32 i = 0; wStream* s = NULL; BOOL result = FALSE; @@ -212,7 +208,7 @@ static BOOL TestStream_Extent(UINT32 maxSize) return FALSE; } - for (i = 1; i < maxSize; i++) + for (UINT32 i = 1; i < maxSize; i++) { if (i % 2) { @@ -504,7 +500,6 @@ out: static BOOL TestStream_Zero(void) { - UINT32 x = 0; BOOL rc = FALSE; const BYTE data[] = "someteststreamdata"; wStream* s = Stream_New(NULL, sizeof(data)); @@ -535,7 +530,7 @@ static BOOL TestStream_Zero(void) if (s->pointer != s->buffer) goto out; - for (x = 0; x < 5; x++) + for (UINT32 x = 0; x < 5; x++) { UINT8 val = 0; Stream_Read_UINT8(s, val); diff --git a/winpr/libwinpr/utils/test/TestStreamPool.c b/winpr/libwinpr/utils/test/TestStreamPool.c index 8dc4dc1e4..1844a531c 100644 --- a/winpr/libwinpr/utils/test/TestStreamPool.c +++ b/winpr/libwinpr/utils/test/TestStreamPool.c @@ -7,14 +7,13 @@ int TestStreamPool(int argc, char* argv[]) { - wStream* s[5]; - wStreamPool* pool = NULL; - char buffer[8192]; + wStream* s[5] = { 0 }; + char buffer[8192] = { 0 }; WINPR_UNUSED(argc); WINPR_UNUSED(argv); - pool = StreamPool_New(TRUE, BUFFER_SIZE); + wStreamPool* pool = StreamPool_New(TRUE, BUFFER_SIZE); s[0] = StreamPool_Take(pool, 0); s[1] = StreamPool_Take(pool, 0); diff --git a/winpr/libwinpr/utils/unwind/debug.c b/winpr/libwinpr/utils/unwind/debug.c index a787bfaf8..1bc8b94b4 100644 --- a/winpr/libwinpr/utils/unwind/debug.c +++ b/winpr/libwinpr/utils/unwind/debug.c @@ -94,7 +94,6 @@ void winpr_unwind_backtrace_free(void* buffer) char** winpr_unwind_backtrace_symbols(void* buffer, size_t* used) { - size_t x = 0; union { char* cp; @@ -113,7 +112,7 @@ char** winpr_unwind_backtrace_symbols(void* buffer, size_t* used) if (used) *used = ctx->pos; - for (x = 0; x < ctx->pos; x++) + for (size_t x = 0; x < ctx->pos; x++) { char* msg = cnv.cp + ctx->pos * sizeof(char*) + x * UNWIND_MAX_LINE_SIZE; const unwind_info_t* info = &ctx->info[x]; diff --git a/winpr/libwinpr/utils/windows/debug.c b/winpr/libwinpr/utils/windows/debug.c index 3577fbf3a..84e04c2cd 100644 --- a/winpr/libwinpr/utils/windows/debug.c +++ b/winpr/libwinpr/utils/windows/debug.c @@ -79,7 +79,6 @@ char** winpr_win_backtrace_symbols(void* buffer, size_t* used) return NULL; { - size_t i; size_t line_len = 1024; HANDLE process = GetCurrentProcess(); t_win_stack* data = (t_win_stack*)buffer; @@ -102,10 +101,10 @@ char** winpr_win_backtrace_symbols(void* buffer, size_t* used) symbol->SizeOfStruct = sizeof(SYMBOL_INFO); /* Set the pointers in the allocated buffer's initial array section */ - for (i = 0; i < data->used; i++) + for (size_t i = 0; i < data->used; i++) vlines[i] = (char*)vlines + array_size + i * line_len; - for (i = 0; i < data->used; i++) + for (size_t i = 0; i < data->used; i++) { DWORD64 address = (DWORD64)(data->stack[i]); DWORD displacement; diff --git a/winpr/libwinpr/utils/wlog/wlog.c b/winpr/libwinpr/utils/wlog/wlog.c index 25253732f..4f064ffb0 100644 --- a/winpr/libwinpr/utils/wlog/wlog.c +++ b/winpr/libwinpr/utils/wlog/wlog.c @@ -77,14 +77,13 @@ static void WLog_Uninit_(void) __attribute__((destructor)); static void WLog_Uninit_(void) { - DWORD index = 0; wLog* child = NULL; wLog* root = g_RootLog; if (!root) return; - for (index = 0; index < root->ChildrenCount; index++) + for (DWORD index = 0; index < root->ChildrenCount; index++) { child = root->Children[index]; WLog_Free(child); @@ -180,7 +179,6 @@ static BOOL log_recursion(LPCSTR file, LPCSTR fkt, size_t line) BOOL status = FALSE; char** msg = NULL; size_t used = 0; - size_t i = 0; void* bt = winpr_backtrace(20); #if defined(ANDROID) LPCSTR tag = WINPR_TAG("utils.wlog"); @@ -202,7 +200,7 @@ static BOOL log_recursion(LPCSTR file, LPCSTR fkt, size_t line) if (__android_log_print(ANDROID_LOG_FATAL, tag, "Check %s [%s:%zu]", fkt, file, line) < 0) goto out; - for (i = 0; i < used; i++) + for (size_t i = 0; i < used; i++) if (__android_log_print(ANDROID_LOG_FATAL, tag, "%zu: %s", i, msg[i]) < 0) goto out; @@ -214,7 +212,7 @@ static BOOL log_recursion(LPCSTR file, LPCSTR fkt, size_t line) if (fprintf(stderr, "[%s]: Check %s:%" PRIuz "\n", fkt, file, line) < 0) goto out; - for (i = 0; i < used; i++) + for (size_t i = 0; i < used; i++) if (fprintf(stderr, "%s: %" PRIuz ": %s\n", fkt, i, msg[i]) < 0) goto out; @@ -472,14 +470,12 @@ BOOL WLog_SetStringLogLevel(wLog* log, LPCSTR level) static BOOL WLog_reset_log_filters(wLog* log) { - DWORD x = 0; - if (!log) return FALSE; log->FilterLevel = WLOG_FILTER_NOT_INITIALIZED; - for (x = 0; x < log->ChildrenCount; x++) + for (DWORD x = 0; x < log->ChildrenCount; x++) { wLog* child = log->Children[x]; @@ -567,10 +563,9 @@ static BOOL WLog_UpdateInheritLevel(wLog* log, DWORD logLevel) if (log->inherit) { - DWORD x = 0; log->Level = logLevel; - for (x = 0; x < log->ChildrenCount; x++) + for (DWORD x = 0; x < log->ChildrenCount; x++) { wLog* child = log->Children[x]; @@ -584,8 +579,6 @@ static BOOL WLog_UpdateInheritLevel(wLog* log, DWORD logLevel) BOOL WLog_SetLogLevel(wLog* log, DWORD logLevel) { - DWORD x = 0; - if (!log) return FALSE; @@ -595,7 +588,7 @@ BOOL WLog_SetLogLevel(wLog* log, DWORD logLevel) log->Level = logLevel; log->inherit = (logLevel == WLOG_LEVEL_INHERIT) ? TRUE : FALSE; - for (x = 0; x < log->ChildrenCount; x++) + for (DWORD x = 0; x < log->ChildrenCount; x++) { wLog* child = log->Children[x]; @@ -742,18 +735,16 @@ BOOL WLog_ParseFilters(wLog* root) LONG WLog_GetFilterLogLevel(wLog* log) { - DWORD i = 0; - DWORD j = 0; BOOL match = FALSE; if (log->FilterLevel >= 0) return log->FilterLevel; log->FilterLevel = WLOG_FILTER_NOT_FILTERED; - for (i = 0; i < g_FilterCount; i++) + for (DWORD i = 0; i < g_FilterCount; i++) { const wLogFilter* filter = &g_Filters[i]; - for (j = 0; j < filter->NameCount; j++) + for (DWORD j = 0; j < filter->NameCount; j++) { if (j >= log->NameCount) break; @@ -988,7 +979,6 @@ exit: static wLog* WLog_FindChild(wLog* root, LPCSTR name) { - DWORD index = 0; wLog* child = NULL; BOOL found = FALSE; @@ -997,7 +987,7 @@ static wLog* WLog_FindChild(wLog* root, LPCSTR name) WLog_Lock(root); - for (index = 0; index < root->ChildrenCount; index++) + for (DWORD index = 0; index < root->ChildrenCount; index++) { child = root->Children[index]; @@ -1049,7 +1039,6 @@ BOOL WLog_Init(void) BOOL WLog_Uninit(void) { - DWORD index = 0; wLog* root = g_RootLog; if (!root) @@ -1057,7 +1046,7 @@ BOOL WLog_Uninit(void) WLog_Lock(root); - for (index = 0; index < root->ChildrenCount; index++) + for (DWORD index = 0; index < root->ChildrenCount; index++) { wLog* child = root->Children[index]; WLog_Free(child); diff --git a/winpr/libwinpr/winsock/winsock.c b/winpr/libwinpr/winsock/winsock.c index af1ccc2c1..3ac8e5081 100644 --- a/winpr/libwinpr/winsock/winsock.c +++ b/winpr/libwinpr/winsock/winsock.c @@ -823,7 +823,6 @@ int WSAIoctl(SOCKET s, DWORD dwIoControlCode, LPVOID lpvInBuffer, DWORD cbInBuff maxNumInterfaces = cbOutBuffer / sizeof(INTERFACE_INFO); #ifdef WSAIOCTL_IFADDRS { - struct ifaddrs* ifa = NULL; struct ifaddrs* ifap = NULL; if (getifaddrs(&ifap) != 0) @@ -835,7 +834,7 @@ int WSAIoctl(SOCKET s, DWORD dwIoControlCode, LPVOID lpvInBuffer, DWORD cbInBuff index = 0; numInterfaces = 0; - for (ifa = ifap; ifa; ifa = ifa->ifa_next) + for (struct ifaddrs* ifa = ifap; ifa; ifa = ifa->ifa_next) { pInterface = &pInterfaces[index]; pAddress = (struct sockaddr_in*)&pInterface->iiAddress; diff --git a/winpr/libwinpr/wtsapi/test/TestWtsApiEnumerateProcesses.c b/winpr/libwinpr/wtsapi/test/TestWtsApiEnumerateProcesses.c index c6ba8db34..f26646c39 100644 --- a/winpr/libwinpr/wtsapi/test/TestWtsApiEnumerateProcesses.c +++ b/winpr/libwinpr/wtsapi/test/TestWtsApiEnumerateProcesses.c @@ -37,9 +37,8 @@ int TestWtsApiEnumerateProcesses(int argc, char* argv[]) #if 0 { - DWORD i; printf("WTSEnumerateProcesses enumerated %"PRIu32" processs:\n", count); - for (i = 0; i < count; i++) + for (DWORD i = 0; i < count; i++) printf("\t[%"PRIu32"]: %s (%"PRIu32")\n", i, pProcessInfo[i].pProcessName, pProcessInfo[i].ProcessId); } #endif diff --git a/winpr/libwinpr/wtsapi/test/TestWtsApiEnumerateSessions.c b/winpr/libwinpr/wtsapi/test/TestWtsApiEnumerateSessions.c index 3a43bbffd..afe48a9df 100644 --- a/winpr/libwinpr/wtsapi/test/TestWtsApiEnumerateSessions.c +++ b/winpr/libwinpr/wtsapi/test/TestWtsApiEnumerateSessions.c @@ -6,7 +6,6 @@ int TestWtsApiEnumerateSessions(int argc, char* argv[]) { - DWORD index = 0; DWORD count = 0; BOOL bSuccess = 0; HANDLE hServer = NULL; @@ -38,7 +37,7 @@ int TestWtsApiEnumerateSessions(int argc, char* argv[]) printf("WTSEnumerateSessions count: %" PRIu32 "\n", count); - for (index = 0; index < count; index++) + for (DWORD index = 0; index < count; index++) { printf("[%" PRIu32 "] SessionId: %" PRIu32 " WinstationName: '%s' State: %s (%u)\n", index, pSessionInfo[index].SessionId, pSessionInfo[index].pWinStationName, diff --git a/winpr/libwinpr/wtsapi/test/TestWtsApiQuerySessionInformation.c b/winpr/libwinpr/wtsapi/test/TestWtsApiQuerySessionInformation.c index 9f652f18d..bc232f0e8 100644 --- a/winpr/libwinpr/wtsapi/test/TestWtsApiQuerySessionInformation.c +++ b/winpr/libwinpr/wtsapi/test/TestWtsApiQuerySessionInformation.c @@ -6,8 +6,6 @@ int TestWtsApiQuerySessionInformation(int argc, char* argv[]) { - DWORD index = 0; - DWORD i = 0; DWORD count = 0; BOOL bSuccess = 0; HANDLE hServer = NULL; @@ -42,7 +40,7 @@ int TestWtsApiQuerySessionInformation(int argc, char* argv[]) printf("WTSEnumerateSessions count: %" PRIu32 "\n", count); - for (index = 0; index < count; index++) + for (DWORD index = 0; index < count; index++) { char* Username = NULL; char* Domain = NULL; @@ -183,7 +181,7 @@ int TestWtsApiQuerySessionInformation(int argc, char* argv[]) ClientAddress = (PWTS_CLIENT_ADDRESS)pBuffer; printf("\tWTSClientAddress: AddressFamily: %" PRIu32 " Address: ", ClientAddress->AddressFamily); - for (i = 0; i < sizeof(ClientAddress->Address); i++) + for (DWORD i = 0; i < sizeof(ClientAddress->Address); i++) printf("%02" PRIX8 "", ClientAddress->Address[i]); printf("\n"); diff --git a/winpr/test/TestTypes.c b/winpr/test/TestTypes.c index 5a368f694..482c87c39 100644 --- a/winpr/test/TestTypes.c +++ b/winpr/test/TestTypes.c @@ -22,7 +22,6 @@ static BOOL test_co_errors(void) { - size_t x = 0; const LONG should[] = { (LONG)0x80004006l, (LONG)0x80004007l, (LONG)0x80004008l, (LONG)0x80004009l, (LONG)0x8000400Al, (LONG)0x8000400Bl, (LONG)0x8000400Cl, (LONG)0x8000400Dl, @@ -98,7 +97,7 @@ static BOOL test_co_errors(void) printf("mismatch: %" PRIuz " vs %" PRIuz "\n", a, b); return FALSE; } - for (x = 0; x < ARRAYSIZE(are); x++) + for (size_t x = 0; x < ARRAYSIZE(are); x++) { const LONG a = are[x]; const LONG b = should[x]; diff --git a/winpr/tools/hash-cli/hash.c b/winpr/tools/hash-cli/hash.c index 37d25c926..b98f8e9c9 100644 --- a/winpr/tools/hash-cli/hash.c +++ b/winpr/tools/hash-cli/hash.c @@ -189,7 +189,7 @@ int main(int argc, char* argv[]) if (format == 0) { - for (index = 0; index < 16; index++) + for (int index = 0; index < 16; index++) printf("%02" PRIx8 "", NtHash[index]); printf("\n"); @@ -205,7 +205,7 @@ int main(int argc, char* argv[]) printf(":"); - for (index = 0; index < 16; index++) + for (int index = 0; index < 16; index++) printf("%02" PRIx8 "", NtHash[index]); printf(":::");