summaryrefslogtreecommitdiff
path: root/src/login
diff options
context:
space:
mode:
Diffstat (limited to 'src/login')
-rw-r--r--src/login/logind-button.c6
-rw-r--r--src/login/logind-session.c21
-rw-r--r--src/login/logind-user.c12
-rw-r--r--src/login/logind.c18
-rw-r--r--src/login/multi-seat-x.c4
5 files changed, 21 insertions, 40 deletions
diff --git a/src/login/logind-button.c b/src/login/logind-button.c
index 62e0c3dbba..d023294a59 100644
--- a/src/login/logind-button.c
+++ b/src/login/logind-button.c
@@ -107,10 +107,8 @@ int button_open(Button *b) {
}
p = strappend("/dev/input/", b->name);
- if (!p) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (!p)
+ return log_oom();
b->fd = open(p, O_RDWR|O_CLOEXEC|O_NOCTTY|O_NONBLOCK);
free(p);
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index a43ecad2b1..16d4955d5d 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -374,10 +374,8 @@ static int session_link_x11_socket(Session *s) {
k = strspn(s->display+1, "0123456789");
f = new(char, sizeof("/tmp/.X11-unix/X") + k);
- if (!f) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (!f)
+ return log_oom();
c = stpcpy(f, "/tmp/.X11-unix/X");
memcpy(c, s->display+1, k);
@@ -395,9 +393,8 @@ static int session_link_x11_socket(Session *s) {
t = strappend(s->user->runtime_path, "/X11-display");
if (!t) {
- log_error("Out of memory.");
free(f);
- return -ENOMEM;
+ return log_oom();
}
if (link(f, t) < 0) {
@@ -468,10 +465,8 @@ static int session_create_cgroup(Session *s) {
assert(s->user->cgroup_path);
if (!s->cgroup_path) {
- if (asprintf(&p, "%s/%s", s->user->cgroup_path, s->id) < 0) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (asprintf(&p, "%s/%s", s->user->cgroup_path, s->id) < 0)
+ return log_oom();
} else
p = s->cgroup_path;
@@ -669,10 +664,8 @@ static int session_unlink_x11_socket(Session *s) {
s->user->display = NULL;
t = strappend(s->user->runtime_path, "/X11-display");
- if (!t) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (!t)
+ return log_oom();
r = unlink(t);
free(t);
diff --git a/src/login/logind-user.c b/src/login/logind-user.c
index fca68159a7..aa9c3f1a31 100644
--- a/src/login/logind-user.c
+++ b/src/login/logind-user.c
@@ -259,10 +259,8 @@ static int user_mkdir_runtime_path(User *u) {
}
if (!u->runtime_path) {
- if (asprintf(&p, "/run/user/%lu", (unsigned long) u->uid) < 0) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (asprintf(&p, "/run/user/%lu", (unsigned long) u->uid) < 0)
+ return log_oom();
} else
p = u->runtime_path;
@@ -286,10 +284,8 @@ static int user_create_cgroup(User *u) {
assert(u);
if (!u->cgroup_path) {
- if (asprintf(&p, "%s/%s", u->manager->cgroup_path, u->name) < 0) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (asprintf(&p, "%s/%s", u->manager->cgroup_path, u->name) < 0)
+ return log_oom();
} else
p = u->cgroup_path;
diff --git a/src/login/logind.c b/src/login/logind.c
index 1cfb7fa9ac..bae9a95f38 100644
--- a/src/login/logind.c
+++ b/src/login/logind.c
@@ -1020,10 +1020,8 @@ int manager_get_session_by_cgroup(Manager *m, const char *cgroup, Session **sess
}
p = strdup(cgroup);
- if (!p) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (!p)
+ return log_oom();
for (;;) {
char *e;
@@ -1061,10 +1059,8 @@ int manager_get_user_by_cgroup(Manager *m, const char *cgroup, User **user) {
}
p = strdup(cgroup);
- if (!p) {
- log_error("Out of memory.");
- return -ENOMEM;
- }
+ if (!p)
+ return log_oom();
for (;;) {
char *e;
@@ -1176,8 +1172,7 @@ static int manager_connect_bus(Manager *m) {
!dbus_connection_register_fallback(m->bus, "/org/freedesktop/login1/session", &bus_session_vtable, m) ||
!dbus_connection_register_fallback(m->bus, "/org/freedesktop/login1/user", &bus_user_vtable, m) ||
!dbus_connection_add_filter(m->bus, bus_message_filter, m, NULL)) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto fail;
}
@@ -1611,8 +1606,7 @@ int main(int argc, char *argv[]) {
m = manager_new();
if (!m) {
- log_error("Out of memory.");
- r = -ENOMEM;
+ r = log_oom();
goto finish;
}
diff --git a/src/login/multi-seat-x.c b/src/login/multi-seat-x.c
index a1fab86f6a..59f70882d4 100644
--- a/src/login/multi-seat-x.c
+++ b/src/login/multi-seat-x.c
@@ -97,7 +97,7 @@ int main(int argc, char *argv[]) {
device_node = strdup(dn);
if (!device_node) {
udev_device_unref(d);
- log_error("Out of memory.");
+ log_oom();
goto fail;
}
}
@@ -121,7 +121,7 @@ int main(int argc, char *argv[]) {
path = strappend("/run/systemd/multi-session-x/", seat);
if (!path) {
- log_error("Out of memory.");
+ log_oom();
goto fail;
}