diff options
author | Scott Anderson <ascent12@hotmail.com> | 2017-05-02 13:00:25 +1200 |
---|---|---|
committer | Scott Anderson <ascent12@hotmail.com> | 2017-05-02 13:00:25 +1200 |
commit | 562d43a5ecc2f7f4af3ed6924d52f87e3cc018c2 (patch) | |
tree | f96f517d49fadfb917e16a10744f9204a13b22c3 /backend/drm/session.c | |
parent | 41a82fd2fcd4759fbb522ffe7e8f6667d6ab945a (diff) |
Changed logging.
Diffstat (limited to 'backend/drm/session.c')
-rw-r--r-- | backend/drm/session.c | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/backend/drm/session.c b/backend/drm/session.c index 285f31b9..49223334 100644 --- a/backend/drm/session.c +++ b/backend/drm/session.c @@ -4,6 +4,7 @@ #include <stdbool.h> #include <stdlib.h> #include <string.h> +#include <errno.h> #include <systemd/sd-bus.h> #include <systemd/sd-login.h> #include <unistd.h> @@ -13,6 +14,7 @@ #include "backend/drm/backend.h" #include "backend/drm/session.h" +#include "common/log.h" int wlr_session_take_device(struct wlr_session *restrict session, const char *restrict path, @@ -25,7 +27,7 @@ int wlr_session_take_device(struct wlr_session *restrict session, struct stat st; if (stat(path, &st) < 0) { - fprintf(stderr, "Failed to stat '%s'\n", path); + wlr_log(L_ERROR, "Failed to stat '%s'", path); return -1; } @@ -37,20 +39,26 @@ int wlr_session_take_device(struct wlr_session *restrict session, &error, &msg, "uu", major(st.st_rdev), minor(st.st_rdev)); if (ret < 0) { - fprintf(stderr, "%s\n", error.message); + wlr_log(L_ERROR, "Failed to take device '%s': %s", path, error.message); goto error; } int paused = 0; ret = sd_bus_message_read(msg, "hb", &fd, &paused); if (ret < 0) { - fprintf(stderr, "%s\n", strerror(-ret)); + wlr_log(L_ERROR, "Failed to parse DBus response for '%s': %s", + path, strerror(-ret)); goto error; } // The original fd seem to be closed when the message is freed // so we just clone it. fd = fcntl(fd, F_DUPFD_CLOEXEC, 0); + if (fd == -1) { + wlr_log(L_ERROR, "Failed to clone file descriptor for '%s': %s", + path, strerror(errno)); + goto error; + } if (paused_out) *paused_out = paused; @@ -69,7 +77,7 @@ void wlr_session_release_device(struct wlr_session *session, int fd) struct stat st; if (fstat(fd, &st) < 0) { - fprintf(stderr, "Could not stat fd %d\n", fd); + wlr_log(L_ERROR, "Failed to stat device '%d'", fd); return; } @@ -80,9 +88,8 @@ void wlr_session_release_device(struct wlr_session *session, int fd) "ReleaseDevice", &error, &msg, "uu", major(st.st_rdev), minor(st.st_rdev)); - if (ret < 0) { - /* Log something */; - } + if (ret < 0) + wlr_log(L_ERROR, "Failed to release device '%d'", fd); sd_bus_error_free(&error); sd_bus_message_unref(msg); @@ -101,9 +108,8 @@ static bool session_activate(struct wlr_session *session) "Activate", &error, &msg, ""); - if (ret < 0) { - fprintf(stderr, "%s\n", error.message); - } + if (ret < 0) + wlr_log(L_ERROR, "Failed to activate session"); sd_bus_error_free(&error); sd_bus_message_unref(msg); @@ -123,9 +129,8 @@ static bool take_control(struct wlr_session *session) "TakeControl", &error, &msg, "b", false); - if (ret < 0) { - /* Log something */; - } + if (ret < 0) + wlr_log(L_ERROR, "Failed to take control of session"); sd_bus_error_free(&error); sd_bus_message_unref(msg); @@ -145,9 +150,8 @@ static void release_control(struct wlr_session *session) "ReleaseControl", &error, &msg, ""); - if (ret < 0) { - /* Log something */; - } + if (ret < 0) + wlr_log(L_ERROR, "Failed to release control of session"); sd_bus_error_free(&error); sd_bus_message_unref(msg); @@ -169,13 +173,13 @@ bool wlr_session_start(struct wlr_session *session) ret = sd_pid_get_session(getpid(), &session->id); if (ret < 0) { - fprintf(stderr, "Could not get session\n"); + wlr_log(L_ERROR, "Failed to get session id: %s", strerror(-ret)); goto error; } ret = sd_session_get_seat(session->id, &session->seat); if (ret < 0) { - fprintf(stderr, "Could not get seat\n"); + wlr_log(L_ERROR, "Failed to get seat id: %s", strerror(-ret)); goto error; } @@ -192,19 +196,15 @@ bool wlr_session_start(struct wlr_session *session) ret = sd_bus_open_system(&session->bus); if (ret < 0) { - fprintf(stderr, "Could not open bus\n"); + wlr_log(L_ERROR, "Failed to open DBus connection: %s", strerror(-ret)); goto error; } - if (!session_activate(session)) { - fprintf(stderr, "Could not activate session\n"); + if (!session_activate(session)) goto error_bus; - } - if (!take_control(session)) { - fprintf(stderr, "Could not take control of session\n"); + if (!take_control(session)) goto error_bus; - } return true; |