[alsa-devel] [PATCH v2 114/146] ASoC: soc-topology: use modern dai_link style

Kuninori Morimoto kuninori.morimoto.gx at renesas.com
Fri Jun 7 02:27:08 CEST 2019


Hi Amadeusz

Thank you for your feedback

> >> +	/* link + cpu + codec */
> >> +	link = kzalloc(sizeof(*link) + (2 * sizeof(*dlc)),
> >> GFP_KERNEL); if (link == NULL)
> >>   		return -ENOMEM;
> >>   +	dlc = (struct snd_soc_dai_link_component *)(link + 1);
> >> +
> >> +	link->cpus	= &dlc[0];
> >> +	link->codecs	= &dlc[1];
> > 
> > While I understand what is going on here, I find this bit ugly.
> 
> It's not so bad and it avoid multiple tests and tags that are just as
> ugly IMHO.

Yeah, it is using a little bit tricky method.

> > Can it perhaps be changed to something like:
> > 
> > 	link = kzalloc(sizeof(*link), GFP_KERNEL);
> > 	if (link == NULL)
> > 		return -ENOMEM;
> > 	link->cpus = kzalloc(sizeof(*dlc), GFP_KERNEL);
> > 	if (link->cpus == NULL) {
> > 		ret = -ENOMEM;
> > 		goto err;
> > 	}
> > 	link->codecs = kzalloc(sizeof(*dlc), GFP_KERNEL);
> > 	if (link->cpus == NULL) {
> > 		ret = -ENOMEM;
> > 		goto err;
> > 	}

From "logic" point of view, I think this patch has no bug,
but from "readable code" point of view,
I have no objection to exchange like above.

I'm not familiar with this driver,
so, can you handle it by incremental patch if you want?

Thank you for your help !!
Best regards
---
Kuninori Morimoto


More information about the Alsa-devel mailing list