Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Guedes, Andre" <andre.guedes@intel.com>
To: "o-takashi@sakamocchi.jp" <o-takashi@sakamocchi.jp>,
	"tiwai@suse.de" <tiwai@suse.de>
Cc: "alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
	"Girdwood, Liam R" <liam.r.girdwood@intel.com>
Subject: Re: [PATCH - AAF PCM plugin 3/7] aaf: Implement Playback mode support
Date: Thu, 11 Oct 2018 19:53:46 +0000	[thread overview]
Message-ID: <1539287618.3419.31.camel@intel.com> (raw)
In-Reply-To: <s5hr2gwdib8.wl-tiwai@suse.de>


[-- Attachment #1.1: Type: text/plain, Size: 2425 bytes --]

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

[-- Attachment #1.2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 3262 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



  reply	other threads:[~2018-10-11 19:57 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-03 23:45 [PATCH - AAF PCM plugin 0/7] Introduce AVTP Audio Format (AAF) plugin Andre Guedes
2018-10-03 23:45 ` [PATCH - AAF PCM plugin 1/7] aaf: Introduce plugin skeleton Andre Guedes
2018-10-10 10:27   ` Takashi Iwai
2018-10-10 21:22     ` Guedes, Andre
2018-10-03 23:45 ` [PATCH - AAF PCM plugin 2/7] aaf: Load configuration parameters Andre Guedes
2018-10-10 10:29   ` Takashi Iwai
2018-10-03 23:45 ` [PATCH - AAF PCM plugin 3/7] aaf: Implement Playback mode support Andre Guedes
2018-10-10 10:34   ` Takashi Iwai
2018-10-10 21:27     ` Guedes, Andre
2018-10-11  7:31       ` Takashi Iwai
2018-10-11  7:45         ` Takashi Sakamoto
2018-10-11  8:00           ` Takashi Iwai
2018-10-11 19:53             ` Guedes, Andre [this message]
2018-10-03 23:45 ` [PATCH - AAF PCM plugin 4/7] aaf: Prepare for Capture " Andre Guedes
2018-10-03 23:45 ` [PATCH - AAF PCM plugin 5/7] aaf: Implement " Andre Guedes
2018-10-03 23:45 ` [PATCH - AAF PCM plugin 6/7] aaf: Implement dump() ioplug callback Andre Guedes
2018-10-03 23:45 ` [PATCH - AAF PCM plugin 7/7] aaf: Add support for direct read/write transfers Andre Guedes
2018-10-10 10:25 ` [PATCH - AAF PCM plugin 0/7] Introduce AVTP Audio Format (AAF) plugin Takashi Iwai
2018-10-10 21:19   ` Guedes, Andre
2018-10-22 16:51     ` Pierre-Louis Bossart
2018-10-23 20:01       ` Guedes, Andre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1539287618.3419.31.camel@intel.com \
    --to=andre.guedes@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=liam.r.girdwood@intel.com \
    --cc=o-takashi@sakamocchi.jp \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox