]> git.tue.mpg.de Git - paraslash.git/commitdiff
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 dd2c61949da4877a88ef4ca468fb6bf4be7e6b7e..4c3a336c6ba64650ccecf5033392aa4e558c2427 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 49d6d66c4f7a6b37d3b5ba4e072f2208f3a90715..49e386ae775c5c3ace61c08108f1bfede9d7fe85 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 bcb1eca8dc563881ddc50065b1a2f4e0d18f1182..b0f308adcee14e40efff9b4e5ed225ef4b1d4ce6 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 76ec7c73a411c292ebc62b2b9f857bd212562e60..5a849868e0ec2998009512e2e1f2d8e7dde43539 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;
 }