Skip to content

Commit 0845b3e

Browse files
Zhu Juntiwai
authored andcommitted
ALSA: usb-audio: Use snprintf instead of sprintf in build_mixer_unit_ctl
Simplified code by removing redundant assignment of sprintf return value and improved safety by replacing sprintf with snprintf. Signed-off-by: Zhu Jun <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 0498a04 commit 0845b3e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

sound/usb/mixer.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2224,7 +2224,8 @@ static void build_mixer_unit_ctl(struct mixer_build *state,
22242224
len = get_term_name(state->chip, iterm, kctl->id.name,
22252225
sizeof(kctl->id.name), 0);
22262226
if (!len)
2227-
len = sprintf(kctl->id.name, "Mixer Source %d", in_ch + 1);
2227+
snprintf(kctl->id.name, sizeof(kctl->id.name), "Mixer Source %d", in_ch + 1);
2228+
22282229
append_ctl_name(kctl, " Volume");
22292230

22302231
usb_audio_dbg(state->chip, "[%d] MU [%s] ch = %d, val = %d/%d\n",

0 commit comments

Comments
 (0)