From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: [PATCH v2 04/13] topology: Add text section parser. Date: Wed, 01 Jul 2015 18:03:27 +0200 Message-ID: References: <1435758275-4047-1-git-send-email-liam.r.girdwood@linux.intel.com> <1435758275-4047-4-git-send-email-liam.r.girdwood@linux.intel.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 54542260633 for ; Wed, 1 Jul 2015 18:03:28 +0200 (CEST) In-Reply-To: <1435758275-4047-4-git-send-email-liam.r.girdwood@linux.intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Liam Girdwood Cc: Vinod Koul , alsa-devel@alsa-project.org, Mark Brown List-Id: alsa-devel@alsa-project.org At Wed, 1 Jul 2015 14:44:26 +0100, Liam Girdwood wrote: > > +static int parse_text_values(snd_config_t *cfg, struct tplg_elem *elem) > +{ > + snd_config_iterator_t i, next; > + snd_config_t *n; > + const char *value = NULL; > + int j = 0; > + > + tplg_dbg(" Text Values: %s\n", elem->id); > + > + snd_config_for_each(i, next, cfg) { > + n = snd_config_iterator_entry(i); > + > + if (j == SND_SOC_TPLG_NUM_TEXTS) { > + tplg_dbg("error: text string number exceeds %d\n", j); > + return -ENOMEM; > + } > + > + /* get value */ > + if (snd_config_get_string(n, &value) < 0) > + continue; > + > + strncpy(&elem->texts[j][0], value, > + SNDRV_CTL_ELEM_ID_NAME_MAXLEN); > + elem->texts[j][SNDRV_CTL_ELEM_ID_NAME_MAXLEN - 1] = 0; There are multiple calls like this, so maybe it's worth to create a simple helper to copy the ctl element id string instead of open coding at each place. Takashi