Re: [PATCH] ALSA: Warn when control names are truncated

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 29 Oct 2008, Takashi Iwai wrote:

> At Wed, 29 Oct 2008 15:51:40 +0100 (CET),
> Jaroslav Kysela wrote:
> > 
> > On Wed, 29 Oct 2008, Takashi Iwai wrote:
> > 
> > > At Wed, 29 Oct 2008 14:40:30 +0000,
> > > Mark Brown wrote:
> > > > 
> > > > 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@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
> > > 
> > > Thanks, applied now.
> > > 
> > > 
> > > > +		if (strcmp(ncontrol->name, kctl.id.name) != 0)
> > 
> > Maybe better is to just use end char comparsion to save few CPU ticks:
> > 
> > if (kctl.id.name[sizeof(kctl.id.name)-2] != '\0' &&
> >     ncontrol->name[sizeof(kctl.id.name)-1] != '\0')
> 
> No, this may cause segfault

How? The first check in the fixed size variable initialized with zeros 
allocated on heap ensures that ncontrol->name string is at least 
sizeof(kctl.id.name) long. There is no possibility of segfault.

> (and way too hacky to understand what's the purpose of the code...)

The printk explains check nicely.

					Jaroslav

-----
Jaroslav Kysela <perex@xxxxxxxx>
Linux Kernel Sound Maintainer
ALSA Project, Red Hat, Inc.

_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux