diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-07-29 20:31:07 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-07-29 20:31:07 +0200 |
commit | dacd6cee76a08331b8c8616c5f30f70ee49aa2f9 (patch) | |
tree | 7a7d73f2ac1f909255361781ca923365b6c9b7c3 /src/login/logind-dbus.c | |
parent | 8388607b5851574e50a6e65db98135b793b08910 (diff) |
tree-wide: port everything over to fflush_and_check()
Some places invoked fflush() directly with their own manual error
checking, let's unify all that by using fflush_and_check().
This also unifies the general error paths of fflush()+rename() file
writers.
Diffstat (limited to 'src/login/logind-dbus.c')
-rw-r--r-- | src/login/logind-dbus.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index e6371ff04d..397952e7e5 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -1816,17 +1816,22 @@ static int update_schedule_file(Manager *m) { if (!isempty(m->wall_message)) fprintf(f, "WALL_MESSAGE=%s\n", t); - (void) fflush_and_check(f); + r = fflush_and_check(f); + if (r < 0) + goto fail; - if (ferror(f) || rename(temp_path, "/run/systemd/shutdown/scheduled") < 0) { - log_error_errno(errno, "Failed to write information about scheduled shutdowns: %m"); + if (rename(temp_path, "/run/systemd/shutdown/scheduled") < 0) { r = -errno; - - (void) unlink(temp_path); - (void) unlink("/run/systemd/shutdown/scheduled"); + goto fail; } - return r; + return 0; + +fail: + (void) unlink(temp_path); + (void) unlink("/run/systemd/shutdown/scheduled"); + + return log_error_errno(r, "Failed to write information about scheduled shutdowns: %m"); } static int manager_scheduled_shutdown_handler( |