public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/06] Fix compilation warning for sound/soc/codecs/wm8400.c
@ 2009-07-15  2:18 Subrata Modak
  2009-07-15  4:43 ` Jaswinder Singh Rajput
  0 siblings, 1 reply; 5+ messages in thread
From: Subrata Modak @ 2009-07-15  2:18 UTC (permalink / raw)
  To: Jaroslav Kysela, alsa-devel, Mark Brown, Takashi Iwai
  Cc: Sachin P Sant, David Howells, Subrata Modak, Balbir Singh, LKML

Following fix is inspired by David Howells fix few days back:
http://lkml.org/lkml/2009/7/9/109,

Signed-off-by: Subrata Modak<subrata@linux.vnet.ibm.com>,
---

--- a/sound/soc/codecs/wm8400.c	2009-06-15 07:52:31.000000000 +0530
+++ b/sound/soc/codecs/wm8400.c	2009-07-15 05:35:00.000000000 +0530
@@ -1015,7 +1015,7 @@ static int wm8400_set_dai_pll(struct snd
 {
 	struct snd_soc_codec *codec = codec_dai->codec;
 	struct wm8400_priv *wm8400 = codec->private_data;
-	struct fll_factors factors;
+	struct fll_factors uninitialized_var(factors);
 	int ret;
 	u16 reg;
 

---
Regards--
Subrata


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

* Re: [PATCH 01/06] Fix compilation warning for sound/soc/codecs/wm8400.c
  2009-07-15  2:18 [PATCH 01/06] Fix compilation warning for sound/soc/codecs/wm8400.c Subrata Modak
@ 2009-07-15  4:43 ` Jaswinder Singh Rajput
  2009-07-15  8:28   ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Jaswinder Singh Rajput @ 2009-07-15  4:43 UTC (permalink / raw)
  To: Subrata Modak
  Cc: Jaroslav Kysela, alsa-devel, Mark Brown, Takashi Iwai,
	Sachin P Sant, David Howells, Balbir Singh, LKML

Hello Subrata,

On Wed, 2009-07-15 at 07:48 +0530, Subrata Modak wrote:
> Following fix is inspired by David Howells fix few days back:
> http://lkml.org/lkml/2009/7/9/109,
> 

Please check further of this thread :

http://marc.info/?l=linux-kernel&m=124756210124518&w=2


