* [patch] ALSA: mixart: don't print an unintialized variable on error
@ 2016-07-13 9:59 Dan Carpenter
2016-07-13 10:18 ` Takashi Sakamoto
2016-07-13 10:24 ` Takashi Iwai
0 siblings, 2 replies; 4+ messages in thread
From: Dan Carpenter @ 2016-07-13 9:59 UTC (permalink / raw)
To: Jaroslav Kysela; +Cc: alsa-devel, kernel-janitors, Takashi Iwai
My static checker complains that "resp" could be unitialized on error
when we print its value.
Signed-off-by: Dan Carpenter <dan.carpenter@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 */
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [patch] ALSA: mixart: don't print an unintialized variable on error
2016-07-13 9:59 [patch] ALSA: mixart: don't print an unintialized variable on error Dan Carpenter
@ 2016-07-13 10:18 ` Takashi Sakamoto
2016-07-13 14:28 ` Takashi Sakamoto
2016-07-13 10:24 ` Takashi Iwai
1 sibling, 1 reply; 4+ messages in thread
From: Takashi Sakamoto @ 2016-07-13 10:18 UTC (permalink / raw)
To: Dan Carpenter, Jaroslav Kysela; +Cc: alsa-devel, kernel-janitors, Takashi Iwai
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@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@sakamocchi.jp>
Regards
Takashi Sakamoto
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] ALSA: mixart: don't print an unintialized variable on error
2016-07-13 9:59 [patch] ALSA: mixart: don't print an unintialized variable on error Dan Carpenter
2016-07-13 10:18 ` Takashi Sakamoto
@ 2016-07-13 10:24 ` Takashi Iwai
1 sibling, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2016-07-13 10:24 UTC (permalink / raw)
To: Dan Carpenter; +Cc: Jaroslav Kysela, alsa-devel, kernel-janitors
On Wed, 13 Jul 2016 11:59:53 +0200,
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@oracle.com>
Applied, thanks.
Takashi
>
> 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 */
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] ALSA: mixart: don't print an unintialized variable on error
2016-07-13 10:18 ` Takashi Sakamoto
@ 2016-07-13 14:28 ` Takashi Sakamoto
0 siblings, 0 replies; 4+ messages in thread
From: Takashi Sakamoto @ 2016-07-13 14:28 UTC (permalink / raw)
To: Dan Carpenter, Jaroslav Kysela; +Cc: alsa-devel, kernel-janitors, Takashi Iwai
On Jul 13 2016 19:18, Takashi Sakamoto wrote:
> 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@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.
Hm. I realized that this interpretation is not enough. When value of the
error is not negative, snd_mixart_send_msg() can assign something to the
resp variable, then dev_dbg() is called. In short, when the function is
successful, there's a case that the message is processed. This is a bit
strange...
I think a condition statement for the resp variable is needless here, as
long as the variable is initialized ahead...
> Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Anyway, it's better to initialize it.
Regards
Takashi Sakamoto
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-07-13 14:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-13 9:59 [patch] ALSA: mixart: don't print an unintialized variable on error Dan Carpenter
2016-07-13 10:18 ` Takashi Sakamoto
2016-07-13 14:28 ` Takashi Sakamoto
2016-07-13 10:24 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox