* [PATCH] ALSA: jack: use scnprintf to improve parse_mask_bits
@ 2026-05-03 10:11 Thorsten Blum
2026-05-04 11:28 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2026-05-03 10:11 UTC (permalink / raw)
To: Jaroslav Kysela, Takashi Iwai, Kees Cook, Dr. David Alan Gilbert
Cc: Thorsten Blum, Takashi Iwai, linux-sound, linux-kernel
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,
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] ALSA: jack: use scnprintf to improve parse_mask_bits
2026-05-03 10:11 [PATCH] ALSA: jack: use scnprintf to improve parse_mask_bits Thorsten Blum
@ 2026-05-04 11:28 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-05-04 11:28 UTC (permalink / raw)
To: Thorsten Blum
Cc: Jaroslav Kysela, Takashi Iwai, Kees Cook, Dr. David Alan Gilbert,
Takashi Iwai, linux-sound, linux-kernel
On Sun, 03 May 2026 12:11:02 +0200,
Thorsten Blum wrote:
>
> 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>
Thanks, applied now.
Takashi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-04 11:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-03 10:11 [PATCH] ALSA: jack: use scnprintf to improve parse_mask_bits Thorsten Blum
2026-05-04 11:28 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox