From: Zbigniew Jędrzejewski-Szmek Date: Tue, 4 Dec 2018 10:52:26 +0000 (+0100) Subject: gpt-auto-generator: use the new main function definer X-Git-Tag: v240~70^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ec6e959750f10c2916d62801d476907e599f9668;p=thirdparty%2Fsystemd.git gpt-auto-generator: use the new main function definer The first error is now returned. --- diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c index 80e7bb671fb..a6d7bcc7552 100644 --- a/src/gpt-auto-generator/gpt-auto-generator.c +++ b/src/gpt-auto-generator/gpt-auto-generator.c @@ -36,7 +36,7 @@ #include "util.h" #include "virt.h" -static const char *arg_dest = "/tmp"; +static const char *arg_dest = NULL; static bool arg_enabled = true; static bool arg_root_enabled = true; static bool arg_root_rw = false; @@ -668,22 +668,14 @@ static int add_mounts(void) { return enumerate_partitions(devno); } -int main(int argc, char *argv[]) { +static int run(const char *dest, const char *dest_early, const char *dest_late) { int r, k; - log_setup_generator(); - - if (argc > 1 && argc != 4) { - log_error("This program takes three or no arguments."); - return EXIT_FAILURE; - } - - if (argc > 1) - arg_dest = argv[3]; + assert_se(arg_dest = dest_late); if (detect_container() > 0) { log_debug("In a container, exiting."); - return EXIT_SUCCESS; + return 0; } r = proc_cmdline_parse(parse_proc_cmdline_item, NULL, 0); @@ -692,19 +684,19 @@ int main(int argc, char *argv[]) { if (!arg_enabled) { log_debug("Disabled, exiting."); - return EXIT_SUCCESS; + return 0; } if (arg_root_enabled) r = add_root_mount(); - else - r = 0; if (!in_initrd()) { k = add_mounts(); - if (k < 0) + if (r >= 0) r = k; } - return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; + return r; } + +DEFINE_MAIN_GENERATOR_FUNCTION(run);