> -----Original Message----- > From: Lars-Peter Clausen [mailto:lars@xxxxxxxxxx] > Sent: Thursday, March 31, 2016 8:01 PM > To: Lu, Han <han.lu@xxxxxxxxx>; broonie@xxxxxxxxxx; tiwai@xxxxxxx; Koul, > Vinod <vinod.koul@xxxxxxxxx>; pierre-louis.bossart@xxxxxxxxxxxxxxx; > liam.r.girdwood@xxxxxxxxxxxxxxx; alsa-devel@xxxxxxxxxxxxxxxx > Subject: Re: [PATCH V3 1/2] ASoC: core: add API for registering > DMI card names > > On 03/31/2016 10:58 AM, han.lu@xxxxxxxxx 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 _______________________________________________ Alsa-devel mailing list Alsa-devel@xxxxxxxxxxxxxxxx http://mailman.alsa-project.org/mailman/listinfo/alsa-devel