Skip to content

Commit

Permalink
fix static analysis errors
Browse files Browse the repository at this point in the history
  • Loading branch information
garydan42 committed Jul 24, 2024
1 parent 7608cc7 commit e72f317
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
36 changes: 19 additions & 17 deletions src/api/Client/WinMM/winmmdrv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ struct MIDICLIENT
LPMIDIHDR buffers[16] {0};
};

struct MIDICLIENT g_InClients[32];
struct MIDICLIENT g_OutClients[32];
#define MAX_CLIENTS 32

struct MIDICLIENT g_InClients[MAX_CLIENTS];
struct MIDICLIENT g_OutClients[MAX_CLIENTS];

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

if (freeIndex < 32 &&
if (freeIndex < MAX_CLIENTS &&
dwParam1 >= sizeof(MIDIOPENDESC))
{
g_InClients[freeIndex].used = TRUE;
Expand All @@ -118,7 +120,7 @@ DWORD APIENTRY midMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
{
mmResult = MMSYSERR_ERROR;

for (UINT index = 0; index < 32; index++)
for (UINT index = 0; index < MAX_CLIENTS; index++)
{
if (g_InClients[index].used && g_InClients[index].user == dwUser)
{
Expand All @@ -141,7 +143,7 @@ DWORD APIENTRY midMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
if (nullptr != header &&
dwParam2 >= sizeof(MIDIHDR))
{
for (UINT index = 0; index < 32; index++)
for (UINT index = 0; index < MAX_CLIENTS; index++)
{
if (g_InClients[index].used && g_InClients[index].user == dwUser)
{
Expand Down Expand Up @@ -169,7 +171,7 @@ DWORD APIENTRY midMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
{
mmResult = MMSYSERR_ERROR;

for (UINT index = 0; index < 32; index++)
for (UINT index = 0; index < MAX_CLIENTS; index++)
{
if (g_InClients[index].used && g_InClients[index].user == dwUser)
{
Expand All @@ -185,7 +187,7 @@ DWORD APIENTRY midMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
{
mmResult = MMSYSERR_ERROR;

for (UINT index = 0; index < 32; index++)
for (UINT index = 0; index < MAX_CLIENTS; index++)
{
if (g_InClients[index].used && g_InClients[index].user == dwUser)
{
Expand All @@ -201,7 +203,7 @@ DWORD APIENTRY midMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
{
mmResult = MMSYSERR_ERROR;

for (UINT index = 0; index < 32; index++)
for (UINT index = 0; index < MAX_CLIENTS; index++)
{
if (g_InClients[index].used && g_InClients[index].user == dwUser)
{
Expand Down Expand Up @@ -252,9 +254,9 @@ DWORD APIENTRY modMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
case MODM_OPEN:
{
UINT freeIndex = 0;
for (freeIndex = 0; g_OutClients[freeIndex].used && freeIndex < 32; freeIndex++);
for (freeIndex = 0;freeIndex < MAX_CLIENTS && g_OutClients[freeIndex].used; freeIndex++);

if (freeIndex < 32 &&
if (freeIndex < MAX_CLIENTS &&
dwParam1 >= sizeof(MIDIOPENDESC))
{
g_OutClients[freeIndex].used = TRUE;
Expand All @@ -276,7 +278,7 @@ DWORD APIENTRY modMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
{
mmResult = MMSYSERR_ERROR;

for (UINT index = 0; index < 32; index++)
for (UINT index = 0; index < MAX_CLIENTS; index++)
{
if (g_OutClients[index].used &&
g_OutClients[index].user == dwUser)
Expand All @@ -299,13 +301,13 @@ DWORD APIENTRY modMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
if (nullptr != header &&
dwParam2 >= sizeof(MIDIHDR))
{
for (UINT outIndex = 0; outIndex < 32; outIndex++)
for (UINT outIndex = 0; outIndex < MAX_CLIENTS; outIndex++)
{
if (g_OutClients[outIndex].used && g_OutClients[outIndex].user == dwUser)
{
mmResult = MMSYSERR_NOERROR;

for (UINT inIndex = 0; inIndex < 32; inIndex++)
for (UINT inIndex = 0; inIndex < MAX_CLIENTS; inIndex++)
{
if (g_InClients[inIndex].used &&
g_OutClients[outIndex].device == g_InClients[inIndex].device)
Expand Down Expand Up @@ -334,13 +336,13 @@ DWORD APIENTRY modMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
{
mmResult = MMSYSERR_ERROR;

for (UINT outIndex = 0; outIndex < 32; outIndex++)
for (UINT outIndex = 0; outIndex < MAX_CLIENTS; outIndex++)
{
if (g_OutClients[outIndex].used && g_OutClients[outIndex].user == dwUser)
{
mmResult = MMSYSERR_NOERROR;

for (UINT inIndex = 0; inIndex < 32; inIndex++)
for (UINT inIndex = 0; inIndex < MAX_CLIENTS; inIndex++)
{
if (g_InClients[inIndex].used &&
g_OutClients[outIndex].device == g_InClients[inIndex].device)
Expand All @@ -362,7 +364,7 @@ DWORD APIENTRY modMessage(UINT uDeviceID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR
{
mmResult = MMSYSERR_ERROR;

for (UINT index = 0; index < 32; index++)
for (UINT index = 0; index < MAX_CLIENTS; index++)
{
if (g_OutClients[index].used && g_OutClients[index].user == dwUser)
{
Expand Down
4 changes: 2 additions & 2 deletions src/api/Inc/MidiKSCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ InstantiateMidiPin(

BOOL
IsAutogeneratedPinName(
_In_ const WCHAR* FilterName,
_In_z_ const WCHAR* FilterName,
_In_ ULONG PinId,
_In_ const WCHAR* NameToCheck
_In_z_ const WCHAR* NameToCheck
);

1 change: 0 additions & 1 deletion src/api/Libs/MidiKsCommon/MidiKsCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ InstantiateMidiPin(
return S_OK;
}

_Use_decl_annotations_
BOOL
IsAutogeneratedPinName(
const WCHAR* FilterName,
Expand Down

0 comments on commit e72f317

Please sign in to comment.