1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-02 19:21:53 +03:00

bless-boot: use static destructor and DEFINE_MAIN_FUNCTION() macro

This commit is contained in:
Yu Watanabe 2018-11-20 17:39:25 +09:00 committed by Zbigniew Jędrzejewski-Szmek
parent 3a40f366b2
commit a8a7e5fcf2

View File

@ -18,6 +18,8 @@
static char *arg_path = NULL; static char *arg_path = NULL;
STATIC_DESTRUCTOR_REGISTER(arg_path, freep);
static int help(int argc, char *argv[], void *userdata) { static int help(int argc, char *argv[], void *userdata) {
printf("%s [COMMAND] [OPTIONS...]\n" printf("%s [COMMAND] [OPTIONS...]\n"
@ -436,7 +438,7 @@ exists:
return 0; return 0;
} }
int main(int argc, char *argv[]) { static int run(int argc, char *argv[]) {
static const Verb verbs[] = { static const Verb verbs[] = {
{ "help", VERB_ANY, VERB_ANY, 0, help }, { "help", VERB_ANY, VERB_ANY, 0, help },
@ -454,24 +456,19 @@ int main(int argc, char *argv[]) {
r = parse_argv(argc, argv); r = parse_argv(argc, argv);
if (r <= 0) if (r <= 0)
goto finish; return r;
if (detect_container() > 0) { if (detect_container() > 0) {
log_error("Marking a boot is not supported in containers."); log_error("Marking a boot is not supported in containers.");
r = -EOPNOTSUPP; return -EOPNOTSUPP;
goto finish;
} }
if (!is_efi_boot()) { if (!is_efi_boot()) {
log_error("Marking a boot is only supported on EFI systems."); log_error("Marking a boot is only supported on EFI systems.");
r = -EOPNOTSUPP; return -EOPNOTSUPP;
goto finish;
} }
r = dispatch_verb(argc, argv, verbs, NULL); return dispatch_verb(argc, argv, verbs, NULL);
finish:
free(arg_path);
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
} }
DEFINE_MAIN_FUNCTION(run);