From: Lennart Poettering Date: Sun, 24 Dec 2017 15:51:28 +0000 (+0100) Subject: rc-local-generator: minor modernizations X-Git-Tag: v237~174^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=449f4fc2c1a62340e858c016607c7d3ad684b03f;p=platform%2Fupstream%2Fsystemd.git rc-local-generator: minor modernizations --- diff --git a/src/rc-local-generator/rc-local-generator.c b/src/rc-local-generator/rc-local-generator.c index 196947c..b10b18e 100644 --- a/src/rc-local-generator/rc-local-generator.c +++ b/src/rc-local-generator/rc-local-generator.c @@ -23,7 +23,6 @@ #include #include -#include "alloc-util.h" #include "log.h" #include "mkdir.h" #include "string-util.h" @@ -32,21 +31,16 @@ static const char *arg_dest = "/tmp"; static int add_symlink(const char *service, const char *where) { - _cleanup_free_ char *from = NULL, *to = NULL; + const char *from, *to; int r; assert(service); assert(where); - from = strjoin(SYSTEM_DATA_UNIT_PATH, "/", service); - if (!from) - return log_oom(); + from = strjoina(SYSTEM_DATA_UNIT_PATH "/", service); + to = strjoina(arg_dest, "/", where, ".wants/", service); - to = strjoin(arg_dest, "/", where, ".wants/", service); - if (!to) - return log_oom(); - - mkdir_parents_label(to, 0755); + (void) mkdir_parents_label(to, 0755); r = symlink(from, to); if (r < 0) { @@ -60,7 +54,7 @@ static int add_symlink(const char *service, const char *where) { } int main(int argc, char *argv[]) { - int r = EXIT_SUCCESS; + int ret = EXIT_SUCCESS; if (argc > 1 && argc != 4) { log_error("This program takes three or no arguments."); @@ -80,15 +74,15 @@ int main(int argc, char *argv[]) { log_debug("Automatically adding rc-local.service."); if (add_symlink("rc-local.service", "multi-user.target") < 0) - r = EXIT_FAILURE; + ret = EXIT_FAILURE; } if (access(RC_LOCAL_SCRIPT_PATH_STOP, X_OK) >= 0) { log_debug("Automatically adding halt-local.service."); if (add_symlink("halt-local.service", "final.target") < 0) - r = EXIT_FAILURE; + ret = EXIT_FAILURE; } - return r; + return ret; }