> Signed-off-by: Subrata Modak<subrata@linux.vnet.ibm.com>,
> ---
> 
> --- a/sound/soc/codecs/wm8400.c	2009-06-15 07:52:31.000000000 +0530
> +++ b/sound/soc/codecs/wm8400.c	2009-07-15 05:35:00.000000000 +0530
> @@ -1015,7 +1015,7 @@ static int wm8400_set_dai_pll(struct snd
>  {
>  	struct snd_soc_codec *codec = codec_dai->codec;
>  	struct wm8400_priv *wm8400 = codec->private_data;
> -	struct fll_factors factors;
> +	struct fll_factors uninitialized_var(factors);
>  	int ret;
>  	u16 reg;
>  
> 

This kind of warnings born due to not handling the variables properly.
Please try to understand the root cause of this warning, just shutting
this warning is of no use.

Please revise your patches, If you face any problems let me know.

Thanks,
--
JSR


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

* Re: [PATCH 01/06] Fix compilation warning for sound/soc/codecs/wm8400.c
  2009-07-15  4:43 ` Jaswinder Singh Rajput
@ 2009-07-15  8:28   ` Mark Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2009-07-15  8:28 UTC (permalink / raw)
  To: Jaswinder Singh Rajput
  Cc: Subrata Modak, Jaroslav Kysela, alsa-devel, Takashi Iwai,
	Sachin P Sant, David Howells, Balbir Singh, LKML

On Wed, Jul 15, 2009 at 10:13:38AM +0530, Jaswinder Singh Rajput wrote:
> Hello Subrata,

> This kind of warnings born due to not handling the variables properly.
> Please try to understand the root cause of this warning, just shutting
> this warning is of no use.

...as I said last time you submitted rougly the same patch.  Please also
remember that sometimes these problems are false positives caused by
issues with the compiler flow analysis (as appears to be the case here).

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

* Re: [PATCH 01/06] Fix compilation warning for sound/soc/codecs/wm8400.c
  2009-07-16 13:10 Subrata Modak
@ 2009-07-16 13:23 ` Mark Brown
  2009-07-16 13:34   ` Takashi Iwai
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2009-07-16 13:23 UTC (permalink / raw)
  To: Subrata Modak
  Cc: Jaswinder Singh Rajput, Jaroslav Kysela, alsa-devel, Takashi Iwai,
	Sachin P Sant, David Howells, Balbir Singh, LKML

On Thu, Jul 16, 2009 at 06:40:01PM +0530, Subrata Modak wrote:

> How about the following brutal shutdown ?

No, this is the patch you originally submitted.  You are missing the
point here - your patches are all just papering over the warning and
won't help at all if there is an actual problem.

> 'factors' will get initialized here, as, 'freq_out' will probably never have
> a '0' value. So, 'fll_factors()' will actually overwrite values in 'factors'
> even after the initial brutal assignment:
> 	"struct fll_factors factors = {}"

This is pretty much the point of the warning when it's valid - it's
trying to catch situations where there is a code path where the variable
is used without being initialised.  If you just blindly initialise the
variable as you are doing then the warning goes away but any problematic
code remains so the situation is worse.

In this case I suspect that whatever compiler you are using (none of
those I've tried with seem to be doing this) isn't able to figure out
that if we skip initialising the variable then we use exactly the same
condition to return from the function before we try to use the variable.
For something like this the warning can normally be worked around by
changing the control flow so that the compiler is able to figure out
that things are safe.

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

* Re: [PATCH 01/06] Fix compilation warning for sound/soc/codecs/wm8400.c
  2009-07-16 13:23 ` [PATCH " Mark Brown
@ 2009-07-16 13:34   ` Takashi Iwai
  0 siblings, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2009-07-16 13:34 UTC (permalink / raw)
  To: Mark Brown
  Cc: Subrata Modak, Jaswinder Singh Rajput, Jaroslav Kysela,
	alsa-devel, Sachin P Sant, David Howells, Balbir Singh, LKML

At Thu, 16 Jul 2009 14:23:08 +0100,
Mark Brown wrote:
> 
> On Thu, Jul 16, 2009 at 06:40:01PM +0530, Subrata Modak wrote:
> 
> > How about the following brutal shutdown ?
> 
> No, this is the patch you originally submitted.  You are missing the
> point here - your patches are all just papering over the warning and
> won't help at all if there is an actual problem.
> 
> > 'factors' will get initialized here, as, 'freq_out' will probably never have
> > a '0' value. So, 'fll_factors()' will actually overwrite values in 'factors'
> > even after the initial brutal assignment:
> > 	"struct fll_factors factors = {}"
> 
> This is pretty much the point of the warning when it's valid - it's
> trying to catch situations where there is a code path where the variable
> is used without being initialised.  If you just blindly initialise the
> variable as you are doing then the warning goes away but any problematic
> code remains so the situation is worse.
> 
> In this case I suspect that whatever compiler you are using (none of
> those I've tried with seem to be doing this) isn't able to figure out
> that if we skip initialising the variable then we use exactly the same
> condition to return from the function before we try to use the variable.

I get compile warnings on gcc 4.4.0, too.


> For something like this the warning can normally be worked around by
> changing the control flow so that the compiler is able to figure out
> that things are safe.

Agreed.


Takashi

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

end of thread, other threads:[~2009-07-16 13:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-15  2:18 [PATCH 01/06] Fix compilation warning for sound/soc/codecs/wm8400.c Subrata Modak
2009-07-15  4:43 ` Jaswinder Singh Rajput
2009-07-15  8:28   ` Mark Brown
  -- strict thread matches above, loose matches on Subject: below --
2009-07-16 13:10 Subrata Modak
2009-07-16 13:23 ` [PATCH " Mark Brown
2009-07-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