Skip to contentSkip to conversation

ALSA: echoaudio: Replace deprecated strcpy() with strscpy()

PATCH Applied Thorsten Blum 3 participants 5 messages Jul 9, 2025 – Jul 10, 2025 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: echoaudio: Replace deprecated strcpy() with strscpy()

strcpy() is deprecated; use strscpy() instead.

No functional changes intended.

---
 sound/pci/echoaudio/echoaudio.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
sound/pci/echoaudio/echoaudio.c +7 -6
index 80d8ce75fdbb..2b33ef588ac3 100644
@@ -6,6 +6,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/string.h>
 
 MODULE_AUTHOR("Giuliano Pochini <[email protected]>");
 MODULE_LICENSE("GPL v2");
@@ -916,7 +917,7 @@ static int snd_echo_new_pcm(struct echoaudio *chip)
 		return err;
 	pcm->private_data = chip;
 	chip->analog_pcm = pcm;
-	strcpy(pcm->name, chip->card->shortname);
+	strscpy(pcm->name, chip->card->shortname);
 	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &analog_playback_ops);
 	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &analog_capture_ops);
 	snd_echo_preallocate_pages(pcm, &chip->pci->dev);
@@ -929,7 +930,7 @@ static int snd_echo_new_pcm(struct echoaudio *chip)
 		return err;
 	pcm->private_data = chip;
 	chip->digital_pcm = pcm;
-	strcpy(pcm->name, chip->card->shortname);
+	strscpy(pcm->name, chip->card->shortname);
 	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &digital_capture_ops);
 	snd_echo_preallocate_pages(pcm, &chip->pci->dev);
 #endif /* ECHOCARD_HAS_DIGITAL_IO */
@@ -949,7 +950,7 @@ static int snd_echo_new_pcm(struct echoaudio *chip)
 		return err;
 	pcm->private_data = chip;
 	chip->analog_pcm = pcm;
-	strcpy(pcm->name, chip->card->shortname);
+	strscpy(pcm->name, chip->card->shortname);
 	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &analog_playback_ops);
 	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &analog_capture_ops);
 	snd_echo_preallocate_pages(pcm, &chip->pci->dev);
@@ -963,7 +964,7 @@ static int snd_echo_new_pcm(struct echoaudio *chip)
 		return err;
 	pcm->private_data = chip;
 	chip->digital_pcm = pcm;
-	strcpy(pcm->name, chip->card->shortname);
+	strscpy(pcm->name, chip->card->shortname);
 	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &digital_playback_ops);
 	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &digital_capture_ops);
 	snd_echo_preallocate_pages(pcm, &chip->pci->dev);
@@ -1985,8 +1986,8 @@ static int __snd_echo_probe(struct pci_dev *pci,
 	if (err < 0)
 		return err;
 
-	strcpy(card->driver, "Echo_" ECHOCARD_NAME);
-	strcpy(card->shortname, chip->card_name);
+	strscpy(card->driver, "Echo_" ECHOCARD_NAME);
+	strscpy(card->shortname, chip->card_name);
 
 	dsp = "56301";
 	if (pci_id->device == 0x3410)
Signature · 1 line
2.50.0
#2 lore raw
Quoted 5 lines · Takashi Iwai

Thanks, applied now.

And now I'm going to convert all the rest of such trivial stuff (strcpy() with card->driver, shortname, mixername, longname, as well as pcm->name, and else) in sound/* for 6.17.

Yes, please :) I thought about submitting a patch series for all of sound/*, but didn't find the time yet.

Thanks,
Thorsten

#3 lore raw
Quoted 9 lines · Thorsten Blum
Quoted 5 lines · Takashi Iwai

Thanks, applied now.

And now I'm going to convert all the rest of such trivial stuff (strcpy() with card->driver, shortname, mixername, longname, as well as pcm->name, and else) in sound/* for 6.17.

Yes, please :) I thought about submitting a patch series for all of sound/*, but didn't find the time yet.

Note that strscpy() supports 3rd argument optionally, it means it's better to use 2-arg variant when the destination is supposed to be an array of characters.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#4 lore raw
Quoted 9 lines · Andy Shevchenko
Quoted 7 lines · Thorsten Blum
Quoted 5 lines · Takashi Iwai

Thanks, applied now.

And now I'm going to convert all the rest of such trivial stuff (strcpy() with card->driver, shortname, mixername, longname, as well as pcm->name, and else) in sound/* for 6.17.

Quoted 6 lines
Quoted 2 lines

Yes, please :) I thought about submitting a patch series for all of sound/*, but didn't find the time yet.

Note that strscpy() supports 3rd argument optionally, it means it's better to use 2-arg variant when the destination is supposed to be an array of characters.

Yes, most of Thomas' patches are using 2 arg variant, just replacing strcpy() with strscpy().

thanks,

Takashi