From a21ef89ed957e259201633c48c0594f3c83367e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20L=C3=B3pez-Cabanillas?= Date: Wed, 11 Dec 2024 23:26:25 +0100 Subject: [PATCH] alternative fix: remove the unneeded assignment --- src/drivers/fluid_winmidi.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/drivers/fluid_winmidi.c b/src/drivers/fluid_winmidi.c index 4da2c124f..077993346 100644 --- a/src/drivers/fluid_winmidi.c +++ b/src/drivers/fluid_winmidi.c @@ -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); } /*