From 8e290f7e1bb88bc9ce8c4fa8fa428e39d5b1f24a Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Wed, 10 Oct 2012 09:29:04 +0200 Subject: [PATCH] Cleanup filter command line parsers. All these functions call the gengetopt parser which aborts on errors. Hence it is pointless to check the return value of the parser. The patch also renames most of the *args_info structs to "conf". --- amp_filter.c | 11 +++++------ compress_filter.c | 13 +++---------- mp3dec_filter.c | 13 +++---------- prebuffer_filter.c | 18 ++++++++---------- 4 files changed, 19 insertions(+), 36 deletions(-) diff --git a/amp_filter.c b/amp_filter.c index dd2c6194..4c3a336c 100644 --- a/amp_filter.c +++ b/amp_filter.c @@ -35,18 +35,17 @@ static void amp_close(struct filter_node *fn) static int amp_parse_config(int argc, char **argv, void **config) { - struct amp_filter_args_info *amp_conf = para_calloc(sizeof(*amp_conf)); + struct amp_filter_args_info *conf = para_calloc(sizeof(*conf)); int ret = -E_AMP_SYNTAX; - if (amp_filter_cmdline_parser(argc, argv, amp_conf)) - goto err; + amp_filter_cmdline_parser(argc, argv, conf); ret = -ERRNO_TO_PARA_ERROR(EINVAL); - if (amp_conf->amp_arg < 0) + if (conf->amp_arg < 0) goto err; - *config = amp_conf; + *config = conf; return 1; err: - free(amp_conf); + free(conf); return ret; } diff --git a/compress_filter.c b/compress_filter.c index 49d6d66c..49e386ae 100644 --- a/compress_filter.c +++ b/compress_filter.c @@ -115,18 +115,11 @@ err: /** TODO: Add sanity checks */ static int compress_parse_config(int argc, char **argv, void **config) { - int ret; - struct compress_filter_args_info *compress_conf - = para_calloc(sizeof(*compress_conf)); + struct compress_filter_args_info *conf = para_calloc(sizeof(*conf)); - ret = -E_COMPRESS_SYNTAX; - if (compress_filter_cmdline_parser(argc, argv, compress_conf)) - goto err; - *config = compress_conf; + compress_filter_cmdline_parser(argc, argv, conf); + *config = conf; return 1; -err: - free(compress_conf); - return ret; } static void compress_open(struct filter_node *fn) diff --git a/mp3dec_filter.c b/mp3dec_filter.c index bcb1eca8..b0f308ad 100644 --- a/mp3dec_filter.c +++ b/mp3dec_filter.c @@ -184,18 +184,11 @@ static void mp3dec_open(struct filter_node *fn) static int mp3dec_parse_config(int argc, char **argv, void **config) { - int ret; - struct mp3dec_filter_args_info *mp3_conf; + struct mp3dec_filter_args_info *conf = para_calloc(sizeof(*conf)); - mp3_conf = para_calloc(sizeof(*mp3_conf)); - ret = -E_MP3DEC_SYNTAX; - if (mp3dec_filter_cmdline_parser(argc, argv, mp3_conf)) - goto err; - *config = mp3_conf; + mp3dec_filter_cmdline_parser(argc, argv, conf); + *config = conf; return 1; -err: - free(mp3_conf); - return ret; } static int mp3dec_execute(struct btr_node *btrn, const char *cmd, char **result) diff --git a/prebuffer_filter.c b/prebuffer_filter.c index 76ec7c73..5a849868 100644 --- a/prebuffer_filter.c +++ b/prebuffer_filter.c @@ -78,23 +78,21 @@ static void prebuffer_post_select(__a_unused struct sched *s, struct task *t) static int prebuffer_parse_config(int argc, char **argv, void **config) { - struct prebuffer_filter_args_info *prebuffer_conf - = para_calloc(sizeof(*prebuffer_conf)); + struct prebuffer_filter_args_info *conf = para_calloc(sizeof(*conf)); int ret = -E_PREBUFFER_SYNTAX; - if (prebuffer_filter_cmdline_parser(argc, argv, prebuffer_conf)) - goto err; + prebuffer_filter_cmdline_parser(argc, argv, conf); ret = -ERRNO_TO_PARA_ERROR(EINVAL); - if (prebuffer_conf->duration_arg < 0) + if (conf->duration_arg < 0) goto err; - if (prebuffer_conf->size_arg < 0) + if (conf->size_arg < 0) goto err; - PARA_NOTICE_LOG("prebuffering %ims, %i bytes\n", - prebuffer_conf->duration_arg, prebuffer_conf->size_arg); - *config = prebuffer_conf; + PARA_NOTICE_LOG("prebuffering %ims, %i bytes\n", conf->duration_arg, + conf->size_arg); + *config = conf; return 1; err: - free(prebuffer_conf); + free(conf); return ret; } -- 2.39.5