diff --git a/src/hostname/hostnamectl.c b/src/hostname/hostnamectl.c index be94de4994f..8220741efad 100644 --- a/src/hostname/hostnamectl.c +++ b/src/hostname/hostnamectl.c @@ -426,7 +426,7 @@ static int hostnamectl_main(sd_bus *bus, int argc, char *argv[]) { return dispatch_verb(argc, argv, verbs, bus); } -int main(int argc, char *argv[]) { +static int run(int argc, char *argv[]) { _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL; int r; @@ -436,16 +436,13 @@ int main(int argc, char *argv[]) { r = parse_argv(argc, argv); if (r <= 0) - goto finish; + return r; r = bus_connect_transport(arg_transport, arg_host, false, &bus); - if (r < 0) { - log_error_errno(r, "Failed to create bus connection: %m"); - goto finish; - } + if (r < 0) + return log_error_errno(r, "Failed to create bus connection: %m"); - r = hostnamectl_main(bus, argc, argv); - -finish: - return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; + return hostnamectl_main(bus, argc, argv); } + +DEFINE_MAIN_FUNCTION(run);