Skip to content

Commit

Permalink
ALSA: mips: avoid potential uninitialized variable use
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
arndb authored and tiwai committed Jan 16, 2017
1 parent a535ad5 commit 8b169cb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sound/mips/hal2.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ static int hal2_gain_get(struct snd_kcontrol *kcontrol,
l = (tmp >> H2I_C2_L_GAIN_SHIFT) & 15;
r = (tmp >> H2I_C2_R_GAIN_SHIFT) & 15;
break;
default:
return -EINVAL;
}
ucontrol->value.integer.value[0] = l;
ucontrol->value.integer.value[1] = r;
Expand Down Expand Up @@ -256,6 +258,8 @@ static int hal2_gain_put(struct snd_kcontrol *kcontrol,
new |= (r << H2I_C2_R_GAIN_SHIFT);
hal2_i_write32(hal2, H2I_ADC_C2, new);
break;
default:
return -EINVAL;
}
return old != new;
}
Expand Down

0 comments on commit 8b169cb

Please sign in to comment.