summaryrefslogtreecommitdiff
path: root/src/login
diff options
context:
space:
mode:
Diffstat (limited to 'src/login')
-rw-r--r--src/login/logind-button.c14
-rw-r--r--src/login/logind-dbus.c3
-rw-r--r--src/login/logind-inhibit.c3
-rw-r--r--src/login/logind-session.c3
-rw-r--r--src/login/logind-user.c3
5 files changed, 8 insertions, 18 deletions
diff --git a/src/login/logind-button.c b/src/login/logind-button.c
index 210b889c4f..f40e35a8cb 100644
--- a/src/login/logind-button.c
+++ b/src/login/logind-button.c
@@ -66,12 +66,11 @@ void button_free(Button *b) {
sd_event_source_unref(b->io_event_source);
sd_event_source_unref(b->check_event_source);
- if (b->fd >= 0) {
+ if (b->fd >= 0)
/* If the device has been unplugged close() returns
* ENODEV, let's ignore this, hence we don't use
* safe_close() */
(void) close(b->fd);
- }
free(b->name);
free(b->seat);
@@ -239,10 +238,7 @@ int button_open(Button *b) {
assert(b);
- if (b->fd >= 0) {
- close(b->fd);
- b->fd = -1;
- }
+ b->fd = safe_close(b->fd);
p = strjoina("/dev/input/", b->name);
@@ -251,8 +247,7 @@ int button_open(Button *b) {
return log_warning_errno(errno, "Failed to open %s: %m", b->name);
if (ioctl(b->fd, EVIOCGNAME(sizeof(name)), name) < 0) {
- log_error_errno(errno, "Failed to get input name: %m");
- r = -errno;
+ r = log_error_errno(errno, "Failed to get input name: %m");
goto fail;
}
@@ -267,8 +262,7 @@ int button_open(Button *b) {
return 0;
fail:
- close(b->fd);
- b->fd = -1;
+ b->fd = safe_close(b->fd);
return r;
}
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index b6fa50aa52..050d0252ad 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -1987,8 +1987,7 @@ static int method_cancel_scheduled_shutdown(sd_bus_message *message, void *userd
m->scheduled_shutdown_timeout_source = sd_event_source_unref(m->scheduled_shutdown_timeout_source);
m->wall_message_timeout_source = sd_event_source_unref(m->wall_message_timeout_source);
m->nologin_timeout_source = sd_event_source_unref(m->nologin_timeout_source);
- free(m->scheduled_shutdown_type);
- m->scheduled_shutdown_type = NULL;
+ m->scheduled_shutdown_type = mfree(m->scheduled_shutdown_type);
m->scheduled_shutdown_timeout = 0;
if (m->unlink_nologin) {
diff --git a/src/login/logind-inhibit.c b/src/login/logind-inhibit.c
index cfae186edd..0c9c1e5e97 100644
--- a/src/login/logind-inhibit.c
+++ b/src/login/logind-inhibit.c
@@ -333,8 +333,7 @@ void inhibitor_remove_fifo(Inhibitor *i) {
if (i->fifo_path) {
unlink(i->fifo_path);
- free(i->fifo_path);
- i->fifo_path = NULL;
+ i->fifo_path = mfree(i->fifo_path);
}
}
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index 92a6027a7e..d2c5a29801 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -913,8 +913,7 @@ static void session_remove_fifo(Session *s) {
if (s->fifo_path) {
unlink(s->fifo_path);
- free(s->fifo_path);
- s->fifo_path = NULL;
+ s->fifo_path = mfree(s->fifo_path);
}
}
diff --git a/src/login/logind-user.c b/src/login/logind-user.c
index 5d8a7571cd..f2c89e3653 100644
--- a/src/login/logind-user.c
+++ b/src/login/logind-user.c
@@ -560,8 +560,7 @@ static int user_remove_runtime_path(User *u) {
if (r < 0)
log_error_errno(r, "Failed to remove runtime directory %s: %m", u->runtime_path);
- free(u->runtime_path);
- u->runtime_path = NULL;
+ u->runtime_path = mfree(u->runtime_path);
return r;
}