mirror of
https://github.com/Dasharo/linux.git
synced 2026-03-06 15:25:10 -08:00
ALSA: Convert strlcpy to strscpy when return value is unused
strlcpy is deprecated. see: Documentation/process/deprecated.rst Change the calls that do not use the strlcpy return value to the preferred strscpy. Done with cocci script: @@ expression e1, e2, e3; @@ - strlcpy( + strscpy( e1, e2, e3); This cocci script leaves the instances where the return value is used unchanged. After this patch, sound/ has 3 uses of strlcpy() that need to be manually inspected for conversion and changed one day. $ git grep -w strlcpy sound/ sound/usb/card.c: len = strlcpy(card->longname, s, sizeof(card->longname)); sound/usb/mixer.c: return strlcpy(buf, p->name, buflen); sound/usb/mixer.c: return strlcpy(buf, p->names[index], buflen); Miscellenea: o Remove trailing whitespace in conversion of sound/core/hwdep.c Link: https://lore.kernel.org/lkml/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/ Signed-off-by: Joe Perches <joe@perches.com> Acked-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/22b393d1790bb268769d0bab7bacf0866dcb0c14.camel@perches.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
committed by
Takashi Iwai
parent
6dcb8bf9a1
commit
75b1a8f9d6
@@ -1013,7 +1013,7 @@ static int onyx_i2c_probe(struct i2c_client *client,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
strlcpy(onyx->codec.name, "onyx", MAX_CODEC_NAME_LEN);
|
||||
strscpy(onyx->codec.name, "onyx", MAX_CODEC_NAME_LEN);
|
||||
onyx->codec.owner = THIS_MODULE;
|
||||
onyx->codec.init = onyx_init_codec;
|
||||
onyx->codec.exit = onyx_exit_codec;
|
||||
|
||||
@@ -894,7 +894,7 @@ static int tas_i2c_probe(struct i2c_client *client,
|
||||
/* seems that half is a saner default */
|
||||
tas->drc_range = TAS3004_DRC_MAX / 2;
|
||||
|
||||
strlcpy(tas->codec.name, "tas", MAX_CODEC_NAME_LEN);
|
||||
strscpy(tas->codec.name, "tas", MAX_CODEC_NAME_LEN);
|
||||
tas->codec.owner = THIS_MODULE;
|
||||
tas->codec.init = tas_init_codec;
|
||||
tas->codec.exit = tas_exit_codec;
|
||||
|
||||
@@ -126,7 +126,7 @@ static int __init toonie_init(void)
|
||||
if (!toonie)
|
||||
return -ENOMEM;
|
||||
|
||||
strlcpy(toonie->codec.name, "toonie", sizeof(toonie->codec.name));
|
||||
strscpy(toonie->codec.name, "toonie", sizeof(toonie->codec.name));
|
||||
toonie->codec.owner = THIS_MODULE;
|
||||
toonie->codec.init = toonie_init_codec;
|
||||
toonie->codec.exit = toonie_exit_codec;
|
||||
|
||||
@@ -28,10 +28,10 @@ int aoa_alsa_init(char *name, struct module *mod, struct device *dev)
|
||||
return err;
|
||||
aoa_card = alsa_card->private_data;
|
||||
aoa_card->alsa_card = alsa_card;
|
||||
strlcpy(alsa_card->driver, "AppleOnbdAudio", sizeof(alsa_card->driver));
|
||||
strlcpy(alsa_card->shortname, name, sizeof(alsa_card->shortname));
|
||||
strlcpy(alsa_card->longname, name, sizeof(alsa_card->longname));
|
||||
strlcpy(alsa_card->mixername, name, sizeof(alsa_card->mixername));
|
||||
strscpy(alsa_card->driver, "AppleOnbdAudio", sizeof(alsa_card->driver));
|
||||
strscpy(alsa_card->shortname, name, sizeof(alsa_card->shortname));
|
||||
strscpy(alsa_card->longname, name, sizeof(alsa_card->longname));
|
||||
strscpy(alsa_card->mixername, name, sizeof(alsa_card->mixername));
|
||||
err = snd_card_register(aoa_card->alsa_card);
|
||||
if (err < 0) {
|
||||
printk(KERN_ERR "snd-aoa: couldn't register alsa card\n");
|
||||
|
||||
@@ -948,7 +948,7 @@ static void layout_attached_codec(struct aoa_codec *codec)
|
||||
ldev->gpio.methods->set_lineout(codec->gpio, 1);
|
||||
ctl = snd_ctl_new1(&lineout_ctl, codec->gpio);
|
||||
if (cc->connected & CC_LINEOUT_LABELLED_HEADPHONE)
|
||||
strlcpy(ctl->id.name,
|
||||
strscpy(ctl->id.name,
|
||||
"Headphone Switch", sizeof(ctl->id.name));
|
||||
ldev->lineout_ctrl = ctl;
|
||||
aoa_snd_ctl_add(ctl);
|
||||
@@ -962,14 +962,14 @@ static void layout_attached_codec(struct aoa_codec *codec)
|
||||
ctl = snd_ctl_new1(&lineout_detect_choice,
|
||||
ldev);
|
||||
if (cc->connected & CC_LINEOUT_LABELLED_HEADPHONE)
|
||||
strlcpy(ctl->id.name,
|
||||
strscpy(ctl->id.name,
|
||||
"Headphone Detect Autoswitch",
|
||||
sizeof(ctl->id.name));
|
||||
aoa_snd_ctl_add(ctl);
|
||||
ctl = snd_ctl_new1(&lineout_detected,
|
||||
ldev);
|
||||
if (cc->connected & CC_LINEOUT_LABELLED_HEADPHONE)
|
||||
strlcpy(ctl->id.name,
|
||||
strscpy(ctl->id.name,
|
||||
"Headphone Detected",
|
||||
sizeof(ctl->id.name));
|
||||
ldev->lineout_detected_ctrl = ctl;
|
||||
|
||||
@@ -13,7 +13,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
|
||||
int length;
|
||||
|
||||
if (*sdev->modalias) {
|
||||
strlcpy(buf, sdev->modalias, sizeof(sdev->modalias) + 1);
|
||||
strscpy(buf, sdev->modalias, sizeof(sdev->modalias) + 1);
|
||||
strcat(buf, "\n");
|
||||
length = strlen(buf);
|
||||
} else {
|
||||
|
||||
@@ -890,8 +890,8 @@ static struct aaci *aaci_init_card(struct amba_device *dev)
|
||||
|
||||
card->private_free = aaci_free_card;
|
||||
|
||||
strlcpy(card->driver, DRIVER_NAME, sizeof(card->driver));
|
||||
strlcpy(card->shortname, "ARM AC'97 Interface", sizeof(card->shortname));
|
||||
strscpy(card->driver, DRIVER_NAME, sizeof(card->driver));
|
||||
strscpy(card->shortname, "ARM AC'97 Interface", sizeof(card->shortname));
|
||||
snprintf(card->longname, sizeof(card->longname),
|
||||
"%s PL%03x rev%u at 0x%08llx, irq %d",
|
||||
card->shortname, amba_part(dev), amba_rev(dev),
|
||||
@@ -921,7 +921,7 @@ static int aaci_init_pcm(struct aaci *aaci)
|
||||
pcm->private_data = aaci;
|
||||
pcm->info_flags = 0;
|
||||
|
||||
strlcpy(pcm->name, DRIVER_NAME, sizeof(pcm->name));
|
||||
strscpy(pcm->name, DRIVER_NAME, sizeof(pcm->name));
|
||||
|
||||
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &aaci_playback_ops);
|
||||
snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &aaci_capture_ops);
|
||||
|
||||
@@ -235,7 +235,7 @@ static int pxa2xx_ac97_probe(struct platform_device *dev)
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
strlcpy(card->driver, dev->dev.driver->name, sizeof(card->driver));
|
||||
strscpy(card->driver, dev->dev.driver->name, sizeof(card->driver));
|
||||
|
||||
ret = pxa2xx_ac97_pcm_new(card);
|
||||
if (ret)
|
||||
|
||||
@@ -1132,7 +1132,7 @@ static void snd_compress_proc_done(struct snd_compr *compr)
|
||||
|
||||
static inline void snd_compress_set_id(struct snd_compr *compr, const char *id)
|
||||
{
|
||||
strlcpy(compr->id, id, sizeof(compr->id));
|
||||
strscpy(compr->id, id, sizeof(compr->id));
|
||||
}
|
||||
#else
|
||||
static inline int snd_compress_proc_init(struct snd_compr *compr)
|
||||
|
||||
@@ -261,7 +261,7 @@ struct snd_kcontrol *snd_ctl_new1(const struct snd_kcontrol_new *ncontrol,
|
||||
kctl->id.device = ncontrol->device;
|
||||
kctl->id.subdevice = ncontrol->subdevice;
|
||||
if (ncontrol->name) {
|
||||
strlcpy(kctl->id.name, ncontrol->name, sizeof(kctl->id.name));
|
||||
strscpy(kctl->id.name, ncontrol->name, sizeof(kctl->id.name));
|
||||
if (strcmp(ncontrol->name, kctl->id.name) != 0)
|
||||
pr_warn("ALSA: Control name '%s' truncated to '%s'\n",
|
||||
ncontrol->name, kctl->id.name);
|
||||
@@ -701,12 +701,12 @@ static int snd_ctl_card_info(struct snd_card *card, struct snd_ctl_file * ctl,
|
||||
return -ENOMEM;
|
||||
down_read(&snd_ioctl_rwsem);
|
||||
info->card = card->number;
|
||||
strlcpy(info->id, card->id, sizeof(info->id));
|
||||
strlcpy(info->driver, card->driver, sizeof(info->driver));
|
||||
strlcpy(info->name, card->shortname, sizeof(info->name));
|
||||
strlcpy(info->longname, card->longname, sizeof(info->longname));
|
||||
strlcpy(info->mixername, card->mixername, sizeof(info->mixername));
|
||||
strlcpy(info->components, card->components, sizeof(info->components));
|
||||
strscpy(info->id, card->id, sizeof(info->id));
|
||||
strscpy(info->driver, card->driver, sizeof(info->driver));
|
||||
strscpy(info->name, card->shortname, sizeof(info->name));
|
||||
strscpy(info->longname, card->longname, sizeof(info->longname));
|
||||
strscpy(info->mixername, card->mixername, sizeof(info->mixername));
|
||||
strscpy(info->components, card->components, sizeof(info->components));
|
||||
up_read(&snd_ioctl_rwsem);
|
||||
if (copy_to_user(arg, info, sizeof(struct snd_ctl_card_info))) {
|
||||
kfree(info);
|
||||
@@ -2137,7 +2137,7 @@ int snd_ctl_enum_info(struct snd_ctl_elem_info *info, unsigned int channels,
|
||||
WARN(strlen(names[info->value.enumerated.item]) >= sizeof(info->value.enumerated.name),
|
||||
"ALSA: too long item name '%s'\n",
|
||||
names[info->value.enumerated.item]);
|
||||
strlcpy(info->value.enumerated.name,
|
||||
strscpy(info->value.enumerated.name,
|
||||
names[info->value.enumerated.item],
|
||||
sizeof(info->value.enumerated.name));
|
||||
return 0;
|
||||
|
||||
@@ -35,7 +35,7 @@ static int get_available_index(struct snd_card *card, const char *name)
|
||||
|
||||
sid.index = 0;
|
||||
sid.iface = SNDRV_CTL_ELEM_IFACE_CARD;
|
||||
strlcpy(sid.name, name, sizeof(sid.name));
|
||||
strscpy(sid.name, name, sizeof(sid.name));
|
||||
|
||||
while (snd_ctl_find_id(card, &sid)) {
|
||||
sid.index++;
|
||||
|
||||
@@ -177,8 +177,8 @@ static int snd_hwdep_info(struct snd_hwdep *hw,
|
||||
|
||||
memset(&info, 0, sizeof(info));
|
||||
info.card = hw->card->number;
|
||||
strlcpy(info.id, hw->id, sizeof(info.id));
|
||||
strlcpy(info.name, hw->name, sizeof(info.name));
|
||||
strscpy(info.id, hw->id, sizeof(info.id));
|
||||
strscpy(info.name, hw->name, sizeof(info.name));
|
||||
info.iface = hw->iface;
|
||||
if (copy_to_user(_info, &info, sizeof(info)))
|
||||
return -EFAULT;
|
||||
@@ -379,7 +379,7 @@ int snd_hwdep_new(struct snd_card *card, char *id, int device,
|
||||
hwdep->card = card;
|
||||
hwdep->device = device;
|
||||
if (id)
|
||||
strlcpy(hwdep->id, id, sizeof(hwdep->id));
|
||||
strscpy(hwdep->id, id, sizeof(hwdep->id));
|
||||
|
||||
snd_device_initialize(&hwdep->dev, card);
|
||||
hwdep->dev.release = release_hwdep_device;
|
||||
|
||||
@@ -174,7 +174,7 @@ int snd_card_new(struct device *parent, int idx, const char *xid,
|
||||
if (extra_size > 0)
|
||||
card->private_data = (char *)card + sizeof(struct snd_card);
|
||||
if (xid)
|
||||
strlcpy(card->id, xid, sizeof(card->id));
|
||||
strscpy(card->id, xid, sizeof(card->id));
|
||||
err = 0;
|
||||
mutex_lock(&snd_card_mutex);
|
||||
if (idx < 0) /* first check the matching module-name slot */
|
||||
@@ -623,7 +623,7 @@ static void snd_card_set_id_no_lock(struct snd_card *card, const char *src,
|
||||
/* last resort... */
|
||||
dev_err(card->dev, "unable to set card id (%s)\n", id);
|
||||
if (card->proc_root->name)
|
||||
strlcpy(card->id, card->proc_root->name, sizeof(card->id));
|
||||
strscpy(card->id, card->proc_root->name, sizeof(card->id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -87,8 +87,8 @@ static int snd_mixer_oss_info(struct snd_mixer_oss_file *fmixer,
|
||||
struct mixer_info info;
|
||||
|
||||
memset(&info, 0, sizeof(info));
|
||||
strlcpy(info.id, mixer && mixer->id[0] ? mixer->id : card->driver, sizeof(info.id));
|
||||
strlcpy(info.name, mixer && mixer->name[0] ? mixer->name : card->mixername, sizeof(info.name));
|
||||
strscpy(info.id, mixer && mixer->id[0] ? mixer->id : card->driver, sizeof(info.id));
|
||||
strscpy(info.name, mixer && mixer->name[0] ? mixer->name : card->mixername, sizeof(info.name));
|
||||
info.modify_counter = card->mixer_oss_change_count;
|
||||
if (copy_to_user(_info, &info, sizeof(info)))
|
||||
return -EFAULT;
|
||||
@@ -103,8 +103,8 @@ static int snd_mixer_oss_info_obsolete(struct snd_mixer_oss_file *fmixer,
|
||||
_old_mixer_info info;
|
||||
|
||||
memset(&info, 0, sizeof(info));
|
||||
strlcpy(info.id, mixer && mixer->id[0] ? mixer->id : card->driver, sizeof(info.id));
|
||||
strlcpy(info.name, mixer && mixer->name[0] ? mixer->name : card->mixername, sizeof(info.name));
|
||||
strscpy(info.id, mixer && mixer->id[0] ? mixer->id : card->driver, sizeof(info.id));
|
||||
strscpy(info.name, mixer && mixer->name[0] ? mixer->name : card->mixername, sizeof(info.name));
|
||||
if (copy_to_user(_info, &info, sizeof(info)))
|
||||
return -EFAULT;
|
||||
return 0;
|
||||
@@ -499,7 +499,7 @@ static struct snd_kcontrol *snd_mixer_oss_test_id(struct snd_mixer_oss *mixer, c
|
||||
|
||||
memset(&id, 0, sizeof(id));
|
||||
id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
|
||||
strlcpy(id.name, name, sizeof(id.name));
|
||||
strscpy(id.name, name, sizeof(id.name));
|
||||
id.index = index;
|
||||
return snd_ctl_find_id(card, &id);
|
||||
}
|
||||
@@ -1355,7 +1355,7 @@ static int snd_mixer_oss_notify_handler(struct snd_card *card, int cmd)
|
||||
mixer->oss_dev_alloc = 1;
|
||||
mixer->card = card;
|
||||
if (*card->mixername)
|
||||
strlcpy(mixer->name, card->mixername, sizeof(mixer->name));
|
||||
strscpy(mixer->name, card->mixername, sizeof(mixer->name));
|
||||
else
|
||||
snprintf(mixer->name, sizeof(mixer->name),
|
||||
"mixer%i", card->number);
|
||||
|
||||
@@ -729,7 +729,7 @@ static int _snd_pcm_new(struct snd_card *card, const char *id, int device,
|
||||
init_waitqueue_head(&pcm->open_wait);
|
||||
INIT_LIST_HEAD(&pcm->list);
|
||||
if (id)
|
||||
strlcpy(pcm->id, id, sizeof(pcm->id));
|
||||
strscpy(pcm->id, id, sizeof(pcm->id));
|
||||
|
||||
err = snd_pcm_new_stream(pcm, SNDRV_PCM_STREAM_PLAYBACK,
|
||||
playback_count);
|
||||
|
||||
@@ -209,13 +209,13 @@ int snd_pcm_info(struct snd_pcm_substream *substream, struct snd_pcm_info *info)
|
||||
info->device = pcm->device;
|
||||
info->stream = substream->stream;
|
||||
info->subdevice = substream->number;
|
||||
strlcpy(info->id, pcm->id, sizeof(info->id));
|
||||
strlcpy(info->name, pcm->name, sizeof(info->name));
|
||||
strscpy(info->id, pcm->id, sizeof(info->id));
|
||||
strscpy(info->name, pcm->name, sizeof(info->name));
|
||||
info->dev_class = pcm->dev_class;
|
||||
info->dev_subclass = pcm->dev_subclass;
|
||||
info->subdevices_count = pstr->substream_count;
|
||||
info->subdevices_avail = pstr->substream_count - pstr->substream_opened;
|
||||
strlcpy(info->subname, substream->name, sizeof(info->subname));
|
||||
strscpy(info->subname, substream->name, sizeof(info->subname));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1686,7 +1686,7 @@ int snd_rawmidi_new(struct snd_card *card, char *id, int device,
|
||||
INIT_LIST_HEAD(&rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams);
|
||||
|
||||
if (id != NULL)
|
||||
strlcpy(rmidi->id, id, sizeof(rmidi->id));
|
||||
strscpy(rmidi->id, id, sizeof(rmidi->id));
|
||||
|
||||
snd_device_initialize(&rmidi->dev, card);
|
||||
rmidi->dev.release = release_rawmidi_device;
|
||||
|
||||
@@ -173,7 +173,7 @@ snd_seq_oss_midi_check_new_port(struct snd_seq_port_info *pinfo)
|
||||
snd_use_lock_init(&mdev->use_lock);
|
||||
|
||||
/* copy and truncate the name of synth device */
|
||||
strlcpy(mdev->name, pinfo->name, sizeof(mdev->name));
|
||||
strscpy(mdev->name, pinfo->name, sizeof(mdev->name));
|
||||
|
||||
/* create MIDI coder */
|
||||
if (snd_midi_event_new(MAX_MIDI_EVENT_BUF, &mdev->coder) < 0) {
|
||||
@@ -647,7 +647,7 @@ snd_seq_oss_midi_make_info(struct seq_oss_devinfo *dp, int dev, struct midi_info
|
||||
inf->device = dev;
|
||||
inf->dev_type = 0; /* FIXME: ?? */
|
||||
inf->capabilities = 0; /* FIXME: ?? */
|
||||
strlcpy(inf->name, mdev->name, sizeof(inf->name));
|
||||
strscpy(inf->name, mdev->name, sizeof(inf->name));
|
||||
snd_use_lock_free(&mdev->use_lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ snd_seq_oss_synth_probe(struct device *_dev)
|
||||
snd_use_lock_init(&rec->use_lock);
|
||||
|
||||
/* copy and truncate the name of synth device */
|
||||
strlcpy(rec->name, dev->name, sizeof(rec->name));
|
||||
strscpy(rec->name, dev->name, sizeof(rec->name));
|
||||
|
||||
/* registration */
|
||||
spin_lock_irqsave(®ister_lock, flags);
|
||||
@@ -616,7 +616,7 @@ snd_seq_oss_synth_make_info(struct seq_oss_devinfo *dp, int dev, struct synth_in
|
||||
inf->synth_subtype = 0;
|
||||
inf->nr_voices = 16;
|
||||
inf->device = dev;
|
||||
strlcpy(inf->name, minf.name, sizeof(inf->name));
|
||||
strscpy(inf->name, minf.name, sizeof(inf->name));
|
||||
} else {
|
||||
if ((rec = get_synthdev(dp, dev)) == NULL)
|
||||
return -ENXIO;
|
||||
@@ -624,7 +624,7 @@ snd_seq_oss_synth_make_info(struct seq_oss_devinfo *dp, int dev, struct synth_in
|
||||
inf->synth_subtype = rec->synth_subtype;
|
||||
inf->nr_voices = rec->nr_voices;
|
||||
inf->device = dev;
|
||||
strlcpy(inf->name, rec->name, sizeof(inf->name));
|
||||
strscpy(inf->name, rec->name, sizeof(inf->name));
|
||||
snd_use_lock_free(&rec->use_lock);
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -1584,7 +1584,7 @@ static int snd_seq_ioctl_get_queue_info(struct snd_seq_client *client,
|
||||
info->queue = q->queue;
|
||||
info->owner = q->owner;
|
||||
info->locked = q->locked;
|
||||
strlcpy(info->name, q->name, sizeof(info->name));
|
||||
strscpy(info->name, q->name, sizeof(info->name));
|
||||
queuefree(q);
|
||||
|
||||
return 0;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user