diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-11-20 18:24:47 +0900 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-11-20 18:40:02 +0100 |
commit | c3d6fb26ed6fc707b4afab955000b5e6c1f89820 (patch) | |
tree | d1e4b62d6dac711c090dc8c7c96e04c11f336131 /src | |
parent | f66da783fa544e4a4cc5cd48fe49f0cf5adadcfb (diff) | |
download | systemd-c3d6fb26ed6fc707b4afab955000b5e6c1f89820.tar.gz |
modules-load: use static destructor and DEFINE_MAIN_FUNCTION() macro
Diffstat (limited to 'src')
-rw-r--r-- | src/modules-load/modules-load.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/modules-load/modules-load.c b/src/modules-load/modules-load.c index acb39516eb..36bda3433f 100644 --- a/src/modules-load/modules-load.c +++ b/src/modules-load/modules-load.c @@ -12,6 +12,7 @@ #include "fd-util.h" #include "fileio.h" #include "log.h" +#include "main-func.h" #include "module-util.h" #include "pretty-print.h" #include "proc-cmdline.h" @@ -20,9 +21,10 @@ #include "util.h" static char **arg_proc_cmdline_modules = NULL; - static const char conf_file_dirs[] = CONF_PATHS_NULSTR("modules-load.d"); +STATIC_DESTRUCTOR_REGISTER(arg_proc_cmdline_modules, strv_freep); + static void systemd_kmod_log(void *data, int priority, const char *file, int line, const char *fn, const char *format, va_list args) { @@ -158,13 +160,13 @@ static int parse_argv(int argc, char *argv[]) { return 1; } -int main(int argc, char *argv[]) { - int r, k; +static int run(int argc, char *argv[]) { _cleanup_(kmod_unrefp) struct kmod_ctx *ctx = NULL; + int r, k; r = parse_argv(argc, argv); if (r <= 0) - return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; + return r; log_setup_service(); @@ -177,7 +179,7 @@ int main(int argc, char *argv[]) { ctx = kmod_new(NULL, NULL); if (!ctx) { log_error("Failed to allocate memory for kmod."); - goto finish; + return -ENOMEM; } kmod_load_resources(ctx); @@ -209,7 +211,7 @@ int main(int argc, char *argv[]) { log_error_errno(k, "Failed to enumerate modules-load.d files: %m"); if (r == 0) r = k; - goto finish; + return r; } STRV_FOREACH(fn, files) { @@ -219,8 +221,7 @@ int main(int argc, char *argv[]) { } } -finish: - strv_free(arg_proc_cmdline_modules); - - return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; + return r; } + +DEFINE_MAIN_FUNCTION(run); |