diff --git a/src/shared/generator.c b/src/shared/generator.c index bba8e1eaae..5d019f4f4e 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; }