mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] sound: pci: ice1712: wm8766.c:  Cleaning up uninitialized variables
@ 2014-06-01 14:02 Rickard Strandqvist
  2014-06-01 16:23 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Rickard Strandqvist @ 2014-06-01 14:02 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai
  Cc: Rickard Strandqvist, alsa-devel, linux-kernel

There is a risk that the variable will be used without being initialized.

This was largely found by using a static code analysis program called cppcheck.

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
---
 sound/pci/ice1712/wm8766.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/pci/ice1712/wm8766.c b/sound/pci/ice1712/wm8766.c
index 21b373b..788a31c 100644
--- a/sound/pci/ice1712/wm8766.c
+++ b/sound/pci/ice1712/wm8766.c
@@ -237,7 +237,7 @@ static int snd_wm8766_ctl_get(struct snd_kcontrol *kcontrol,
 {
 	struct snd_wm8766 *wm = snd_kcontrol_chip(kcontrol);
 	int n = kcontrol->private_value;
-	u16 val1, val2;
+	u16 val1 = 0, val2 = 0;
 
 	if (wm->ctl[n].get)
 		wm->ctl[n].get(wm, &val1, &val2);
-- 
1.7.10.4


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] sound: pci: ice1712: wm8766.c:  Cleaning up uninitialized variables
  2014-06-01 14:02 [PATCH] sound: pci: ice1712: wm8766.c: Cleaning up uninitialized variables Rickard Strandqvist
@ 2014-06-01 16:23 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2014-06-01 16:23 UTC (permalink / raw)
  To: Rickard Strandqvist; +Cc: Jaroslav Kysela, alsa-devel, linux-kernel

At Sun,  1 Jun 2014 16:02:51 +0200,
Rickard Strandqvist wrote:
> 
> There is a risk that the variable will be used without being initialized.
> 
> This was largely found by using a static code analysis program called cppcheck.

It won't happen in reality.  And, initializing to some random values
isn't always received good.  You can use uninitialized_var() in such a
case, too.


Takashi

> 
> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> ---
>  sound/pci/ice1712/wm8766.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sound/pci/ice1712/wm8766.c b/sound/pci/ice1712/wm8766.c
> index 21b373b..788a31c 100644
> --- a/sound/pci/ice1712/wm8766.c
> +++ b/sound/pci/ice1712/wm8766.c
> @@ -237,7 +237,7 @@ static int snd_wm8766_ctl_get(struct snd_kcontrol *kcontrol,
>  {
>  	struct snd_wm8766 *wm = snd_kcontrol_chip(kcontrol);
>  	int n = kcontrol->private_value;
> -	u16 val1, val2;
> +	u16 val1 = 0, val2 = 0;
>  
>  	if (wm->ctl[n].get)
>  		wm->ctl[n].get(wm, &val1, &val2);
> -- 
> 1.7.10.4
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-06-01 16:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-01 14:02 [PATCH] sound: pci: ice1712: wm8766.c: Cleaning up uninitialized variables Rickard Strandqvist
2014-06-01 16:23 ` 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®