From 7a44c7e31fdeebce82189b134221297919104e7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 4 Dec 2018 11:49:42 +0100 Subject: generators: define custom main func definer and use it where applicable There should be no functional difference, except that the error message is changd from "three or no arguments" to "zero or three arguments". Somehow the inverted form always seemed strange. umask() call is also dropped from run-generator. I think it wasn't dropped in 053254e3cb215df3b8c905bc39b920f8817e1c7d because the run generator was merged around the same time. --- src/debug-generator/debug-generator.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'src/debug-generator') diff --git a/src/debug-generator/debug-generator.c b/src/debug-generator/debug-generator.c index 2615aa189d..fa4ca57bbf 100644 --- a/src/debug-generator/debug-generator.c +++ b/src/debug-generator/debug-generator.c @@ -2,7 +2,6 @@ #include "alloc-util.h" #include "generator.h" -#include "main-func.h" #include "mkdir.h" #include "parse-util.h" #include "proc-cmdline.h" @@ -12,8 +11,8 @@ #include "unit-name.h" #include "util.h" +static const char *arg_dest = NULL; static char *arg_default_unit = NULL; -static const char *arg_dest = "/tmp"; static char **arg_mask = NULL; static char **arg_wants = NULL; static bool arg_debug_shell = false; @@ -142,17 +141,10 @@ static int generate_wants_symlinks(void) { return r; } -static int run(int argc, char *argv[]) { +static int run(const char *dest, const char *dest_early, const char *dest_late) { int r, q; - log_setup_generator(); - - if (argc > 1 && argc != 4) - return log_error_errno(SYNTHETIC_ERRNO(EINVAL), - "This program takes three or no arguments."); - - if (argc > 1) - arg_dest = argv[2]; + assert_se(arg_dest = dest_early); r = proc_cmdline_parse(parse_proc_cmdline_item, NULL, PROC_CMDLINE_RD_STRICT | PROC_CMDLINE_STRIP_RD_PREFIX); if (r < 0) @@ -170,4 +162,4 @@ static int run(int argc, char *argv[]) { return r < 0 ? r : q; } -DEFINE_MAIN_FUNCTION(run); +DEFINE_MAIN_GENERATOR_FUNCTION(run); -- cgit v1.2.1