Cleanup filter command line parsers.
authorAndre Noll <maan@systemlinux.org>
Wed, 10 Oct 2012 07:29:04 +0000 (09:29 +0200)
committerAndre Noll <maan@systemlinux.org>
Sun, 21 Oct 2012 09:51:22 +0000 (11:51 +0200)
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
compress_filter.c
mp3dec_filter.c
prebuffer_filter.c

index dd2c619..4c3a336 100644 (file)
@@ -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;
 }
 
index 49d6d66..49e386a 100644 (file)
@@ -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)
index bcb1eca..b0f308a 100644 (file)
@@ -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)
index 76ec7c7..5a84986 100644 (file)
@@ -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;
 }