[alsa-devel] [PATCH V3 1/2] ASoC: core: add API for registering DMI card names

Lars-Peter Clausen lars at metafoo.de
Thu Mar 31 14:00:43 CEST 2016


On 03/31/2016 10:58 AM, han.lu at intel.com wrote:
[...]
> +	name_size = strlen(card->name) + strlen(card->driver_name)
> +			+ strlen(vendor) + strlen(firmware) + 4;
> +	if (buf_size < name_size + strlen(card->snd_card->components))
> +		return -ENOMEM;
> +	name = kmalloc(buf_size, GFP_KERNEL);
> +	if (!name)
> +		return -ENOMEM;
> +	snprintf(name, buf_size, "%s:%s:%s:%s", card->name,
> +			card->driver_name, vendor, firmware);

Have a look at kasprintf(). It will allow you to simplify the code here




More information about the Alsa-devel mailing list