From: Zbigniew Jędrzejewski-Szmek Date: Tue, 20 Nov 2018 08:56:18 +0000 (+0100) Subject: localectl: define main through macro X-Git-Tag: v240~258^2~31 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=39daad0a8134e9c7584b717fc9e13f0da70a7aed;p=thirdparty%2Fsystemd.git localectl: define main through macro --- diff --git a/src/locale/localectl.c b/src/locale/localectl.c index 8417ff64968..9698a9f2a85 100644 --- a/src/locale/localectl.c +++ b/src/locale/localectl.c @@ -15,6 +15,7 @@ #include "fd-util.h" #include "fileio.h" #include "locale-util.h" +#include "main-func.h" #include "pager.h" #include "proc-cmdline.h" #include "set.h" @@ -505,8 +506,8 @@ static int localectl_main(sd_bus *bus, int argc, char *argv[]) { return dispatch_verb(argc, argv, verbs, bus); } -int main(int argc, char*argv[]) { - sd_bus *bus = NULL; +static int run(int argc, char*argv[]) { + _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL; int r; setlocale(LC_ALL, ""); @@ -515,21 +516,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; - } - - r = localectl_main(bus, argc, argv); - -finish: - /* make sure we terminate the bus connection first, and then close the - * pager, see issue #3543 for the details. */ - sd_bus_flush_close_unref(bus); - pager_close(); + if (r < 0) + return log_error_errno(r, "Failed to create bus connection: %m"); - return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; + return localectl_main(bus, argc, argv); } + +DEFINE_MAIN_FUNCTION(run);