summaryrefslogtreecommitdiffstats
path: root/sound/usb
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2021-01-15 11:04:37 +0100
committerTakashi Iwai <tiwai@suse.de>2021-01-15 11:05:26 +0100
commit42ef170d57d8fc59b36619b00cadacac84ecfb90 (patch)
tree6b9996e859506b1a52d8859e4921dee09ad265ce /sound/usb
parente8afdfdc8125801b1e28b5a54d2bd94cf2d59965 (diff)
downloadlinux-42ef170d57d8fc59b36619b00cadacac84ecfb90.tar.bz2
ALSA: usb-audio: Convert the last strlcpy() usage
The last remaining usage of strlcpy() in USB-audio driver is the setup of the card longname string. Basically we need to know whether any non-empty string is set or not, and no real length is needed. Refactor the code and use strscpy() instead. After this change, strlcpy() is gone from all sound/* code. Link: https://lore.kernel.org/r/20210115100437.20906-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb')
-rw-r--r--sound/usb/card.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/sound/usb/card.c b/sound/usb/card.c
index 85e79b9ecb08..45407cb81b66 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -514,18 +514,17 @@ static void usb_audio_make_longname(struct usb_device *dev,
s = preset->vendor_name;
else if (quirk && quirk->vendor_name)
s = quirk->vendor_name;
+ *card->longname = 0;
if (s && *s) {
- len = strlcpy(card->longname, s, sizeof(card->longname));
+ strscpy(card->longname, s, sizeof(card->longname));
} else {
/* retrieve the vendor and device strings as longname */
if (dev->descriptor.iManufacturer)
- len = usb_string(dev, dev->descriptor.iManufacturer,
- card->longname, sizeof(card->longname));
- else
- len = 0;
+ usb_string(dev, dev->descriptor.iManufacturer,
+ card->longname, sizeof(card->longname));
/* we don't really care if there isn't any vendor string */
}
- if (len > 0) {
+ if (*card->longname) {
strim(card->longname);
if (*card->longname)
strlcat(card->longname, " ", sizeof(card->longname));