From ec6e959750f10c2916d62801d476907e599f9668 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 4 Dec 2018 11:52:26 +0100 Subject: [PATCH] gpt-auto-generator: use the new main function definer The first error is now returned. --- src/gpt-auto-generator/gpt-auto-generator.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c index 80e7bb6..a6d7bcc 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); -- 2.7.4