public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: usb-audio: Use snprintf instead of sprintf in build_mixer_unit_ctl
@ 2024-10-09  7:09 Zhu Jun
  2024-10-10 12:23 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Zhu Jun @ 2024-10-09  7:09 UTC (permalink / raw)
  To: tiwai; +Cc: perex, kl, zhujun2, k.kosik, linux-sound, linux-kernel

Simplified code by removing redundant assignment of sprintf return value
and improved safety by replacing sprintf with snprintf.

Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
---
 sound/usb/mixer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index 9945ae55b0d0..b6c3d2ee416e 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -2224,7 +2224,8 @@ static void build_mixer_unit_ctl(struct mixer_build *state,
 		len = get_term_name(state->chip, iterm, kctl->id.name,
 				    sizeof(kctl->id.name), 0);
 	if (!len)
-		len = sprintf(kctl->id.name, "Mixer Source %d", in_ch + 1);
+		snprintf(kctl->id.name, sizeof(kctl->id.name), "Mixer Source %d", in_ch + 1);
+
 	append_ctl_name(kctl, " Volume");
 
 	usb_audio_dbg(state->chip, "[%d] MU [%s] ch = %d, val = %d/%d\n",
-- 
2.17.1




^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-10-10 12:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-09  7:09 [PATCH] ALSA: usb-audio: Use snprintf instead of sprintf in build_mixer_unit_ctl Zhu Jun
2024-10-10 12:23 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox