From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: [PATCH v2 03/13] topology: Add topology core parser. Date: Wed, 01 Jul 2015 18:00:16 +0200 Message-ID: References: <1435758275-4047-1-git-send-email-liam.r.girdwood@linux.intel.com> <1435758275-4047-3-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 0AA32260633 for ; Wed, 1 Jul 2015 18:00:17 +0200 (CEST) In-Reply-To: <1435758275-4047-3-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:25 +0100, Liam Girdwood wrote: > > +int tplg_parse_compound(snd_tplg_t *tplg, snd_config_t *cfg, > + int (*fcn)(snd_tplg_t *, snd_config_t *, void *), > + void *private) > +{ > + const char *id; > + snd_config_iterator_t i, next; > + snd_config_t *n; > + int err = -EINVAL; > + > + if (snd_config_get_id(cfg, &id) < 0) > + return -EINVAL; > + > + if (snd_config_get_type(cfg) != SND_CONFIG_TYPE_COMPOUND) { > + fprintf(stderr, "error: compound type expected for %s", id); It's not good to print an error unconditionally from a system library. Better to use SNDERR() macro. > +int snd_tplg_build(snd_tplg_t *tplg, const char *infile, const char *outfile) > +{ > + snd_config_t *cfg = NULL; > + int err = 0; > + > + /* delete any old output files */ > + unlink(outfile); > + > + tplg->out_fd = > + open(outfile, O_RDWR | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO); > + if (tplg->out_fd < 0) { > + fprintf(stderr, "error: failed to open %s err %d\n", > + outfile, -errno); > + return -errno; > + } > + > + err = tplg_load_config(infile, &cfg); > + if (err < 0) { > + fprintf(stderr, "error: failed to load topology file %s\n", > + infile); > + return err; The outfile is left opened. Takashi