From: Zbigniew Jędrzejewski-Szmek Date: Fri, 16 Dec 2016 21:03:31 +0000 (-0500) Subject: debug-generator: simplify handling of arg_default_unit X-Git-Tag: v233~310^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3a8a0ace2cea130beccf20b83636bda1c2536578;p=thirdparty%2Fsystemd.git debug-generator: simplify handling of arg_default_unit Also free the allocated memory before exiting. --- diff --git a/src/debug-generator/debug-generator.c b/src/debug-generator/debug-generator.c index 1ee3471355c..28ebe36b387 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; }