tools: fix return codes on failure
authorPeter Hutterer <peter.hutterer@who-t.net>
Wed, 24 May 2017 23:32:13 +0000 (09:32 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Fri, 26 May 2017 01:15:01 +0000 (11:15 +1000)
Leftovers from an earlier version where we had booleans and more function
nesting in the mix. Fix to return integers, and also rename the function name
accordingly.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
tools/libinput-tool.c

index 12204abdd23a8f3214aab1f847cdcd2d13035ec5..1485419db6953ad64504ac147ea5e75944a1d393 100644 (file)
@@ -76,8 +76,8 @@ enum global_opts {
        GOPT_VERBOSE,
 };
 
-static bool
-parse_args_cmd(enum command cmd,
+static int
+run_args_cmd(enum command cmd,
               struct global_options *global_options,
               int argc, char *argv[])
 {
@@ -91,7 +91,8 @@ parse_args_cmd(enum command cmd,
        case COMMAND_DEBUG_EVENTS:
                return libinput_debug_events(global_options, argc, argv);
        }
-       return true;
+
+       return EXIT_FAILURE;
 }
 
 int
@@ -104,7 +105,7 @@ main(int argc, char **argv)
 
        if (argc == 1) {
                libinput_tool_usage();
-               return false;
+               return EXIT_FAILURE;
        }
 
        while (1) {
@@ -125,10 +126,10 @@ main(int argc, char **argv)
                case 'h':
                case GOPT_HELP:
                        libinput_tool_usage();
-                       exit(0);
+                       return EXIT_SUCCESS;
                case GOPT_VERSION:
                        printf("%s\n", LIBINPUT_VERSION);
-                       exit(0);
+                       return EXIT_SUCCESS;
                case GOPT_VERBOSE:
                        global_options.verbose = true;
                        break;
@@ -137,13 +138,13 @@ main(int argc, char **argv)
                        break;
                default:
                        libinput_tool_usage();
-                       return false;
+                       return EXIT_FAILURE;
                }
        }
 
        if (optind > argc) {
                libinput_tool_usage();
-               return false;
+               return EXIT_FAILURE;
        }
 
        command = argv[optind];
@@ -157,5 +158,5 @@ main(int argc, char **argv)
                return EXIT_FAILURE;
        }
 
-       return parse_args_cmd(cmd, &global_options, argc - optind, &argv[optind]);
+       return run_args_cmd(cmd, &global_options, argc - optind, &argv[optind]);
 }