From: Yu Watanabe Date: Tue, 20 Nov 2018 06:40:36 +0000 (+0900) Subject: busctl: use static destructor and DEFINE_MAIN_FUNCTION() macro X-Git-Tag: v240~258^2~22 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=360f3dc275efdacd8f22fd562f95c762b6420365;p=thirdparty%2Fsystemd.git busctl: use static destructor and DEFINE_MAIN_FUNCTION() macro --- diff --git a/src/busctl/busctl.c b/src/busctl/busctl.c index 2c0f48c437b..0a325f96386 100644 --- a/src/busctl/busctl.c +++ b/src/busctl/busctl.c @@ -18,6 +18,7 @@ #include "json.h" #include "locale-util.h" #include "log.h" +#include "main-func.h" #include "pager.h" #include "parse-util.h" #include "path-util.h" @@ -55,6 +56,8 @@ static bool arg_augment_creds = true; static bool arg_watch_bind = false; static usec_t arg_timeout = 0; +STATIC_DESTRUCTOR_REGISTER(arg_matches, strv_freep); + #define NAME_IS_ACQUIRED INT_TO_PTR(1) #define NAME_IS_ACTIVATABLE INT_TO_PTR(2) @@ -2417,7 +2420,7 @@ static int busctl_main(int argc, char *argv[]) { return dispatch_verb(argc, argv, verbs, NULL); } -int main(int argc, char *argv[]) { +static int run(int argc, char *argv[]) { int r; log_parse_environment(); @@ -2425,16 +2428,9 @@ int main(int argc, char *argv[]) { r = parse_argv(argc, argv); if (r <= 0) - goto finish; - - r = busctl_main(argc, argv); - -finish: - /* make sure we terminate the bus connection first, and then close the - * pager, see issue #3543 for the details. */ - pager_close(); - - arg_matches = strv_free(arg_matches); + return r; - return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; + return busctl_main(argc, argv); } + +DEFINE_MAIN_FUNCTION(run);