summaryrefslogtreecommitdiff
path: root/src/machine
diff options
context:
space:
mode:
Diffstat (limited to 'src/machine')
-rw-r--r--src/machine/machine.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/machine/machine.c b/src/machine/machine.c
index c08a645814..acb86c1a83 100644
--- a/src/machine/machine.c
+++ b/src/machine/machine.c
@@ -17,6 +17,7 @@
#include "fd-util.h"
#include "fileio.h"
#include "format-util.h"
+#include "fs-util.h"
#include "hashmap.h"
#include "machine-dbus.h"
#include "machine.h"
@@ -107,7 +108,7 @@ Machine* machine_free(Machine *m) {
}
int machine_save(Machine *m) {
- _cleanup_free_ char *temp_path = NULL;
+ _cleanup_(unlink_and_freep) char *temp_path = NULL;
_cleanup_fclose_ FILE *f = NULL;
int r;
@@ -211,6 +212,8 @@ int machine_save(Machine *m) {
goto fail;
}
+ temp_path = mfree(temp_path);
+
if (m->unit) {
char *sl;
@@ -226,9 +229,6 @@ int machine_save(Machine *m) {
fail:
(void) unlink(m->state_file);
- if (temp_path)
- (void) unlink(temp_path);
-
return log_error_errno(r, "Failed to save machine data %s: %m", m->state_file);
}