Skip to content

Commit e72f317

Browse files
committed
fix static analysis errors
1 parent 7608cc7 commit e72f317

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

src/api/Client/WinMM/winmmdrv.cpp

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ struct MIDICLIENT
5252
LPMIDIHDR buffers[16] {0};
5353
};
5454

55-
struct MIDICLIENT g_InClients[32];
56-
struct MIDICLIENT g_OutClients[32];
55+
#define MAX_CLIENTS 32
56+
57+
struct MIDICLIENT g_InClients[MAX_CLIENTS];
58+
struct MIDICLIENT g_OutClients[MAX_CLIENTS];
5759

5860
void Callback(struct MIDICLIENT* client, UINT msg, DWORD_PTR dw1, DWORD_PTR dw2)
5961
{
@@ -94,9 +96,9 @@ DWORD APIENTRY midMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
9496
case MIDM_OPEN:
9597
{
9698
UINT freeIndex = 0;
97-
for (freeIndex = 0; g_InClients[freeIndex].used && freeIndex < 32; freeIndex++);
99+
for (freeIndex = 0;freeIndex < MAX_CLIENTS && g_InClients[freeIndex].used; freeIndex++);
98100

99-
if (freeIndex < 32 &&
101+
if (freeIndex < MAX_CLIENTS &&
100102
dwParam1 >= sizeof(MIDIOPENDESC))
101103
{
102104
g_InClients[freeIndex].used = TRUE;
@@ -118,7 +120,7 @@ DWORD APIENTRY midMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
118120
{
119121
mmResult = MMSYSERR_ERROR;
120122

121-
for (UINT index = 0; index < 32; index++)
123+
for (UINT index = 0; index < MAX_CLIENTS; index++)
122124
{
123125
if (g_InClients[index].used && g_InClients[index].user == dwUser)
124126
{
@@ -141,7 +143,7 @@ DWORD APIENTRY midMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
141143
if (nullptr != header &&
142144
dwParam2 >= sizeof(MIDIHDR))
143145
{
144-
for (UINT index = 0; index < 32; index++)
146+
for (UINT index = 0; index < MAX_CLIENTS; index++)
145147
{
146148
if (g_InClients[index].used && g_InClients[index].user == dwUser)
147149
{
@@ -169,7 +171,7 @@ DWORD APIENTRY midMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
169171
{
170172
mmResult = MMSYSERR_ERROR;
171173

172-
for (UINT index = 0; index < 32; index++)
174+
for (UINT index = 0; index < MAX_CLIENTS; index++)
173175
{
174176
if (g_InClients[index].used && g_InClients[index].user == dwUser)
175177
{
@@ -185,7 +187,7 @@ DWORD APIENTRY midMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
185187
{
186188
mmResult = MMSYSERR_ERROR;
187189

188-
for (UINT index = 0; index < 32; index++)
190+
for (UINT index = 0; index < MAX_CLIENTS; index++)
189191
{
190192
if (g_InClients[index].used && g_InClients[index].user == dwUser)
191193
{
@@ -201,7 +203,7 @@ DWORD APIENTRY midMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
201203
{
202204
mmResult = MMSYSERR_ERROR;
203205

204-
for (UINT index = 0; index < 32; index++)
206+
for (UINT index = 0; index < MAX_CLIENTS; index++)
205207
{
206208
if (g_InClients[index].used && g_InClients[index].user == dwUser)
207209
{
@@ -252,9 +254,9 @@ DWORD APIENTRY modMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
252254
case MODM_OPEN:
253255
{
254256
UINT freeIndex = 0;
255-
for (freeIndex = 0; g_OutClients[freeIndex].used && freeIndex < 32; freeIndex++);
257+
for (freeIndex = 0;freeIndex < MAX_CLIENTS && g_OutClients[freeIndex].used; freeIndex++);
256258

257-
if (freeIndex < 32 &&
259+
if (freeIndex < MAX_CLIENTS &&
258260
dwParam1 >= sizeof(MIDIOPENDESC))
259261
{
260262
g_OutClients[freeIndex].used = TRUE;
@@ -276,7 +278,7 @@ DWORD APIENTRY modMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
276278
{
277279
mmResult = MMSYSERR_ERROR;
278280

279-
for (UINT index = 0; index < 32; index++)
281+
for (UINT index = 0; index < MAX_CLIENTS; index++)
280282
{
281283
if (g_OutClients[index].used &&
282284
g_OutClients[index].user == dwUser)
@@ -299,13 +301,13 @@ DWORD APIENTRY modMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
299301
if (nullptr != header &&
300302
dwParam2 >= sizeof(MIDIHDR))
301303
{
302-
for (UINT outIndex = 0; outIndex < 32; outIndex++)
304+
for (UINT outIndex = 0; outIndex < MAX_CLIENTS; outIndex++)
303305
{
304306
if (g_OutClients[outIndex].used && g_OutClients[outIndex].user == dwUser)
305307
{
306308
mmResult = MMSYSERR_NOERROR;
307309

308-
for (UINT inIndex = 0; inIndex < 32; inIndex++)
310+
for (UINT inIndex = 0; inIndex < MAX_CLIENTS; inIndex++)
309311
{
310312
if (g_InClients[inIndex].used &&
311313
g_OutClients[outIndex].device == g_InClients[inIndex].device)
@@ -334,13 +336,13 @@ DWORD APIENTRY modMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
334336
{
335337
mmResult = MMSYSERR_ERROR;
336338

337-
for (UINT outIndex = 0; outIndex < 32; outIndex++)
339+
for (UINT outIndex = 0; outIndex < MAX_CLIENTS; outIndex++)
338340
{
339341
if (g_OutClients[outIndex].used && g_OutClients[outIndex].user == dwUser)
340342
{
341343
mmResult = MMSYSERR_NOERROR;
342344

343-
for (UINT inIndex = 0; inIndex < 32; inIndex++)
345+
for (UINT inIndex = 0; inIndex < MAX_CLIENTS; inIndex++)
344346
{
345347
if (g_InClients[inIndex].used &&
346348
g_OutClients[outIndex].device == g_InClients[inIndex].device)
@@ -362,7 +364,7 @@ DWORD APIENTRY modMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
362364
{
363365
mmResult = MMSYSERR_ERROR;
364366

365-
for (UINT index = 0; index < 32; index++)
367+
for (UINT index = 0; index < MAX_CLIENTS; index++)
366368
{
367369
if (g_OutClients[index].used && g_OutClients[index].user == dwUser)
368370
{

src/api/Inc/MidiKSCommon.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ InstantiateMidiPin(
5454

5555
BOOL
5656
IsAutogeneratedPinName(
57-
_In_ const WCHAR* FilterName,
57+
_In_z_ const WCHAR* FilterName,
5858
_In_ ULONG PinId,
59-
_In_ const WCHAR* NameToCheck
59+
_In_z_ const WCHAR* NameToCheck
6060
);
6161

src/api/Libs/MidiKsCommon/MidiKsCommon.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,6 @@ InstantiateMidiPin(
274274
return S_OK;
275275
}
276276

277-
_Use_decl_annotations_
278277
BOOL
279278
IsAutogeneratedPinName(
280279
const WCHAR* FilterName,

0 commit comments

Comments
 (0)