]> git.tue.mpg.de Git - paraslash.git/commitdiff
afh: Print help if no arguments are given.
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 19 Jun 2016 20:16:41 +0000 (22:16 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 31 Jul 2016 14:54:52 +0000 (16:54 +0200)
Currently, if para_afh is invoked with no non-option arguments,
the command fails with

main: afh syntax error

This message is not very helpful, so let's print the short help in
this case, and exit successfully.

afh.c

diff --git a/afh.c b/afh.c
index 195b3788678549a5ab2554d0ac388e1a3a8f60f3..8975777bdb549ae68bc0fc125be7e959b4253ecc 100644 (file)
--- a/afh.c
+++ b/afh.c
@@ -169,7 +169,7 @@ __noreturn static void print_help_and_die(void)
  */
 int main(int argc, char **argv)
 {
-       int i, ret, audio_format_num, fd;
+       int i, ret = 0, audio_format_num, fd;
        void *audio_file_data;
        size_t audio_file_size;
        struct afh_info afhi;
@@ -177,12 +177,9 @@ int main(int argc, char **argv)
        afh_cmdline_parser(argc, argv, &conf);
        loglevel = get_loglevel_by_name(conf.loglevel_arg);
        version_handle_flag("afh", conf.version_given);
-       if (conf.help_given || conf.detailed_help_given)
+       if (conf.help_given || conf.detailed_help_given || conf.inputs_num == 0)
                print_help_and_die();
        afh_init();
-       ret = -E_AFH_SYNTAX;
-       if (conf.inputs_num == 0)
-               goto out;
        for (i = 0; i < conf.inputs_num; i++) {
                int ret2;
                ret = mmap_full_file(conf.inputs[i], O_RDONLY, &audio_file_data,