]> git.ipfire.org Git - people/ms/network.git/commitdiff
networkctl: Terminate after showing help or version
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 9 Jun 2023 07:51:50 +0000 (07:51 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 9 Jun 2023 07:51:50 +0000 (07:51 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/networkctl/main.c

index 0ba72849fcca4f2c826b56764e426d0498add8de..fde77b828a5ad9635446a5cd71fc2a474b3c2f9a 100644 (file)
@@ -21,6 +21,7 @@
 #include <errno.h>
 #include <getopt.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <unistd.h>
 
 #include <systemd/sd-bus.h>
@@ -45,13 +46,13 @@ static int networkctl_main(sd_bus* bus, int argc, char* argv[]) {
        return command_dispatch(bus, commands, argc, argv);
 }
 
-static int version(void) {
+static void version(void) {
        printf("networkctl %s\n", PACKAGE_VERSION);
 
-       return 0;
+       exit(0);
 }
 
-static int help(void) {
+static void help(void) {
        printf(
                "%s [OPTIONS...] COMMAND\n\n"
                "Options:\n"
@@ -60,7 +61,7 @@ static int help(void) {
                program_invocation_short_name
        );
 
-       return 0;
+       exit(0);
 }
 
 static int parse_argv(int argc, char* argv[]) {
@@ -82,10 +83,10 @@ static int parse_argv(int argc, char* argv[]) {
 
                switch (c) {
                        case 'h':
-                               return help();
+                               help();
 
                        case ARG_VERSION:
-                               return version();
+                               version();
 
                        case '?':
                                return -EINVAL;