[alsa-devel] [PATCH alsa-lib] pcm: hw: fix to initialize function local variable

Takashi Sakamoto o-takashi at sakamocchi.jp
Fri Jun 30 12:50:00 CEST 2017


This commit is to fix below warning.

pcm_hw.c: In function ‘snd1_pcm_hw_open_fd’:
pcm_hw.c:955:33: warning: ‘mmap_control’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  if (mmap_control == MAP_FAILED || mmap_control == NULL) {
                                 ^
pcm_hw.c:946:31: note: ‘mmap_control’ was declared here
  struct snd_pcm_mmap_control *mmap_control;
                               ^~~~~~~~~~~~

Signed-off-by: Takashi Sakamoto <o-takashi at sakamocchi.jp>
---
 src/pcm/pcm_hw.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c
index 64188b22..e0931577 100644
--- a/src/pcm/pcm_hw.c
+++ b/src/pcm/pcm_hw.c
@@ -904,6 +904,7 @@ static bool map_control_data(snd_pcm_hw_t *hw,
 	struct snd_pcm_mmap_control *mmap_control;
 	bool fallbacked;
 
+	mmap_control = MAP_FAILED;
 	if (!force_fallback) {
 		mmap_control = mmap(NULL, page_align(sizeof(*mmap_control)),
 				    PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED,
-- 
2.11.0



More information about the Alsa-devel mailing list