From a8a7e5fcf260abe2fbc74e8fa0d325dc5a5fa994 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 20 Nov 2018 17:39:25 +0900 Subject: [PATCH] bless-boot: use static destructor and DEFINE_MAIN_FUNCTION() macro --- src/boot/bless-boot.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/boot/bless-boot.c b/src/boot/bless-boot.c index 2455f3703f5..92661122c54 100644 --- a/src/boot/bless-boot.c +++ b/src/boot/bless-boot.c @@ -18,6 +18,8 @@ static char *arg_path = NULL; +STATIC_DESTRUCTOR_REGISTER(arg_path, freep); + static int help(int argc, char *argv[], void *userdata) { printf("%s [COMMAND] [OPTIONS...]\n" @@ -436,7 +438,7 @@ exists: return 0; } -int main(int argc, char *argv[]) { +static int run(int argc, char *argv[]) { static const Verb verbs[] = { { "help", VERB_ANY, VERB_ANY, 0, help }, @@ -454,24 +456,19 @@ int main(int argc, char *argv[]) { r = parse_argv(argc, argv); if (r <= 0) - goto finish; + return r; if (detect_container() > 0) { log_error("Marking a boot is not supported in containers."); - r = -EOPNOTSUPP; - goto finish; + return -EOPNOTSUPP; } if (!is_efi_boot()) { log_error("Marking a boot is only supported on EFI systems."); - r = -EOPNOTSUPP; - goto finish; + return -EOPNOTSUPP; } - r = dispatch_verb(argc, argv, verbs, NULL); - -finish: - free(arg_path); - - return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; + return dispatch_verb(argc, argv, verbs, NULL); } + +DEFINE_MAIN_FUNCTION(run); -- 2.47.3