Re: [linux-next:master 9388/11353] sound/soc/soc-compress.c:628 snd_soc_new_compress() error: we previously assumed 'codec_dai' could be null (see line 571)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Mar 09, 2022 at 18:18:23PM +0800, Dan Carpenter wrote:
> Yeah.  That's true.  Smatch tries to look at conditions and figure out
> the implications but this one is too complicated.
> 
> But if codec_dai can really be NULL then it would be easier to
> understand if we reversed the check on codec_dai and returned early.
> 
>	if (!codec_dai) {
>		dev_err(rtd->card->dev, "Missing codec\n");
>		return -EINVAL;
>	}
>
>	/* check client and interface hw capabilities */
>	if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_PLAYBACK) &&
> 	    snd_soc_dai_stream_valid(cpu_dai,   SNDRV_PCM_STREAM_PLAYBACK))
> 		playback = 1;

Thanks, it looks good to me.
I will submit a patch with
"Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>"
to make the code more clear.

Jiang





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux