Skip to content

Commit 8b169cb

Browse files
arndbtiwai
authored andcommitted
ALSA: mips: avoid potential uninitialized variable use
MIPS allmodconfig results in this warning: sound/mips/hal2.c: In function 'hal2_gain_get': sound/mips/hal2.c:224:35: error: 'r' may be used uninitialized in this function [-Werror=maybe-uninitialized] sound/mips/hal2.c:223:35: error: 'l' may be used uninitialized in this function [-Werror=maybe-uninitialized] sound/mips/hal2.c: In function 'hal2_gain_put': sound/mips/hal2.c:260:13: error: 'new' may be used uninitialized in this function [-Werror=maybe-uninitialized] sound/mips/hal2.c:260:13: error: 'old' may be used uninitialized in this function [-Werror=maybe-uninitialized] Returning an error for all unexpected cases shuts up the warning Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent a535ad5 commit 8b169cb

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎sound/mips/hal2.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ static int hal2_gain_get(struct snd_kcontrol *kcontrol,
219219
l = (tmp >> H2I_C2_L_GAIN_SHIFT) & 15;
220220
r = (tmp >> H2I_C2_R_GAIN_SHIFT) & 15;
221221
break;
222+
default:
223+
return -EINVAL;
222224
}
223225
ucontrol->value.integer.value[0] = l;
224226
ucontrol->value.integer.value[1] = r;
@@ -256,6 +258,8 @@ static int hal2_gain_put(struct snd_kcontrol *kcontrol,
256258
new |= (r << H2I_C2_R_GAIN_SHIFT);
257259
hal2_i_write32(hal2, H2I_ADC_C2, new);
258260
break;
261+
default:
262+
return -EINVAL;
259263
}
260264
return old != new;
261265
}

0 commit comments

Comments
 (0)