Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: Warn when control names are truncated
@ 2008-10-29 14:40 Mark Brown
  2008-10-29 14:46 ` Takashi Iwai
  0 siblings, 1 reply; 10+ messages in thread
From: Mark Brown @ 2008-10-29 14:40 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel, Mark Brown

This is likely to confuse user interfaces since the end of the control
name is interpreted (eg, "Volume", "Switch").

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 sound/core/control.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/sound/core/control.c b/sound/core/control.c
index 6d71f9a..b0bf426 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -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 :
-- 
1.5.6.5

^ permalink raw reply related	[flat|nested] 10+ messages in thread
* [PATCH] ALSA: Warn when control names are truncated
@ 2008-10-29 14:14 Mark Brown
  2008-10-29 14:28 ` Takashi Iwai
  0 siblings, 1 reply; 10+ messages in thread
From: Mark Brown @ 2008-10-29 14:14 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel, Mark Brown

This is likely to confuse user interfaces since the end of the control
name is interpreted (eg, "Volume", "Switch").

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 sound/core/control.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/sound/core/control.c b/sound/core/control.c
index 6d71f9a..1257ca8 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -225,8 +225,12 @@ 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) {
+		if (strlen(ncontrol->name) > sizeof(kctl.id.name))
+			snd_printk(KERN_WARNING "Control name '%s' truncated\n",
+				   ncontrol->name);
 		strlcpy(kctl.id.name, ncontrol->name, sizeof(kctl.id.name));
+	}
 	kctl.id.index = ncontrol->index;
 	kctl.count = ncontrol->count ? ncontrol->count : 1;
 	access = ncontrol->access == 0 ? SNDRV_CTL_ELEM_ACCESS_READWRITE :
-- 
1.5.6.5

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2008-10-29 19:00 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-29 14:40 [PATCH] ALSA: Warn when control names are truncated Mark Brown
2008-10-29 14:46 ` Takashi Iwai
2008-10-29 14:51   ` Jaroslav Kysela
2008-10-29 14:55     ` Takashi Iwai
2008-10-29 18:31       ` Jaroslav Kysela
2008-10-29 19:00         ` Takashi Iwai
2008-10-29 14:55     ` Mark Brown
  -- strict thread matches above, loose matches on Subject: below --
2008-10-29 14:14 Mark Brown
2008-10-29 14:28 ` Takashi Iwai
2008-10-29 14:33   ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox