Skip to contentSkip to conversation

ALSA: usb-audio: initialize the cur variable

PATCH In review [email protected] 2 participants 2 messages May 21, 2021 – May 22, 2021 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: usb-audio: initialize the cur variable

From: Tom Rix <[email protected]>

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.

---
 sound/usb/clock.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
sound/usb/clock.c +2 -1
index 772478c725c2e..edc458c50bf2c 100644
@@ -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;
 
Signature · 1 line
2.26.3
#1 lore raw
Quoted 6 lines · On Fri, 21 May 2021 21:46:03 +0200, [email protected] wrote:

From: Tom Rix <[email protected]>

Static analysis reports this problem clock.c:338:10: warning: The right operand of '=='
is a garbage value

Quoted 8 lines
    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.

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

Takashi