machine: minor modernizations
This commit is contained in:
parent
1b99214789
commit
034753ac13
|
@ -176,12 +176,13 @@ int machine_save(Machine *m) {
|
||||||
m->timestamp.realtime,
|
m->timestamp.realtime,
|
||||||
m->timestamp.monotonic);
|
m->timestamp.monotonic);
|
||||||
|
|
||||||
fflush(f);
|
r = fflush_and_check(f);
|
||||||
|
if (r < 0)
|
||||||
|
goto finish;
|
||||||
|
|
||||||
if (ferror(f) || rename(temp_path, m->state_file) < 0) {
|
if (rename(temp_path, m->state_file) < 0) {
|
||||||
r = -errno;
|
r = -errno;
|
||||||
unlink(m->state_file);
|
goto finish;
|
||||||
unlink(temp_path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m->unit) {
|
if (m->unit) {
|
||||||
|
@ -195,8 +196,12 @@ int machine_save(Machine *m) {
|
||||||
}
|
}
|
||||||
|
|
||||||
finish:
|
finish:
|
||||||
if (r < 0)
|
if (r < 0) {
|
||||||
|
if (temp_path)
|
||||||
|
unlink(temp_path);
|
||||||
|
|
||||||
log_error("Failed to save machine data %s: %s", m->state_file, strerror(-r));
|
log_error("Failed to save machine data %s: %s", m->state_file, strerror(-r));
|
||||||
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue