From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: [PATCH v2 07/13] topology: Add private data parser Date: Wed, 01 Jul 2015 18:20:36 +0200 Message-ID: References: <1435758275-4047-1-git-send-email-liam.r.girdwood@linux.intel.com> <1435758275-4047-7-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 25845261537 for ; Wed, 1 Jul 2015 18:20:37 +0200 (CEST) In-Reply-To: <1435758275-4047-7-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:29 +0100, Liam Girdwood wrote: > > +static int tplg_parse_data_file(snd_config_t *cfg, struct tplg_elem *elem) > +{ > + struct snd_soc_tplg_private *priv = NULL; > + const char *value = NULL; > + char filename[MAX_FILE]; > + char *env = getenv(ALSA_CONFIG_TPLG_VAR); > + FILE *fp; > + size_t size, bytes_read; > + int ret = 0; > + > + tplg_dbg("data DataFile: %s\n", elem->id); > + > + if (snd_config_get_string(cfg, &value) < 0) > + return -EINVAL; > + > + /* prepend alsa config directory to path */ > + snprintf(filename, sizeof(filename), "%s/%s", > + env ? env : ALSA_TPLG_DIR, value); > + filename[sizeof(filename)-1] = '\0'; Unlike strncpy(), snprintf() puts the NUL-character by itself, so this is superfluous. > +static int get_hex_num(const char *str) > +{ > + char *tmp, *s = NULL; > + int i = 0; > + > + tmp = strdup(str); > + if (tmp == NULL) > + return -ENOMEM; > + > + s = strtok(tmp, ","); > + while (s != NULL) { > + s = strtok(NULL, ","); > + i++; > + } > + > + free(tmp); > + return i; Hmm, this just counts the number of comma + 1, so you don't need to duplicate the string? Takashi