* [PATCH] ASoC: tlv320aic3x - fix variable may be used uninitialized warning
@ 2010-11-24 14:40 Axel Lin
2010-11-24 14:44 ` Mark Brown
2010-11-25 21:47 ` Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Axel Lin @ 2010-11-24 14:40 UTC (permalink / raw)
To: linux-kernel; +Cc: Liam Girdwood, Mark Brown, vbarinov, alsa-devel
If aic3x_read failed , val is used uninitialized.
Fix it by initializing val to 0.
This patch fixes below compile warning:
sound/soc/codecs/tlv320aic3x.c: In function 'aic3x_get_gpio':
sound/soc/codecs/tlv320aic3x.c:1183: warning: 'val' may be used uninitialized in this function
sound/soc/codecs/tlv320aic3x.c: In function 'aic3x_headset_detected':
sound/soc/codecs/tlv320aic3x.c:1211: warning: 'val' may be used uninitialized in this function
sound/soc/codecs/tlv320aic3x.c: In function 'aic3x_button_pressed':
sound/soc/codecs/tlv320aic3x.c:1219: warning: 'val' may be used uninitialized in this function
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
sound/soc/codecs/tlv320aic3x.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index bfd036a..9de7c38 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -1180,7 +1180,7 @@ EXPORT_SYMBOL_GPL(aic3x_set_gpio);
int aic3x_get_gpio(struct snd_soc_codec *codec, int gpio)
{
u8 reg = gpio ? AIC3X_GPIO2_REG : AIC3X_GPIO1_REG;
- u8 val, bit = gpio ? 2: 1;
+ u8 val = 0, bit = gpio ? 2 : 1;
aic3x_read(codec, reg, &val);
return (val >> bit) & 1;
@@ -1208,7 +1208,7 @@ EXPORT_SYMBOL_GPL(aic3x_set_headset_detection);
int aic3x_headset_detected(struct snd_soc_codec *codec)
{
- u8 val;
+ u8 val = 0;
aic3x_read(codec, AIC3X_HEADSET_DETECT_CTRL_B, &val);
return (val >> 4) & 1;
}
@@ -1216,7 +1216,7 @@ EXPORT_SYMBOL_GPL(aic3x_headset_detected);
int aic3x_button_pressed(struct snd_soc_codec *codec)
{
- u8 val;
+ u8 val = 0;
aic3x_read(codec, AIC3X_HEADSET_DETECT_CTRL_B, &val);
return (val >> 5) & 1;
}
--
1.7.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: tlv320aic3x - fix variable may be used uninitialized warning
2010-11-24 14:40 [PATCH] ASoC: tlv320aic3x - fix variable may be used uninitialized warning Axel Lin
@ 2010-11-24 14:44 ` Mark Brown
2010-11-25 21:47 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2010-11-24 14:44 UTC (permalink / raw)
To: Axel Lin; +Cc: linux-kernel, Liam Girdwood, vbarinov, alsa-devel
On Wed, Nov 24, 2010 at 10:40:59PM +0800, Axel Lin wrote:
> If aic3x_read failed , val is used uninitialized.
> Fix it by initializing val to 0.
>
> This patch fixes below compile warning:
> sound/soc/codecs/tlv320aic3x.c: In function 'aic3x_get_gpio':
> sound/soc/codecs/tlv320aic3x.c:1183: warning: 'val' may be used uninitialized in this function
> sound/soc/codecs/tlv320aic3x.c: In function 'aic3x_headset_detected':
> sound/soc/codecs/tlv320aic3x.c:1211: warning: 'val' may be used uninitialized in this function
> sound/soc/codecs/tlv320aic3x.c: In function 'aic3x_button_pressed':
> sound/soc/codecs/tlv320aic3x.c:1219: warning: 'val' may be used uninitialized in this function
This does rather look like a compiler bug. I'm generally against this
sort of change as it just tramples over the warning in cases where it
may be valid, though given the trivially small functions here it's hard
to care.
Really this stuff should all be written to use the standard jack and
GPIO APIs anyway.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: tlv320aic3x - fix variable may be used uninitialized warning
2010-11-24 14:40 [PATCH] ASoC: tlv320aic3x - fix variable may be used uninitialized warning Axel Lin
2010-11-24 14:44 ` Mark Brown
@ 2010-11-25 21:47 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2010-11-25 21:47 UTC (permalink / raw)
To: Axel Lin; +Cc: linux-kernel, Liam Girdwood, vbarinov, alsa-devel
On Wed, Nov 24, 2010 at 10:40:59PM +0800, Axel Lin wrote:
> If aic3x_read failed , val is used uninitialized.
> Fix it by initializing val to 0.
I applied this one too after Liam's ack (via IM), thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-11-25 21:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-24 14:40 [PATCH] ASoC: tlv320aic3x - fix variable may be used uninitialized warning Axel Lin
2010-11-24 14:44 ` Mark Brown
2010-11-25 21:47 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox