[alsa-devel] [patch] ALSA: mixart: don't print an unintialized variable on error
Takashi Sakamoto
o-takashi at sakamocchi.jp
Wed Jul 13 12:18:39 CEST 2016
Hi,
On Jul 13 2016 18:59, Dan Carpenter wrote:
> My static checker complains that "resp" could be unitialized on error
> when we print its value.
>
> Signed-off-by: Dan Carpenter <dan.carpenter at oracle.com>
>
> diff --git a/sound/pci/mixart/mixart_mixer.c b/sound/pci/mixart/mixart_mixer.c
> index 58fd79eb..51e5349 100644
> --- a/sound/pci/mixart/mixart_mixer.c
> +++ b/sound/pci/mixart/mixart_mixer.c
> @@ -965,7 +965,7 @@ static int mixart_update_monitoring(struct snd_mixart* chip, int channel)
> int err;
> struct mixart_msg request;
> struct mixart_set_out_audio_level audio_level;
> - u32 resp;
> + u32 resp = 0;
>
> if(chip->pipe_out_ana.status == PIPE_UNDEFINED)
> return -EINVAL; /* no pipe defined */
The 'resp' variable is firstly given to snd_mixart_send_msg().
static int mixart_update_monitoring(struct snd_mixart* chip,
int channel)
{
...
err = snd_mixart_send_msg(chip->mgr, &request, sizeof(resp), &resp);
if((err<0) || resp) {
dev_dbg(chip->card->dev,
"error MSG_CONNECTOR_SET_OUT_AUDIO_LEVEL card(%d)
resp(%x)\n",
chip->chip_idx, resp);
return -EINVAL;
}
return 0;
}
When the function, snd_mixart_send_msg(), assigns nothing to the
variable in error cases, dev_dbg() prints uninitialized value.
Reviewed-by: Takashi Sakamoto <o-takashi at sakamocchi.jp>
Regards
Takashi Sakamoto
More information about the Alsa-devel
mailing list