buffer.h: silences warning "flags may be used uninitialized"

buffer_unlock() does not use flags.

Silences this gcc 8.1.0 (and valid) warning in
src/audio/pipeline.c#pipeline_for_each_comp(). For some strange reason
it shows up only with CONFIG_OPTIMIZE_FOR_DEBUG=y. Heuristics?

In file included from sof/src/include/sof/audio/pipeline.h:16,
                 from sof/src/include/sof/audio/buffer.h:12,
                 from sof/src/audio/pipeline.c:8:
src/audio/pipeline.c: In function 'pipeline_for_each_comp':
src/include/sof/spinlock.h:200:38: error: 'flags' may be used uninitialized in this function [-Werror=maybe-uninitialized]
src/audio/pipeline.c:182:11: note: 'flags' was declared here
  uint32_t flags;
           ^~~~~

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
This commit is contained in:
Marc Herbert 2021-03-05 01:40:56 +00:00 committed by Liam Girdwood
parent 1f9c91d174
commit 69985365c6
1 changed files with 7 additions and 1 deletions

View File

@ -197,9 +197,15 @@ static inline void buffer_writeback(struct comp_buffer *buffer, uint32_t bytes)
*/
static inline void buffer_lock(struct comp_buffer *buffer, uint32_t *flags)
{
if (!buffer->inter_core)
if (!buffer->inter_core) {
/* Ignored by buffer_unlock() below, silences "may be
* used uninitialized" warning.
*/
*flags = 0xffffffff;
return;
}
/* Expands to: *flags = ... */
spin_lock_irq(buffer->lock, *flags);
/* invalidate in case something has changed during our wait */