summaryrefslogtreecommitdiff
path: root/src/debug-generator/debug-generator.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-12-16 16:03:31 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-12-17 17:26:59 -0500
commit3a8a0ace2cea130beccf20b83636bda1c2536578 (patch)
tree73b168034e0317ee392bc116c38c1f2a1e1f5f84 /src/debug-generator/debug-generator.c
parent075dafd2045728fef61a99e876400781ab5bb373 (diff)
debug-generator: simplify handling of arg_default_unit
Also free the allocated memory before exiting.
Diffstat (limited to 'src/debug-generator/debug-generator.c')
-rw-r--r--src/debug-generator/debug-generator.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/debug-generator/debug-generator.c b/src/debug-generator/debug-generator.c
index 1ee3471355..28ebe36b38 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;
}