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".
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;
}
/** 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)
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)
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;
}