[alsa-devel] [PATCH - AAF PCM plugin 3/7] aaf: Implement Playback mode support

Guedes, Andre andre.guedes at intel.com
Thu Oct 11 21:53:46 CEST 2018


On Thu, 2018-10-11 at 10:00 +0200, Takashi Iwai wrote:
> On Thu, 11 Oct 2018 09:45:07 +0200,
> Takashi Sakamoto wrote:
> > 
> > On Oct 11 2018 16:31, Takashi Iwai wrote:
> > > On Wed, 10 Oct 2018 23:27:29 +0200,
> > > Guedes, Andre wrote:
> > > > 
> > > > On Wed, 2018-10-10 at 12:34 +0200, Takashi Iwai wrote:
> > > > > > +static int aaf_set_hw_constraint(snd_pcm_aaf_t *aaf)
> > > > > > +{
> > > > > > +     int res;
> > > > > > +     snd_pcm_ioplug_t *io = &aaf->io;
> > > > > > +     const unsigned int accesses[] = {
> > > > > > +             SND_PCM_ACCESS_RW_INTERLEAVED,
> > > > > > +     };
> > > > > > +     const unsigned int formats[] = {
> > > > > > +             SND_PCM_FORMAT_S16_BE,
> > > > > > +             SND_PCM_FORMAT_S24_3BE,
> > > > > > +             SND_PCM_FORMAT_S32_BE,
> > > > > > +             SND_PCM_FORMAT_FLOAT_BE,
> > > > > > +     };
> > > > > > +     const unsigned int rates[] = {
> > > > > > +             8000,
> > > > > > +             16000,
> > > > > > +             24000,
> > > > > > +             32000,
> > > > > > +             44100,
> > > > > > +             48000,
> > > > > > +             88200,
> > > > > > +             96000,
> > > > > > +             176400,
> > > > > > +             192000,
> > > > > > +     };
> > > > > 
> > > > > Use static arrays for the above.
> > > > 
> > > > It isn't clear to me what is the point in allocating these
> > > > variables in
> > > > the global scope. May I ask what is the benefit in adding the
> > > > 'static'
> > > > modifier to these local variables?
> > > 
> > > Yes.
> > 
> > In this case, it's not relevant to access scope.
> > 
> > Just with 'const' qualifier, the symbol allocates in .text section
> > of ELF binary. With additional 'static' qualifier, the symbol
> > allocates in .rodata section.
> > 
> > In loading, symbol in .rodata section locates in segments of VMA
> > with 'read-only' flag. This brings safety from several bugs such as
> > buffer over-run.

My understanding is that the arrays are allocated in the stack frame,
not in .text section, and the 'const' qualifier here has no influence
on that. But I get your point in moving the arrays to .rodata.

> OK, then scratch my comments.

I checked other plugins and it seems having 'static' to these variables
is the "norm" so I'm adding it for the sake of consistency.

Thanks,

Andre
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3262 bytes
Desc: not available
URL: <http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20181011/00e0ad51/attachment.bin>


More information about the Alsa-devel mailing list