From: Thorsten Blum <thorsten.blum@linux.dev>
To: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
Kees Cook <kees@kernel.org>,
"Dr. David Alan Gilbert" <linux@treblig.org>
Cc: Thorsten Blum <thorsten.blum@linux.dev>,
Takashi Iwai <tiwai@suse.de>,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] ALSA: jack: use scnprintf to improve parse_mask_bits
Date: Sun, 3 May 2026 12:11:02 +0200 [thread overview]
Message-ID: <20260503101102.298782-2-thorsten.blum@linux.dev> (raw)
Use the return value of scnprintf() to keep track of the current string
length and also replace strlcat() with scnprintf(). Return the string
length directly instead of calling strlen(buf).
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
sound/core/jack.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/sound/core/jack.c b/sound/core/jack.c
index 5e8a2f3f4196..96e0733ede77 100644
--- a/sound/core/jack.c
+++ b/sound/core/jack.c
@@ -250,18 +250,15 @@ static const char * const jack_events_name[] = {
/* the recommended buffer size is 256 */
static int parse_mask_bits(unsigned int mask_bits, char *buf, size_t buf_size)
{
+ int len = scnprintf(buf, buf_size, "0x%04x", mask_bits);
int i;
- scnprintf(buf, buf_size, "0x%04x", mask_bits);
-
for (i = 0; i < ARRAY_SIZE(jack_events_name); i++)
- if (mask_bits & (1 << i)) {
- strlcat(buf, " ", buf_size);
- strlcat(buf, jack_events_name[i], buf_size);
- }
- strlcat(buf, "\n", buf_size);
+ if (mask_bits & (1 << i))
+ len += scnprintf(buf + len, buf_size - len, " %s", jack_events_name[i]);
+ len += scnprintf(buf + len, buf_size - len, "\n");
- return strlen(buf);
+ return len;
}
static ssize_t jack_kctl_mask_bits_read(struct file *file,
next reply other threads:[~2026-05-03 10:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-03 10:11 Thorsten Blum [this message]
2026-05-04 11:28 ` [PATCH] ALSA: jack: use scnprintf to improve parse_mask_bits 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=20260503101102.298782-2-thorsten.blum@linux.dev \
--to=thorsten.blum@linux.dev \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=linux@treblig.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.