All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thorsten Blum <blum@kernel.org>
To: "Jaroslav Kysela" <perex@perex.cz>,
	"Takashi Iwai" <tiwai@suse.com>,
	"Uwe Kleine-König (The Capable Hub)"
	<u.kleine-koenig@baylibre.com>,
	"Zhao Dongdong" <zhaodongdong@kylinos.cn>
Cc: Thorsten Blum <blum@kernel.org>, Takashi Iwai <tiwai@suse.de>,
	linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] ALSA: cmipci: Use strscpy() in snd_cmipci_create()
Date: Thu, 22 Oct 2026 18:40:11 +0200	[thread overview]
Message-ID: <20261022164013.95811-2-blum@kernel.org> (raw)

To prepare for removing strlcat() from the kernel [1], use strscpy()
instead with the current driver name length as the append offset. Also
use size_t in the multi-channel branch to match strlen()'s return type.

No functional change.

Link: https://github.com/KSPP/linux/issues/370 [1]
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
 sound/pci/cmipci.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c
index 9d9f784e3a8c..5722b722da95 100644
--- a/sound/pci/cmipci.c
+++ b/sound/pci/cmipci.c
@@ -2980,11 +2980,15 @@ static int snd_cmipci_create(struct snd_card *card, struct pci_dev *pci,
 		query_chip(cm);
 	/* added -MCx suffix for chip supporting multi-channels */
 	if (cm->can_multi_ch) {
-		int l = strlen(cm->card->driver);
+		size_t l = strlen(cm->card->driver);
+
 		scnprintf(cm->card->driver + l, sizeof(cm->card->driver) - l,
 			  "-MC%d", cm->max_channels);
-	} else if (cm->can_ac3_sw)
-		strlcat(cm->card->driver, "-SWIEC", sizeof(cm->card->driver));
+	} else if (cm->can_ac3_sw) {
+		size_t l = strlen(cm->card->driver);
+
+		strscpy(cm->card->driver + l, "-SWIEC", sizeof(cm->card->driver) - l);
+	}
 
 	cm->dig_status = SNDRV_PCM_DEFAULT_CON_SPDIF;
 	cm->dig_pcm_status = SNDRV_PCM_DEFAULT_CON_SPDIF;

             reply	other threads:[~2026-10-22 16:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-22 16:40 Thorsten Blum [this message]
2026-10-23 13:41 ` [PATCH] ALSA: cmipci: Use strscpy() in snd_cmipci_create() Takashi Iwai
2026-10-23 18:40 ` David Laight
2026-10-23 19:38   ` Takashi Iwai
2026-10-23 21:01     ` David Laight

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=20261022164013.95811-2-blum@kernel.org \
    --to=blum@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    --cc=tiwai@suse.de \
    --cc=u.kleine-koenig@baylibre.com \
    --cc=zhaodongdong@kylinos.cn \
    /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.