summaryrefslogtreecommitdiff
path: root/src/login
diff options
context:
space:
mode:
Diffstat (limited to 'src/login')
-rw-r--r--src/login/logind-dbus.c4
-rw-r--r--src/login/logind-inhibit.c7
-rw-r--r--src/login/logind-seat.c8
-rw-r--r--src/login/logind-session.c7
-rw-r--r--src/login/logind-user.c6
5 files changed, 13 insertions, 19 deletions
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index 7024bba82d..1c151021c7 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -2083,7 +2083,7 @@ void manager_load_scheduled_shutdown(Manager *m) {
}
static int update_schedule_file(Manager *m) {
- _cleanup_free_ char *temp_path = NULL;
+ _cleanup_(unlink_and_freep) char *temp_path = NULL;
_cleanup_fclose_ FILE *f = NULL;
int r;
@@ -2123,10 +2123,10 @@ static int update_schedule_file(Manager *m) {
goto fail;
}
+ temp_path = mfree(temp_path);
return 0;
fail:
- (void) unlink(temp_path);
(void) unlink(SHUTDOWN_SCHEDULE_FILE);
return log_error_errno(r, "Failed to write information about scheduled shutdowns: %m");
diff --git a/src/login/logind-inhibit.c b/src/login/logind-inhibit.c
index 95b11ed9e7..8735538d20 100644
--- a/src/login/logind-inhibit.c
+++ b/src/login/logind-inhibit.c
@@ -14,6 +14,7 @@
#include "fd-util.h"
#include "fileio.h"
#include "format-util.h"
+#include "fs-util.h"
#include "io-util.h"
#include "logind-dbus.h"
#include "logind-inhibit.h"
@@ -83,7 +84,7 @@ Inhibitor* inhibitor_free(Inhibitor *i) {
}
static int inhibitor_save(Inhibitor *i) {
- _cleanup_free_ char *temp_path = NULL;
+ _cleanup_(unlink_and_freep) char *temp_path = NULL;
_cleanup_fclose_ FILE *f = NULL;
int r;
@@ -146,14 +147,12 @@ static int inhibitor_save(Inhibitor *i) {
goto fail;
}
+ temp_path = mfree(temp_path);
return 0;
fail:
(void) unlink(i->state_file);
- if (temp_path)
- (void) unlink(temp_path);
-
return log_error_errno(r, "Failed to save inhibit data %s: %m", i->state_file);
}
diff --git a/src/login/logind-seat.c b/src/login/logind-seat.c
index 65323f6c92..c92e59ae51 100644
--- a/src/login/logind-seat.c
+++ b/src/login/logind-seat.c
@@ -13,6 +13,7 @@
#include "fd-util.h"
#include "fileio.h"
#include "format-util.h"
+#include "fs-util.h"
#include "logind-seat-dbus.h"
#include "logind-seat.h"
#include "logind-session-dbus.h"
@@ -81,7 +82,7 @@ Seat* seat_free(Seat *s) {
}
int seat_save(Seat *s) {
- _cleanup_free_ char *temp_path = NULL;
+ _cleanup_(unlink_and_freep) char *temp_path = NULL;
_cleanup_fclose_ FILE *f = NULL;
int r;
@@ -146,14 +147,11 @@ int seat_save(Seat *s) {
goto fail;
}
+ temp_path = mfree(temp_path);
return 0;
fail:
(void) unlink(s->state_file);
-
- if (temp_path)
- (void) unlink(temp_path);
-
return log_error_errno(r, "Failed to save seat data %s: %m", s->state_file);
}
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index 63b6d012ee..1daa102071 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -21,6 +21,7 @@
#include "fd-util.h"
#include "fileio.h"
#include "format-util.h"
+#include "fs-util.h"
#include "io-util.h"
#include "logind-dbus.h"
#include "logind-seat-dbus.h"
@@ -202,7 +203,7 @@ static void session_save_devices(Session *s, FILE *f) {
}
int session_save(Session *s) {
- _cleanup_free_ char *temp_path = NULL;
+ _cleanup_(unlink_and_freep) char *temp_path = NULL;
_cleanup_fclose_ FILE *f = NULL;
int r;
@@ -349,14 +350,12 @@ int session_save(Session *s) {
goto fail;
}
+ temp_path = mfree(temp_path);
return 0;
fail:
(void) unlink(s->state_file);
- if (temp_path)
- (void) unlink(temp_path);
-
return log_error_errno(r, "Failed to save session data %s: %m", s->state_file);
}
diff --git a/src/login/logind-user.c b/src/login/logind-user.c
index 5680a300f3..3920467f44 100644
--- a/src/login/logind-user.c
+++ b/src/login/logind-user.c
@@ -140,7 +140,7 @@ User *user_free(User *u) {
}
static int user_save_internal(User *u) {
- _cleanup_free_ char *temp_path = NULL;
+ _cleanup_(unlink_and_freep) char *temp_path = NULL;
_cleanup_fclose_ FILE *f = NULL;
int r;
@@ -282,14 +282,12 @@ static int user_save_internal(User *u) {
goto fail;
}
+ temp_path = mfree(temp_path);
return 0;
fail:
(void) unlink(u->state_file);
- if (temp_path)
- (void) unlink(temp_path);
-
return log_error_errno(r, "Failed to save user data %s: %m", u->state_file);
}