1 Jul
2015
1 Jul
'15
6:20 p.m.
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