diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2016-12-16 16:03:31 -0500 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2016-12-17 17:26:59 -0500 |
commit | 3a8a0ace2cea130beccf20b83636bda1c2536578 (patch) | |
tree | 73b168034e0317ee392bc116c38c1f2a1e1f5f84 /src/debug-generator | |
parent | Use SPECIAL_DEFAULT_TARGET consistently (diff) | |
download | systemd-3a8a0ace2cea130beccf20b83636bda1c2536578.tar.gz systemd-3a8a0ace2cea130beccf20b83636bda1c2536578.tar.bz2 systemd-3a8a0ace2cea130beccf20b83636bda1c2536578.zip |
debug-generator: simplify handling of arg_default_unit
Also free the allocated memory before exiting.
Diffstat (limited to 'src/debug-generator')
-rw-r--r-- | src/debug-generator/debug-generator.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/debug-generator/debug-generator.c b/src/debug-generator/debug-generator.c index 1ee347135..28ebe36b3 100644 --- a/src/debug-generator/debug-generator.c +++ b/src/debug-generator/debug-generator.c @@ -135,8 +135,9 @@ static int generate_wants_symlinks(void) { STRV_FOREACH(u, arg_wants) { _cleanup_free_ char *p = NULL, *f = NULL; + const char *target = arg_default_unit ?: SPECIAL_DEFAULT_TARGET; - p = strjoin(arg_dest, "/", arg_default_unit, ".wants/", *u); + p = strjoin(arg_dest, "/", target, ".wants/", *u); if (!p) return log_oom(); @@ -172,12 +173,6 @@ int main(int argc, char *argv[]) { umask(0022); - r = free_and_strdup(&arg_default_unit, SPECIAL_DEFAULT_TARGET); - if (r < 0) { - log_error_errno(r, "Failed to set default unit %s: %m", SPECIAL_DEFAULT_TARGET); - goto finish; - } - r = parse_proc_cmdline(parse_proc_cmdline_item, NULL, false); if (r < 0) log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m"); @@ -197,6 +192,7 @@ int main(int argc, char *argv[]) { r = q; finish: - return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; + arg_default_unit = mfree(arg_default_unit); + return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; } |