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

Lu, Han han.lu at intel.com
Thu Mar 31 16:48:32 CEST 2016


> -----Original Message-----
> From: Lars-Peter Clausen [mailto:lars at metafoo.de]
> Sent: Thursday, March 31, 2016 8:01 PM
> To: Lu, Han <han.lu at intel.com>; broonie at kernel.org; tiwai at suse.de; Koul,
> Vinod <vinod.koul at intel.com>; pierre-louis.bossart at linux.intel.com;
> liam.r.girdwood at linux.intel.com; alsa-devel at alsa-project.org
> Subject: Re: [alsa-devel] [PATCH V3 1/2] ASoC: core: add API for registering
> DMI card names
> 
> 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
> 

Thanks Lars-Peter, I'll use kasprintf() to replace kmalloc() and snprintf() in V4.

BR,
Han



More information about the Alsa-devel mailing list