Skip to content

Commit

Permalink
ALSA: Warn when control names are truncated
Browse files Browse the repository at this point in the history
This is likely to confuse user interfaces since the end of the control
name is interpreted (eg, "Volume", "Switch").

Signed-off-by: Mark Brown <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
broonie authored and tiwai committed Oct 29, 2008
1 parent 78fad34 commit 366840d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sound/core/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,13 @@ struct snd_kcontrol *snd_ctl_new1(const struct snd_kcontrol_new *ncontrol,
kctl.id.iface = ncontrol->iface;
kctl.id.device = ncontrol->device;
kctl.id.subdevice = ncontrol->subdevice;
if (ncontrol->name)
if (ncontrol->name) {
strlcpy(kctl.id.name, ncontrol->name, sizeof(kctl.id.name));
if (strcmp(ncontrol->name, kctl.id.name) != 0)
snd_printk(KERN_WARNING
"Control name '%s' truncated to '%s'\n",
ncontrol->name, kctl.id.name);
}
kctl.id.index = ncontrol->index;
kctl.count = ncontrol->count ? ncontrol->count : 1;
access = ncontrol->access == 0 ? SNDRV_CTL_ELEM_ACCESS_READWRITE :
Expand Down

0 comments on commit 366840d

Please sign in to comment.