Don't check return value of command line parsers unnecessarily.
authorAndre Noll <maan@systemlinux.org>
Sat, 6 Apr 2013 18:59:12 +0000 (18:59 +0000)
committerAndre Noll <maan@systemlinux.org>
Thu, 13 Jun 2013 16:29:03 +0000 (18:29 +0200)
All gengetopt parsers except the one for para_client are generated
without the --no-handle-error option, i.e. these parsers exit on errors.
Hence it is pointless to check return values.

afh_recv.c
audioc.c
audiod.c
dccp_recv.c
fade.c
filter.c
gui.c
http_recv.c
play.c
recv.c
udp_recv.c

index 774ae88..96f0d7e 100644 (file)
@@ -70,10 +70,8 @@ static void *afh_recv_parse_config(int argc, char **argv)
 {
        struct afh_recv_args_info *tmp = para_calloc(sizeof(*tmp));
 
-       if (!afh_recv_cmdline_parser(argc, argv, tmp))
-               return tmp;
-       free(tmp);
-       return NULL;
+       afh_recv_cmdline_parser(argc, argv, tmp);
+       return tmp;
 }
 
 static void afh_recv_free_config(void *conf)
index 42b4628..b0f822b 100644 (file)
--- a/audioc.c
+++ b/audioc.c
@@ -281,12 +281,11 @@ static char *configfile_exists(void)
  */
 int main(int argc, char *argv[])
 {
-       int ret = -E_AUDIOC_SYNTAX, fd;
+       int ret, fd;
        char *cf, *buf = NULL, *args = NULL;
        size_t bufsize;
 
-       if (audioc_cmdline_parser(argc, argv, &conf))
-               goto out;
+       audioc_cmdline_parser(argc, argv, &conf);
        HANDLE_VERSION_FLAG("audioc", conf);
        cf = configfile_exists();
        if (cf) {
@@ -298,12 +297,8 @@ int main(int argc, char *argv[])
                        .print_errors = 1,
 
                };
-               ret = audioc_cmdline_parser_config_file(cf, &conf, &params);
+               audioc_cmdline_parser_config_file(cf, &conf, &params);
                free(cf);
-               if (ret) {
-                       fprintf(stderr, "parse error in config file\n");
-                       exit(EXIT_FAILURE);
-               }
        }
        loglevel = get_loglevel_by_name(conf.loglevel_arg);
        if (conf.socket_given)
index d2c66f2..4100d41 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -1350,8 +1350,7 @@ int main(int argc, char *argv[])
        };
 
        valid_fd_012();
-       if (audiod_cmdline_parser_ext(argc, argv, &conf, &params))
-               exit(EXIT_FAILURE);
+       audiod_cmdline_parser_ext(argc, argv, &conf, &params);
        HANDLE_VERSION_FLAG("audiod", conf);
        /* init receivers/filters/writers early to make help work */
        recv_init();
index 1f9df18..875d838 100644 (file)
@@ -107,11 +107,10 @@ static void *dccp_recv_parse_config(int argc, char **argv)
 {
        struct dccp_recv_args_info *tmp = para_calloc(sizeof(*tmp));
 
-       if (!dccp_recv_cmdline_parser(argc, argv, tmp) &&
-           dccp_recv_ccid_support_check(tmp))
-               return tmp;
-       free(tmp);
-       return NULL;
+       dccp_recv_cmdline_parser(argc, argv, tmp);
+       if (!dccp_recv_ccid_support_check(tmp))
+               exit(EXIT_FAILURE);
+       return tmp;
 }
 
 static void dccp_recv_pre_select(struct sched *s, struct task *t)
diff --git a/fade.c b/fade.c
index fee8f8c..d2ab828 100644 (file)
--- a/fade.c
+++ b/fade.c
@@ -292,8 +292,7 @@ int main(int argc, char *argv[])
        struct mixer *m;
        struct mixer_handle *h = NULL;
 
-       if (fade_cmdline_parser(argc, argv, &conf))
-               exit(EXIT_FAILURE);
+       fade_cmdline_parser(argc, argv, &conf);
        HANDLE_VERSION_FLAG("fade", conf);
        ret = configfile_exists();
        if (!ret && conf.config_file_given) {
index 40e3779..84ad857 100644 (file)
--- a/filter.c
+++ b/filter.c
@@ -65,8 +65,7 @@ static int parse_config(int argc, char *argv[])
        static char *cf; /* config file */
        struct stat statbuf;
 
-       if (filter_cmdline_parser(argc, argv, &conf))
-               return -E_FILTER_SYNTAX;
+       filter_cmdline_parser(argc, argv, &conf);
        HANDLE_VERSION_FLAG("filter", conf);
        if (conf.help_given || conf.detailed_help_given)
                print_help_and_die();
@@ -84,8 +83,7 @@ static int parse_config(int argc, char *argv[])
                        .check_ambiguity = 0,
                        .print_errors = 1
                };
