31 Mar
2016
31 Mar
'16
4:48 p.m.
-----Original Message----- From: Lars-Peter Clausen [mailto:lars@metafoo.de] Sent: Thursday, March 31, 2016 8:01 PM To: Lu, Han han.lu@intel.com; broonie@kernel.org; tiwai@suse.de; Koul, Vinod vinod.koul@intel.com; pierre-louis.bossart@linux.intel.com; liam.r.girdwood@linux.intel.com; alsa-devel@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@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