linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ALSA: usb-audio: initialize the cur variable
@ 2021-05-21 19:46 trix
  2021-05-22  6:46 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: trix @ 2021-05-21 19:46 UTC (permalink / raw)
  To: perex, tiwai, gustavoars; +Cc: alsa-devel, linux-kernel, Tom Rix

From: Tom Rix <trix@redhat.com>

Static analysis reports this problem
clock.c:338:10: warning: The right operand of '=='
  is a garbage value
    if (i == cur)
          ^  ~~~

In __uac_clock_find_source() the goto find_others skips over
setting of the 'cur' variable.  Since the pin loop variable
starts with 1, it is safe to initialize cur to 0.

Signed-off-by: Tom Rix <trix@redhat.com>
---
 sound/usb/clock.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/usb/clock.c b/sound/usb/clock.c
index 772478c725c2e..edc458c50bf2c 100644
--- a/sound/usb/clock.c
+++ b/sound/usb/clock.c
@@ -258,9 +258,10 @@ static int __uac_clock_find_source(struct snd_usb_audio *chip,
 	union uac23_clock_source_desc *source;
 	union uac23_clock_selector_desc *selector;
 	union uac23_clock_multiplier_desc *multiplier;
-	int ret, i, cur, err, pins, clock_id;
+	int ret, i, err, pins, clock_id;
 	const u8 *sources;
 	int proto = fmt->protocol;
+	int cur = 0;
 
 	entity_id &= 0xff;
 
-- 
2.26.3


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

* Re: [PATCH] ALSA: usb-audio: initialize the cur variable
  2021-05-21 19:46 [PATCH] ALSA: usb-audio: initialize the cur variable trix
@ 2021-05-22  6:46 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2021-05-22  6:46 UTC (permalink / raw)
  To: trix; +Cc: perex, tiwai, gustavoars, alsa-devel, linux-kernel

On Fri, 21 May 2021 21:46:03 +0200,
trix@redhat.com wrote:
> 
> From: Tom Rix <trix@redhat.com>
> 
> Static analysis reports this problem
> clock.c:338:10: warning: The right operand of '=='
>   is a garbage value
>     if (i == cur)
>           ^  ~~~
> 
> In __uac_clock_find_source() the goto find_others skips over
> setting of the 'cur' variable.  Since the pin loop variable
> starts with 1, it is safe to initialize cur to 0.
> 
> Signed-off-by: Tom Rix <trix@redhat.com>

Thanks for the patch, but this has been already fixed in for-next
branch.


Takashi

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

end of thread, other threads:[~2021-05-22  6:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-21 19:46 [PATCH] ALSA: usb-audio: initialize the cur variable trix
2021-05-22  6:46 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).