From: Thorsten Blum <blum@kernel.org>
To: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Rong Zhang <i@rong.moe>, Arun Raghavan <arunr@valvesoftware.com>,
Thorsten Blum <blum@kernel.org>
Cc: Takashi Iwai <tiwai@suse.de>,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] ALSA: usb-audio: Use strscpy() in append_ctl_name()
Date: Wed, 21 Oct 2026 12:58:26 +0200 [thread overview]
Message-ID: <20261021105826.147060-3-blum@kernel.org> (raw)
To prepare for removing strlcat() from the kernel [1], use strscpy()
instead with the current name length as the append offset. Change
append_ctl_name() to return void since no caller uses its return value.
Use append_ctl_name() to append " Jack" in build_connector_control().
No functional change.
Link: https://github.com/KSPP/linux/issues/370 [1]
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
sound/usb/mixer.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index ecaa8bc08d7c..0320a3e8af92 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -1720,9 +1720,11 @@ const struct snd_kcontrol_new *snd_usb_feature_unit_ctl = &usb_feature_unit_ctl;
/*
* build a feature control
*/
-static size_t append_ctl_name(struct snd_kcontrol *kctl, const char *str)
+static void append_ctl_name(struct snd_kcontrol *kctl, const char *str)
{
- return strlcat(kctl->id.name, str, sizeof(kctl->id.name));
+ size_t len = strlen(kctl->id.name);
+
+ strscpy(kctl->id.name + len, str, sizeof(kctl->id.name) - len);
}
/*
@@ -2090,7 +2092,7 @@ static void build_connector_control(struct usb_mixer_interface *mixer,
}
if (check_mapped_name(map, kctl->id.name, sizeof(kctl->id.name)))
- strlcat(kctl->id.name, " Jack", sizeof(kctl->id.name));
+ append_ctl_name(kctl, " Jack");
else
get_connector_control_name(mixer, term, is_input, kctl->id.name,
sizeof(kctl->id.name));
next reply other threads:[~2026-10-21 10:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 10:58 Thorsten Blum [this message]
2026-10-21 12:59 ` Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261021105826.147060-3-blum@kernel.org \
--to=blum@kernel.org \
--cc=arunr@valvesoftware.com \
--cc=i@rong.moe \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®