core: minor simplification

This commit is contained in:
Lennart Poettering 2017-11-23 17:39:25 +01:00
parent fbc5883523
commit 0126c8f3f6

View file

@ -4325,8 +4325,8 @@ int unit_write_settingf(Unit *u, UnitWriteFlags flags, const char *name, const c
} }
int unit_make_transient(Unit *u) { int unit_make_transient(Unit *u) {
_cleanup_free_ char *path = NULL;
FILE *f; FILE *f;
char *path;
assert(u); assert(u);
@ -4342,18 +4342,14 @@ int unit_make_transient(Unit *u) {
RUN_WITH_UMASK(0022) { RUN_WITH_UMASK(0022) {
f = fopen(path, "we"); f = fopen(path, "we");
if (!f) { if (!f)
free(path);
return -errno; return -errno;
}
} }
if (u->transient_file) safe_fclose(u->transient_file);
fclose(u->transient_file);
u->transient_file = f; u->transient_file = f;
free(u->fragment_path); free_and_replace(u->fragment_path, path);
u->fragment_path = path;
u->source_path = mfree(u->source_path); u->source_path = mfree(u->source_path);
u->dropin_paths = strv_free(u->dropin_paths); u->dropin_paths = strv_free(u->dropin_paths);