Skip to content

Commit 4aa69d6

Browse files
committed
ALSA: ump: Fix -Wformat-truncation warnings
Filling the rawmidi name and substream name can be truncated, and this leads to spurious compiler warnings due to -Wformat-truncation. Although the truncation is the expected behavior, it'd be better to truncate the string within "(...)" This patch puts the precision specifies to each %s for fitting the words within the size-limited strings. Fixes: 5f11dd9 ("ALSA: usb-audio: Attach legacy rawmidi after probing all UMP EPs") Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202308251844.1FuQYsql-lkp@intel.com/ Link: https://lore.kernel.org/r/20230826072151.23408-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 61698d3 commit 4aa69d6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sound/core/ump.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,7 @@ static void fill_substream_names(struct snd_ump_endpoint *ump,
11571157
struct snd_rawmidi_substream *s;
11581158

11591159
list_for_each_entry(s, &rmidi->streams[dir].substreams, list)
1160-
snprintf(s->name, sizeof(s->name), "Group %d (%s)",
1160+
snprintf(s->name, sizeof(s->name), "Group %d (%.16s)",
11611161
ump->legacy_mapping[s->number] + 1, ump->info.name);
11621162
}
11631163

@@ -1191,7 +1191,7 @@ int snd_ump_attach_legacy_rawmidi(struct snd_ump_endpoint *ump,
11911191
if (output)
11921192
snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT,
11931193
&snd_ump_legacy_output_ops);
1194-
snprintf(rmidi->name, sizeof(rmidi->name), "%s (MIDI 1.0)",
1194+
snprintf(rmidi->name, sizeof(rmidi->name), "%.68s (MIDI 1.0)",
11951195
ump->info.name);
11961196
rmidi->info_flags = ump->core.info_flags & ~SNDRV_RAWMIDI_INFO_UMP;
11971197
rmidi->ops = &snd_ump_legacy_ops;

0 commit comments

Comments
 (0)