All of lore.kernel.org
 help / color / mirror / Atom feed
* Compiler warning - overriding codec compress type
@ 2011-04-18  6:37 Patrick Lai
  2011-04-18  9:25 ` Clemens Ladisch
  2011-04-18 10:30 ` Mark Brown
  0 siblings, 2 replies; 4+ messages in thread
From: Patrick Lai @ 2011-04-18  6:37 UTC (permalink / raw)
  To: alsa-devel

Hi,

I got a compiler warning soc-core.c: In function 
'snd_soc_instantiate_cards' warning: 'compress_type' may be used 
uninitialized in this function. In reality, compress_type is defined as 
local variable in snd_soc_instantiate_card().

My kernel version is 2.6.38. Has the warning being addressed in 2.6.39 
or 2.6.40 patches? If not, after tracing through the code, I think the 
fix should look like the following:

list_for_each_entry(codec, &codec_list, list) {
                 if (codec->cache_init)
                         continue;
+               compress_type = 0;
                 /* check to see if we need to override the compress_type */
                 for (i = 0; i < card->num_configs; ++i) {
                         codec_conf = &card->codec_conf[i];

Please advise

Thanks
Patrick

-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

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

* Re: Compiler warning - overriding codec compress type
  2011-04-18  6:37 Compiler warning - overriding codec compress type Patrick Lai
@ 2011-04-18  9:25 ` Clemens Ladisch
  2011-04-18 10:30 ` Mark Brown
  1 sibling, 0 replies; 4+ messages in thread
From: Clemens Ladisch @ 2011-04-18  9:25 UTC (permalink / raw)
  To: Patrick Lai; +Cc: alsa-devel

Patrick Lai wrote:
> I got a compiler warning soc-core.c: In function
> 'snd_soc_instantiate_cards' warning: 'compress_type' may be used
> uninitialized in this function. In reality, compress_type is defined as
> local variable in snd_soc_instantiate_card().

Please note that this warning is merely a tool to find errors in the
code; the word "may" indicates that the compilter isn't sure about this.

> I think the fix should look like the following:
> 
> list_for_each_entry(codec, &codec_list, list) {
>                  if (codec->cache_init)
>                          continue;
> +               compress_type = 0;
>                  /* check to see if we need to override the compress_type */
>                  for (i = 0; i < card->num_configs; ++i) {
>                          codec_conf = &card->codec_conf[i];

When the for loop does not find an override, the following if() will
jump out of the outer list_for_each_entry loop before the compress_type
could be used, so it is not actually necessary to initialize this
variable; a better way would be to use uninitialized_var.

> My kernel version is 2.6.38. Has the warning being addressed in 2.6.39 
> or 2.6.40 patches?

... and an even better way is to simplify the logic:
http://git.alsa-project.org/?p=alsa-kernel.git;a=commitdiff;h=3110b8b0206cba978d95895723a3d901fb0f738d


Regards,
Clemens

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

* Re: Compiler warning - overriding codec compress type
  2011-04-18  6:37 Compiler warning - overriding codec compress type Patrick Lai
  2011-04-18  9:25 ` Clemens Ladisch
@ 2011-04-18 10:30 ` Mark Brown
  2011-04-18 18:53   ` Patrick Lai
  1 sibling, 1 reply; 4+ messages in thread
From: Mark Brown @ 2011-04-18 10:30 UTC (permalink / raw)
  To: Patrick Lai; +Cc: alsa-devel

On Sun, Apr 17, 2011 at 11:37:34PM -0700, Patrick Lai wrote:

> I got a compiler warning soc-core.c: In function 
> 'snd_soc_instantiate_cards' warning: 'compress_type' may be used 
> uninitialized in this function. In reality, compress_type is defined as 
> local variable in snd_soc_instantiate_card().

Please *always* CC relevant maintainers on mails if you want them to be
read.

> My kernel version is 2.6.38. Has the warning being addressed in 2.6.39 
> or 2.6.40 patches? If not, after tracing through the code, I think the 
> fix should look like the following:

This is the sort of question that can easily be answered by building the
code...  I believe it's not an issue with current code but I've not
looked myself.

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

* Re: Compiler warning - overriding codec compress type
  2011-04-18 10:30 ` Mark Brown
@ 2011-04-18 18:53   ` Patrick Lai
  0 siblings, 0 replies; 4+ messages in thread
From: Patrick Lai @ 2011-04-18 18:53 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel

On 4/18/2011 3:30 AM, Mark Brown wrote:
>
> Please *always* CC relevant maintainers on mails if you want them to be
> read.
Will do
>
> This is the sort of question that can easily be answered by building the
> code...  I believe it's not an issue with current code but I've not
> looked myself.
Clemens pointed out the patch which addresses the warning.
http://git.alsa-project.org/?p=alsa-kernel.git;a=commitdiff;h=3110b8b0206cba978d95895723a3d901fb0f738d

> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel


-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.

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

end of thread, other threads:[~2011-04-18 18:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-18  6:37 Compiler warning - overriding codec compress type Patrick Lai
2011-04-18  9:25 ` Clemens Ladisch
2011-04-18 10:30 ` Mark Brown
2011-04-18 18:53   ` Patrick Lai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.