Skip to content

Commit

Permalink
alternative fix: remove the unneeded assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrolcl committed Dec 11, 2024
1 parent 9f8508e commit a21ef89
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions src/drivers/fluid_winmidi.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,26 +484,22 @@ static void fluid_winmidi_autoconnect_build_name(char *name)
int j;
unsigned int i, n = 0;
unsigned int num = midiInGetNumDevs();
if (num > 0)

for (i = 0; i < num; ++i)
{
for (i = 0; i < num; ++i)
char x[4];
j = FLUID_SNPRINTF(x, sizeof(x), "%d;", i);
n += j;
if (n >= sizeof(new_name))
{
char x[4];
j = FLUID_SNPRINTF(x, sizeof(x), "%d;", i);
n += j;
if (n >= sizeof(new_name))
{
FLUID_LOG(FLUID_DBG, "winmidi: autoconnect dev name exceeds MAXPNAMELEN (%d), num (%d), n (%d)", MAXPNAMELEN, num, n);
return;
}
strncat(new_name, x, j);
FLUID_LOG(FLUID_DBG, "winmidi: autoconnect dev name exceeds MAXPNAMELEN (%d), num (%d), n (%d)", MAXPNAMELEN, num, n);
return;
}

name[n - 1] = 0;

FLUID_MEMSET(name, 0, MAXPNAMELEN);
FLUID_STRCPY(name, new_name);
strncat(new_name, x, j);
}

FLUID_MEMSET(name, 0, MAXPNAMELEN);
FLUID_STRCPY(name, new_name);
}

/*
Expand Down

0 comments on commit a21ef89

Please sign in to comment.