-               if (filter_cmdline_parser_config_file(cf, &conf, &params))
-                       return -E_FILTER_SYNTAX;
+               filter_cmdline_parser_config_file(cf, &conf, &params);
        }
        if (!conf.filter_given)
                return -E_NO_FILTERS;
diff --git a/gui.c b/gui.c
index 096beb9..e157dd1 100644 (file)
--- a/gui.c
+++ b/gui.c
@@ -1362,10 +1362,7 @@ static void com_reread_conf(void)
        }
        PARA_INFO_LOG("rereading command line options and config file");
        gui_cmdline_parser_ext(_argc, _argv, &conf, &params);
-       if (gui_cmdline_parser_config_file(cf, &conf, &params) != 0) {
-               PARA_EMERG_LOG("errors in config file");
-               finish(EXIT_FAILURE);
-       }
+       gui_cmdline_parser_config_file(cf, &conf, &params);
        PARA_NOTICE_LOG("config file reloaded");
        if (check_key_map_args() < 0)
                finish(EXIT_FAILURE);
@@ -1538,8 +1535,7 @@ int main(int argc, char *argv[])
                        .check_ambiguity = 0,
                        .print_errors = 1,
                };
-               if (gui_cmdline_parser_config_file(cf, &conf, &params) != 0)
-                       exit(EXIT_FAILURE);
+               gui_cmdline_parser_config_file(cf, &conf, &params);
        }
        loglevel = get_loglevel_by_name(conf.loglevel_arg);
        if (check_key_map_args() < 0) {
index f1d8593..8cb984f 100644 (file)
@@ -143,10 +143,8 @@ static void *http_recv_parse_config(int argc, char **argv)
 {
        struct http_recv_args_info *tmp = para_calloc(sizeof(*tmp));
 
-       if (!http_recv_cmdline_parser(argc, argv, tmp))
-               return tmp;
-       free(tmp);
-       return NULL;
+       http_recv_cmdline_parser(argc, argv, tmp);
+       return tmp;
 }
 
 static int http_recv_open(struct receiver_node *rn)
diff --git a/play.c b/play.c
index 2cb0536..83d2851 100644 (file)
--- a/play.c
+++ b/play.c
@@ -176,8 +176,7 @@ static void parse_config_or_die(int argc, char *argv[])
                .print_errors = 1
        };
 
-       if (play_cmdline_parser_ext(argc, argv, &conf, &params))
-               exit(EXIT_FAILURE);
+       play_cmdline_parser_ext(argc, argv, &conf, &params);
        HANDLE_VERSION_FLAG("play", conf);
        if (conf.help_given || conf.detailed_help_given)
                print_help_and_die();
diff --git a/recv.c b/recv.c
index 1fb5e25..b03c571 100644 (file)
--- a/recv.c
+++ b/recv.c
@@ -54,8 +54,7 @@ __noreturn static void print_help_and_die(void)
 
 static void *parse_config(int argc, char *argv[], int *receiver_num)
 {
-       if (recv_cmdline_parser(argc, argv, &conf))
-               return NULL;
+       recv_cmdline_parser(argc, argv, &conf);
        HANDLE_VERSION_FLAG("recv", conf);
        if (conf.help_given || conf.detailed_help_given)
                print_help_and_die();
index f9c70ec..cff55f2 100644 (file)
@@ -100,15 +100,9 @@ static void udp_recv_close(struct receiver_node *rn)
 
 static void *udp_recv_parse_config(int argc, char **argv)
 {
-       int ret;
-       struct udp_recv_args_info *tmp =
-               para_calloc(sizeof(struct udp_recv_args_info));
-
-       ret = udp_recv_cmdline_parser(argc, argv, tmp)? -E_UDP_SYNTAX : 1;
-       if (ret >= 0)
-               return tmp;
-       free(tmp);
-       return NULL;
+       struct udp_recv_args_info *tmp = para_calloc(sizeof(*tmp));
+       udp_recv_cmdline_parser(argc, argv, tmp);
+       return tmp;
 }
 
 /*