From: Lennart Poettering Date: Sun, 16 Oct 2022 20:37:26 +0000 (+0200) Subject: generator: modernize generator_open_unit_file() X-Git-Tag: v252-rc2~26 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e8ede6f57e49531a820b5ddc05ddade661b5832c;p=thirdparty%2Fsystemd.git generator: modernize generator_open_unit_file() --- diff --git a/src/shared/generator.c b/src/shared/generator.c index bba8e1eaae5..5d019f4f4e0 100644 --- a/src/shared/generator.c +++ b/src/shared/generator.c @@ -24,36 +24,38 @@ #include "util.h" int generator_open_unit_file( - const char *dest, + const char *dir, const char *source, - const char *name, - FILE **file) { + const char *fn, + FILE **ret) { - _cleanup_free_ char *unit = NULL; + _cleanup_free_ char *p = NULL; FILE *f; int r; - unit = path_join(dest, name); - if (!unit) + assert(dir); + assert(fn); + assert(ret); + + p = path_join(dir, fn); + if (!p) return log_oom(); - r = fopen_unlocked(unit, "wxe", &f); + r = fopen_unlocked(p, "wxe", &f); if (r < 0) { if (source && r == -EEXIST) return log_error_errno(r, - "Failed to create unit file %s, as it already exists. Duplicate entry in %s?", - unit, source); - else - return log_error_errno(r, - "Failed to create unit file %s: %m", - unit); + "Failed to create unit file '%s', as it already exists. Duplicate entry in '%s'?", + p, source); + + return log_error_errno(r, "Failed to create unit file '%s': %m", p); } fprintf(f, "# Automatically generated by %s\n\n", program_invocation_short_name); - *file = f; + *ret = f; return 0; }