]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bootctl: use static destructor and DEFINE_MAIN_FUNCTION() macro
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 20 Nov 2018 06:35:07 +0000 (15:35 +0900)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 20 Nov 2018 15:48:21 +0000 (16:48 +0100)
src/boot/bootctl.c

index 427faf8b242ab0708c3e965b72f7fb2368430475..59241e5ee43cb93125197913484fc0c3108dfdcd 100644 (file)
@@ -29,6 +29,7 @@
 #include "fileio.h"
 #include "fs-util.h"
 #include "locale-util.h"
+#include "main-func.h"
 #include "pager.h"
 #include "parse-util.h"
 #include "rm-rf.h"
@@ -47,6 +48,8 @@ static bool arg_print_path = false;
 static bool arg_touch_variables = true;
 static PagerFlags arg_pager_flags = 0;
 
+STATIC_DESTRUCTOR_REGISTER(arg_path, freep);
+
 static int acquire_esp(
                 bool unprivileged_mode,
                 uint32_t *ret_part,
@@ -1251,7 +1254,7 @@ static int bootctl_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();
@@ -1263,13 +1266,9 @@ int main(int argc, char *argv[]) {
 
         r = parse_argv(argc, argv);
         if (r <= 0)
-                goto finish;
-
-        r = bootctl_main(argc, argv);
-
- finish:
-        pager_close();
-        free(arg_path);
+                return r;
 
-        return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
+        return bootctl_main(argc, argv);
 }
+
+DEFINE_MAIN_FUNCTION(run);