diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-11-20 18:00:13 +0900 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-11-20 18:40:02 +0100 |
commit | 77182cc65ee853d9278543cff2f517af4c27bac3 (patch) | |
tree | b4d211b01c1585ee47afae95d29fb4e11c67eb1f /src/hibernate-resume | |
parent | a4ef3e4dbb6a03a4d0e0270c637c2fda294275ce (diff) | |
download | systemd-77182cc65ee853d9278543cff2f517af4c27bac3.tar.gz |
hibernate-resume-generator: use static destructor and DEFINE_MAIN_FUNCTION() macro
Diffstat (limited to 'src/hibernate-resume')
-rw-r--r-- | src/hibernate-resume/hibernate-resume-generator.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/hibernate-resume/hibernate-resume-generator.c b/src/hibernate-resume/hibernate-resume-generator.c index fd58720779..64c184558f 100644 --- a/src/hibernate-resume/hibernate-resume-generator.c +++ b/src/hibernate-resume/hibernate-resume-generator.c @@ -7,6 +7,7 @@ #include "fstab-util.h" #include "generator.h" #include "log.h" +#include "main-func.h" #include "mkdir.h" #include "proc-cmdline.h" #include "special.h" @@ -18,6 +19,8 @@ static const char *arg_dest = "/tmp"; static char *arg_resume_device = NULL; static bool arg_noresume = false; +STATIC_DESTRUCTOR_REGISTER(arg_resume_device, freep); + static int parse_proc_cmdline_item(const char *key, const char *value, void *data) { if (streq(key, "resume")) { @@ -66,7 +69,7 @@ static int process_resume(void) { return 0; } -int main(int argc, char *argv[]) { +static int run(int argc, char *argv[]) { int r = 0; log_setup_generator(); @@ -75,7 +78,7 @@ int main(int argc, char *argv[]) { if (argc > 1 && argc != 4) { log_error("This program takes three or no arguments."); - return EXIT_FAILURE; + return -EINVAL; } if (argc > 1) @@ -84,7 +87,7 @@ int main(int argc, char *argv[]) { /* Don't even consider resuming outside of initramfs. */ if (!in_initrd()) { log_debug("Not running in an initrd, quitting."); - return EXIT_SUCCESS; + return 0; } r = proc_cmdline_parse(parse_proc_cmdline_item, NULL, 0); @@ -93,14 +96,10 @@ int main(int argc, char *argv[]) { if (arg_noresume) { log_notice("Found \"noresume\" on the kernel command line, quitting."); - r = 0; - goto finish; + return 0; } - r = process_resume(); - -finish: - free(arg_resume_device); - - return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; + return process_resume(); } + +DEFINE_MAIN_FUNCTION(run); |