* [PATCH v3] ALSA: mips: avoid potential uninitialized variable use
@ 2017-01-16 13:27 Arnd Bergmann
2017-01-16 13:34 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2017-01-16 13:27 UTC (permalink / raw)
To: Jaroslav Kysela, Takashi Iwai
Cc: linux-mips, Arnd Bergmann, alsa-devel, linux-kernel
MIPS allmodconfig results in this warning:
sound/mips/hal2.c: In function 'hal2_gain_get':
sound/mips/hal2.c:224:35: error: 'r' may be used uninitialized in this function [-Werror=maybe-uninitialized]
sound/mips/hal2.c:223:35: error: 'l' may be used uninitialized in this function [-Werror=maybe-uninitialized]
sound/mips/hal2.c: In function 'hal2_gain_put':
sound/mips/hal2.c:260:13: error: 'new' may be used uninitialized in this function [-Werror=maybe-uninitialized]
sound/mips/hal2.c:260:13: error: 'old' may be used uninitialized in this function [-Werror=maybe-uninitialized]
Returning an error for all unexpected cases shuts up the warning
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
v3: actually send the correct patch, sorry for the mixup
v2: return an error instead trying to handle gracefully
sound/mips/hal2.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/sound/mips/hal2.c b/sound/mips/hal2.c
index ede449f0b50d..00fc9241d266 100644
--- a/sound/mips/hal2.c
+++ b/sound/mips/hal2.c
@@ -219,6 +219,8 @@ static int hal2_gain_get(struct snd_kcontrol *kcontrol,
l = (tmp >> H2I_C2_L_GAIN_SHIFT) & 15;
r = (tmp >> H2I_C2_R_GAIN_SHIFT) & 15;
break;
+ default:
+ return -EINVAL;
}
ucontrol->value.integer.value[0] = l;
ucontrol->value.integer.value[1] = r;
@@ -256,6 +258,8 @@ static int hal2_gain_put(struct snd_kcontrol *kcontrol,
new |= (r << H2I_C2_R_GAIN_SHIFT);
hal2_i_write32(hal2, H2I_ADC_C2, new);
break;
+ default:
+ return -EINVAL;
}
return old != new;
}
--
2.9.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v3] ALSA: mips: avoid potential uninitialized variable use
2017-01-16 13:27 [PATCH v3] ALSA: mips: avoid potential uninitialized variable use Arnd Bergmann
@ 2017-01-16 13:34 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2017-01-16 13:34 UTC (permalink / raw)
To: Arnd Bergmann; +Cc: Jaroslav Kysela, alsa-devel, linux-mips, linux-kernel
On Mon, 16 Jan 2017 14:27:57 +0100,
Arnd Bergmann wrote:
>
> MIPS allmodconfig results in this warning:
>
> sound/mips/hal2.c: In function 'hal2_gain_get':
> sound/mips/hal2.c:224:35: error: 'r' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> sound/mips/hal2.c:223:35: error: 'l' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> sound/mips/hal2.c: In function 'hal2_gain_put':
> sound/mips/hal2.c:260:13: error: 'new' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> sound/mips/hal2.c:260:13: error: 'old' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>
> Returning an error for all unexpected cases shuts up the warning
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> v3: actually send the correct patch, sorry for the mixup
> v2: return an error instead trying to handle gracefully
Thanks, applied now.
Takashi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-01-16 13:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-16 13:27 [PATCH v3] ALSA: mips: avoid potential uninitialized variable use Arnd Bergmann
2017-01-16 13:34 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®