]> git.alsa-project.org Git - alsa-lib.git/commit
topology: builder: Fix possibly uninitialized variable in write_elem_block()
authorTakashi Iwai <tiwai@suse.de>
Tue, 8 Sep 2015 20:04:48 +0000 (22:04 +0200)
committerTakashi Iwai <tiwai@suse.de>
Tue, 8 Sep 2015 20:08:22 +0000 (22:08 +0200)
commit76b9cae026bf73a00ccf3ec8833ec56f0e64f451
tree1aecfe7d7fb3f213c4117c129fe14170f8fffaf4
parent03d6b15291e3534afb72c5aa36495a932ef0cc6a
topology: builder: Fix possibly uninitialized variable in write_elem_block()

When an empty list is passed to write_elem_block(), it may leave
vendor_type uninitialized.
  builder.c: In function ‘write_elem_block’:
  builder.c:127:8: warning: ‘vendor_type’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    ret = write_block_header(tplg, tplg_type, vendor_type,
          ^
  builder.c:114:33: note: ‘vendor_type’ was declared here
    int ret, wsize = 0, count = 0, vendor_type;
                                   ^

Add an immediate return for count = 0 for avoiding it, and simplify
the code initializing vendor_type without using a one-shot loop.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
src/topology/builder.c