Skip to content

Commit d7ebec5

Browse files
committed
[tidy] move loop variable declaration to loop
1 parent 62f974a commit d7ebec5

File tree

345 files changed

+1569
-2829
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

345 files changed

+1569
-2829
lines changed

channels/audin/client/ios/audin_ios.m

+1-2
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ static UINT audin_ios_open(IAudinDevice *device, AudinReceive receive, void *use
222222
DWORD errCode;
223223
char errString[1024];
224224
OSStatus devStat;
225-
size_t index;
226225

227226
ios->receive = receive;
228227
ios->user_data = user_data;
@@ -237,7 +236,7 @@ static UINT audin_ios_open(IAudinDevice *device, AudinReceive receive, void *use
237236
goto err_out;
238237
}
239238

240-
for (index = 0; index < IOS_AUDIO_QUEUE_NUM_BUFFERS; index++)
239+
for (size_t index = 0; index < IOS_AUDIO_QUEUE_NUM_BUFFERS; index++)
241240
{
242241
devStat = AudioQueueAllocateBuffer(ios->audioQueue,
243242
ios->FramesPerPacket * 2 * ios->format.nChannels,

channels/audin/client/mac/audin_mac.m

+1-2
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ static UINT audin_mac_open(IAudinDevice *device, AudinReceive receive, void *use
247247
DWORD errCode;
248248
char errString[1024];
249249
OSStatus devStat;
250-
size_t index;
251250

252251
if (!mac->isAuthorized)
253252
return ERROR_INTERNAL_ERROR;
@@ -265,7 +264,7 @@ static UINT audin_mac_open(IAudinDevice *device, AudinReceive receive, void *use
265264
goto err_out;
266265
}
267266

268-
for (index = 0; index < MAC_AUDIO_QUEUE_NUM_BUFFERS; index++)
267+
for (size_t index = 0; index < MAC_AUDIO_QUEUE_NUM_BUFFERS; index++)
269268
{
270269
devStat = AudioQueueAllocateBuffer(mac->audioQueue,
271270
mac->FramesPerPacket * 2 * mac->format.nChannels,

channels/audin/client/winmm/audin_winmm.c

+8-10
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,11 @@ static BOOL test_format_supported(const PWAVEFORMATEX pwfx)
168168
static DWORD WINAPI audin_winmm_thread_func(LPVOID arg)
169169
{
170170
AudinWinmmDevice* winmm = (AudinWinmmDevice*)arg;
171-
char* buffer;
172-
int size, i;
171+
char* buffer = NULL;
172+
int size = 0;
173173
WAVEHDR waveHdr[4] = { 0 };
174-
DWORD status;
175-
MMRESULT rc;
174+
DWORD status = 0;
175+
MMRESULT rc = 0;
176176

177177
if (!winmm->hWaveIn)
178178
{
@@ -189,7 +189,7 @@ static DWORD WINAPI audin_winmm_thread_func(LPVOID arg)
189189
7) /
190190
8;
191191

192-
for (i = 0; i < 4; i++)
192+
for (int i = 0; i < 4; i++)
193193
{
194194
buffer = (char*)malloc(size);
195195

@@ -235,7 +235,7 @@ static DWORD WINAPI audin_winmm_thread_func(LPVOID arg)
235235
{
236236
}
237237

238-
for (i = 0; i < 4; i++)
238+
for (int i = 0; i < 4; i++)
239239
{
240240
rc = waveInUnprepareHeader(winmm->hWaveIn, &waveHdr[i], sizeof(waveHdr[i]));
241241

@@ -263,13 +263,12 @@ static DWORD WINAPI audin_winmm_thread_func(LPVOID arg)
263263
*/
264264
static UINT audin_winmm_free(IAudinDevice* device)
265265
{
266-
UINT32 i;
267266
AudinWinmmDevice* winmm = (AudinWinmmDevice*)device;
268267

269268
if (!winmm)
270269
return ERROR_INVALID_PARAMETER;
271270

272-
for (i = 0; i < winmm->cFormats; i++)
271+
for (UINT32 i = 0; i < winmm->cFormats; i++)
273272
{
274273
free(winmm->ppwfx[i]);
275274
}
@@ -322,15 +321,14 @@ static UINT audin_winmm_close(IAudinDevice* device)
322321
static UINT audin_winmm_set_format(IAudinDevice* device, const AUDIO_FORMAT* format,
323322
UINT32 FramesPerPacket)
324323
{
325-
UINT32 i;
326324
AudinWinmmDevice* winmm = (AudinWinmmDevice*)device;
327325

328326
if (!winmm || !format)
329327
return ERROR_INVALID_PARAMETER;
330328

331329
winmm->frames_per_packet = FramesPerPacket;
332330

333-
for (i = 0; i < winmm->cFormats; i++)
331+
for (UINT32 i = 0; i < winmm->cFormats; i++)
334332
{
335333
const PWAVEFORMATEX ppwfx = winmm->ppwfx[i];
336334
if ((ppwfx->wFormatTag == format->wFormatTag) && (ppwfx->nChannels == format->nChannels) &&

channels/client/addin.c

+5-12
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ static FREERDP_ADDIN** freerdp_channels_list_client_static_addins(LPCSTR pszName
8787
LPCSTR pszSubsystem,
8888
LPCSTR pszType, DWORD dwFlags)
8989
{
90-
size_t i = 0;
91-
size_t j = 0;
9290
DWORD nAddins = 0;
9391
FREERDP_ADDIN** ppAddins = NULL;
9492
const STATIC_SUBSYSTEM_ENTRY* subsystems = NULL;
@@ -103,7 +101,7 @@ static FREERDP_ADDIN** freerdp_channels_list_client_static_addins(LPCSTR pszName
103101

104102
ppAddins[nAddins] = NULL;
105103

106-
for (i = 0; CLIENT_STATIC_ADDIN_TABLE[i].name != NULL; i++)
104+
for (size_t i = 0; CLIENT_STATIC_ADDIN_TABLE[i].name != NULL; i++)
107105
{
108106
FREERDP_ADDIN* pAddin = (FREERDP_ADDIN*)calloc(1, sizeof(FREERDP_ADDIN));
109107

@@ -120,7 +118,7 @@ static FREERDP_ADDIN** freerdp_channels_list_client_static_addins(LPCSTR pszName
120118
ppAddins[nAddins++] = pAddin;
121119
subsystems = (const STATIC_SUBSYSTEM_ENTRY*)CLIENT_STATIC_ADDIN_TABLE[i].table;
122120

123-
for (j = 0; subsystems[j].name != NULL; j++)
121+
for (size_t j = 0; subsystems[j].name != NULL; j++)
124122
{
125123
pAddin = (FREERDP_ADDIN*)calloc(1, sizeof(FREERDP_ADDIN));
126124

@@ -165,7 +163,6 @@ static HANDLE FindFirstFileUTF8(LPCSTR pszSearchPath, WIN32_FIND_DATAW* FindData
165163
static FREERDP_ADDIN** freerdp_channels_list_dynamic_addins(LPCSTR pszName, LPCSTR pszSubsystem,
166164
LPCSTR pszType, DWORD dwFlags)
167165
{
168-
int index = 0;
169166
int nDashes = 0;
170167
HANDLE hFind = NULL;
171168
DWORD nAddins = 0;
@@ -270,7 +267,7 @@ static FREERDP_ADDIN** freerdp_channels_list_dynamic_addins(LPCSTR pszName, LPCS
270267
goto skip;
271268

272269
nDashes = 0;
273-
for (index = 0; cFileName[index]; index++)
270+
for (size_t index = 0; cFileName[index]; index++)
274271
nDashes += (cFileName[index] == '-') ? 1 : 0;
275272

276273
if (nDashes == 1)
@@ -428,12 +425,10 @@ FREERDP_ADDIN** freerdp_channels_list_addins(LPCSTR pszName, LPCSTR pszSubsystem
428425

429426
void freerdp_channels_addin_list_free(FREERDP_ADDIN** ppAddins)
430427
{
431-
size_t index = 0;
432-
433428
if (!ppAddins)
434429
return;
435430

436-
for (index = 0; ppAddins[index] != NULL; index++)
431+
for (size_t index = 0; ppAddins[index] != NULL; index++)
437432
free(ppAddins[index]);
438433

439434
free(ppAddins);
@@ -443,9 +438,7 @@ extern const STATIC_ENTRY CLIENT_VirtualChannelEntryEx_TABLE[];
443438

444439
static BOOL freerdp_channels_is_virtual_channel_entry_ex(LPCSTR pszName)
445440
{
446-
size_t i = 0;
447-
448-
for (i = 0; CLIENT_VirtualChannelEntryEx_TABLE[i].name != NULL; i++)
441+
for (size_t i = 0; CLIENT_VirtualChannelEntryEx_TABLE[i].name != NULL; i++)
449442
{
450443
const STATIC_ENTRY* entry = &CLIENT_VirtualChannelEntryEx_TABLE[i];
451444

channels/cliprdr/client/cliprdr_main.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ static UINT cliprdr_process_general_capability(cliprdrPlugin* cliprdr, wStream*
223223
static UINT cliprdr_process_clip_caps(cliprdrPlugin* cliprdr, wStream* s, UINT32 length,
224224
UINT16 flags)
225225
{
226-
UINT16 index = 0;
227226
UINT16 lengthCapability = 0;
228227
UINT16 cCapabilitiesSets = 0;
229228
UINT16 capabilitySetType = 0;
@@ -239,7 +238,7 @@ static UINT cliprdr_process_clip_caps(cliprdrPlugin* cliprdr, wStream* s, UINT32
239238
Stream_Seek_UINT16(s); /* pad1 (2 bytes) */
240239
WLog_Print(cliprdr->log, WLOG_DEBUG, "ServerCapabilities");
241240

242-
for (index = 0; index < cCapabilitiesSets; index++)
241+
for (UINT16 index = 0; index < cCapabilitiesSets; index++)
243242
{
244243
if (!Stream_CheckAndLogRequiredLength(TAG, s, 4))
245244
return ERROR_INVALID_DATA;

channels/cliprdr/cliprdr_common.c

+4-7
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ wStream* cliprdr_packet_format_list_new(const CLIPRDR_FORMAT_LIST* formatList,
184184
BOOL useLongFormatNames)
185185
{
186186
wStream* s = NULL;
187-
UINT32 index = 0;
188187
size_t formatNameSize = 0;
189188
char* szFormatName = NULL;
190189
WCHAR* wszFormatName = NULL;
@@ -206,7 +205,7 @@ wStream* cliprdr_packet_format_list_new(const CLIPRDR_FORMAT_LIST* formatList,
206205
return NULL;
207206
}
208207

209-
for (index = 0; index < formatList->numFormats; index++)
208+
for (UINT32 index = 0; index < formatList->numFormats; index++)
210209
{
211210
size_t formatNameLength = 0;
212211
format = (CLIPRDR_FORMAT*)&(formatList->formats[index]);
@@ -259,7 +258,7 @@ wStream* cliprdr_packet_format_list_new(const CLIPRDR_FORMAT_LIST* formatList,
259258
else
260259
{
261260
length = 0;
262-
for (index = 0; index < formatList->numFormats; index++)
261+
for (UINT32 index = 0; index < formatList->numFormats; index++)
263262
{
264263
format = (CLIPRDR_FORMAT*)&(formatList->formats[index]);
265264
length += 4;
@@ -284,7 +283,7 @@ wStream* cliprdr_packet_format_list_new(const CLIPRDR_FORMAT_LIST* formatList,
284283
return NULL;
285284
}
286285

287-
for (index = 0; index < formatList->numFormats; index++)
286+
for (UINT32 index = 0; index < formatList->numFormats; index++)
288287
{
289288
format = (CLIPRDR_FORMAT*)&(formatList->formats[index]);
290289
Stream_Write_UINT32(s, format->formatId); /* formatId (4 bytes) */
@@ -550,14 +549,12 @@ UINT cliprdr_read_format_list(wStream* s, CLIPRDR_FORMAT_LIST* formatList, BOOL
550549

551550
void cliprdr_free_format_list(CLIPRDR_FORMAT_LIST* formatList)
552551
{
553-
UINT index = 0;
554-
555552
if (formatList == NULL)
556553
return;
557554

558555
if (formatList->formats)
559556
{
560-
for (index = 0; index < formatList->numFormats; index++)
557+
for (UINT32 index = 0; index < formatList->numFormats; index++)
561558
{
562559
free(formatList->formats[index].formatName);
563560
}

channels/cliprdr/server/cliprdr_main.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,12 @@ static UINT cliprdr_server_capabilities(CliprdrServerContext* context,
119119
const CLIPRDR_CAPABILITIES* capabilities)
120120
{
121121
size_t offset = 0;
122-
UINT32 x = 0;
123122
wStream* s = NULL;
124-
CliprdrServerPrivate* cliprdr = NULL;
125123

126124
WINPR_ASSERT(context);
127125
WINPR_ASSERT(capabilities);
128126

129-
cliprdr = (CliprdrServerPrivate*)context->handle;
127+
CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*)context->handle;
130128

131129
if (capabilities->common.msgType != CB_CLIP_CAPS)
132130
WLog_WARN(TAG, "called with invalid type %08" PRIx32, capabilities->common.msgType);
@@ -148,7 +146,7 @@ static UINT cliprdr_server_capabilities(CliprdrServerContext* context,
148146
Stream_Write_UINT16(s,
149147
(UINT16)capabilities->cCapabilitiesSets); /* cCapabilitiesSets (2 bytes) */
150148
Stream_Write_UINT16(s, 0); /* pad1 (2 bytes) */
151-
for (x = 0; x < capabilities->cCapabilitiesSets; x++)
149+
for (UINT32 x = 0; x < capabilities->cCapabilitiesSets; x++)
152150
{
153151
const CLIPRDR_CAPABILITY_SET* cap =
154152
(const CLIPRDR_CAPABILITY_SET*)(((const BYTE*)capabilities->capabilitySets) + offset);

channels/disp/client/disp_main.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ disp_send_display_control_monitor_layout_pdu(GENERIC_CHANNEL_CALLBACK* callback,
6363
{
6464
UINT status = 0;
6565
wStream* s = NULL;
66-
UINT32 index = 0;
6766
DISP_PLUGIN* disp = NULL;
6867
UINT32 MonitorLayoutSize = 0;
6968
DISPLAY_CONTROL_HEADER header = { 0 };
@@ -99,7 +98,7 @@ disp_send_display_control_monitor_layout_pdu(GENERIC_CHANNEL_CALLBACK* callback,
9998
Stream_Write_UINT32(s, NumMonitors); /* NumMonitors (4 bytes) */
10099
WLog_DBG(TAG, "NumMonitors=%" PRIu32 "", NumMonitors);
101100

102-
for (index = 0; index < NumMonitors; index++)
101+
for (UINT32 index = 0; index < NumMonitors; index++)
103102
{
104103
DISPLAY_CONTROL_MONITOR_LAYOUT current = Monitors[index];
105104
current.Width -= (current.Width % 2);

channels/disp/server/disp_main.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ static BOOL disp_server_is_monitor_layout_valid(const DISPLAY_CONTROL_MONITOR_LA
127127
static UINT disp_recv_display_control_monitor_layout_pdu(wStream* s, DispServerContext* context)
128128
{
129129
UINT32 error = CHANNEL_RC_OK;
130-
UINT32 index = 0;
131130
DISPLAY_CONTROL_MONITOR_LAYOUT_PDU pdu = { 0 };
132131

133132
WINPR_ASSERT(s);
@@ -170,7 +169,7 @@ static UINT disp_recv_display_control_monitor_layout_pdu(wStream* s, DispServerC
170169
WLog_DBG(TAG, "disp_recv_display_control_monitor_layout_pdu: NumMonitors=%" PRIu32 "",
171170
pdu.NumMonitors);
172171

173-
for (index = 0; index < pdu.NumMonitors; index++)
172+
for (UINT32 index = 0; index < pdu.NumMonitors; index++)
174173
{
175174
DISPLAY_CONTROL_MONITOR_LAYOUT* monitor = &(pdu.Monitors[index]);
176175

channels/drdynvc/client/drdynvc_main.c

+6-11
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ static UINT dvcman_register_plugin(IDRDYNVC_ENTRY_POINTS* pEntryPoints, const ch
152152
static IWTSPlugin* dvcman_get_plugin(IDRDYNVC_ENTRY_POINTS* pEntryPoints, const char* name)
153153
{
154154
IWTSPlugin* plugin = NULL;
155-
size_t i = 0;
156155
size_t nc = 0;
157156
size_t pc = 0;
158157
WINPR_ASSERT(pEntryPoints);
@@ -167,7 +166,7 @@ static IWTSPlugin* dvcman_get_plugin(IDRDYNVC_ENTRY_POINTS* pEntryPoints, const
167166

168167
ArrayList_Lock(dvcman->plugin_names);
169168
ArrayList_Lock(dvcman->plugins);
170-
for (i = 0; i < pc; i++)
169+
for (size_t i = 0; i < pc; i++)
171170
{
172171
const char* cur = ArrayList_GetItem(dvcman->plugin_names, i);
173172
if (strcmp(cur, name) == 0)
@@ -579,13 +578,12 @@ static void dvcman_free(drdynvcPlugin* drdynvc, IWTSVirtualChannelManager* pChan
579578
*/
580579
static UINT dvcman_init(drdynvcPlugin* drdynvc, IWTSVirtualChannelManager* pChannelMgr)
581580
{
582-
size_t i = 0;
583581
DVCMAN* dvcman = (DVCMAN*)pChannelMgr;
584582
UINT error = CHANNEL_RC_OK;
585583

586584
WINPR_ASSERT(dvcman);
587585
ArrayList_Lock(dvcman->plugins);
588-
for (i = 0; i < ArrayList_Count(dvcman->plugins); i++)
586+
for (size_t i = 0; i < ArrayList_Count(dvcman->plugins); i++)
589587
{
590588
IWTSPlugin* pPlugin = ArrayList_GetItem(dvcman->plugins, i);
591589

@@ -1672,7 +1670,6 @@ static UINT drdynvc_virtual_channel_event_connected(drdynvcPlugin* drdynvc, LPVO
16721670
{
16731671
UINT error = 0;
16741672
UINT32 status = 0;
1675-
UINT32 index = 0;
16761673
rdpSettings* settings = NULL;
16771674

16781675
WINPR_ASSERT(drdynvc);
@@ -1698,8 +1695,8 @@ static UINT drdynvc_virtual_channel_event_connected(drdynvcPlugin* drdynvc, LPVO
16981695
settings = drdynvc->rdpcontext->settings;
16991696
WINPR_ASSERT(settings);
17001697

1701-
for (index = 0; index < freerdp_settings_get_uint32(settings, FreeRDP_DynamicChannelCount);
1702-
index++)
1698+
for (UINT32 index = 0;
1699+
index < freerdp_settings_get_uint32(settings, FreeRDP_DynamicChannelCount); index++)
17031700
{
17041701
const ADDIN_ARGV* args =
17051702
freerdp_settings_get_pointer_array(settings, FreeRDP_DynamicChannelArray, index);
@@ -1834,7 +1831,6 @@ static UINT drdynvc_virtual_channel_event_terminated(drdynvcPlugin* drdynvc)
18341831
static UINT drdynvc_virtual_channel_event_attached(drdynvcPlugin* drdynvc)
18351832
{
18361833
UINT error = CHANNEL_RC_OK;
1837-
size_t i = 0;
18381834
DVCMAN* dvcman = NULL;
18391835

18401836
if (!drdynvc)
@@ -1846,7 +1842,7 @@ static UINT drdynvc_virtual_channel_event_attached(drdynvcPlugin* drdynvc)
18461842
return CHANNEL_RC_BAD_CHANNEL_HANDLE;
18471843

18481844
ArrayList_Lock(dvcman->plugins);
1849-
for (i = 0; i < ArrayList_Count(dvcman->plugins); i++)
1845+
for (size_t i = 0; i < ArrayList_Count(dvcman->plugins); i++)
18501846
{
18511847
IWTSPlugin* pPlugin = ArrayList_GetItem(dvcman->plugins, i);
18521848

@@ -1866,7 +1862,6 @@ static UINT drdynvc_virtual_channel_event_attached(drdynvcPlugin* drdynvc)
18661862
static UINT drdynvc_virtual_channel_event_detached(drdynvcPlugin* drdynvc)
18671863
{
18681864
UINT error = CHANNEL_RC_OK;
1869-
size_t i = 0;
18701865
DVCMAN* dvcman = NULL;
18711866

18721867
if (!drdynvc)
@@ -1878,7 +1873,7 @@ static UINT drdynvc_virtual_channel_event_detached(drdynvcPlugin* drdynvc)
18781873
return CHANNEL_RC_BAD_CHANNEL_HANDLE;
18791874

18801875
ArrayList_Lock(dvcman->plugins);
1881-
for (i = 0; i < ArrayList_Count(dvcman->plugins); i++)
1876+
for (size_t i = 0; i < ArrayList_Count(dvcman->plugins); i++)
18821877
{
18831878
IWTSPlugin* pPlugin = ArrayList_GetItem(dvcman->plugins, i);
18841879

channels/drive/client/drive_file.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,12 @@
6161

6262
static BOOL drive_file_fix_path(WCHAR* path, size_t length)
6363
{
64-
size_t i = 0;
65-
6664
if ((length == 0) || (length > UINT32_MAX))
6765
return FALSE;
6866

6967
WINPR_ASSERT(path);
7068

71-
for (i = 0; i < length; i++)
69+
for (size_t i = 0; i < length; i++)
7270
{
7371
if (path[i] == L'\\')
7472
path[i] = L'/';

0 commit comments

Comments
 (0)