aboutsummaryrefslogtreecommitdiff
path: root/backend/session/direct.c
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2018-09-17 22:01:35 +0200
committeremersion <contact@emersion.fr>2018-09-18 11:06:01 +0200
commit07ea98dab91975e5fb97ba7c3db7337e777f7359 (patch)
tree50bde8046efbbde76cd5c500988783c33f2cec4d /backend/session/direct.c
parent6c05f17a256ab2b6135dfe4d7faebb67ca499e57 (diff)
backend/session: add assertions
Diffstat (limited to 'backend/session/direct.c')
-rw-r--r--backend/session/direct.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/backend/session/direct.c b/backend/session/direct.c
index ed7a0c65..0912cd58 100644
--- a/backend/session/direct.c
+++ b/backend/session/direct.c
@@ -1,4 +1,5 @@
#define _POSIX_C_SOURCE 200809L
+#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <linux/input.h>
@@ -33,8 +34,14 @@ struct direct_session {
struct wl_event_source *vt_source;
};
+static struct direct_session *direct_session_from_session(
+ struct wlr_session *base) {
+ assert(base->impl == &session_direct);
+ return (struct direct_session *)base;
+}
+
static int direct_session_open(struct wlr_session *base, const char *path) {
- struct direct_session *session = wl_container_of(base, session, base);
+ struct direct_session *session = direct_session_from_session(base);
int fd = direct_ipc_open(session->sock, path);
if (fd < 0) {
@@ -57,7 +64,7 @@ static int direct_session_open(struct wlr_session *base, const char *path) {
}
static void direct_session_close(struct wlr_session *base, int fd) {
- struct direct_session *session = wl_container_of(base, session, base);
+ struct direct_session *session = direct_session_from_session(base);
struct stat st;
if (fstat(fd, &st) < 0) {
@@ -76,7 +83,7 @@ static void direct_session_close(struct wlr_session *base, int fd) {
}
static bool direct_change_vt(struct wlr_session *base, unsigned vt) {
- struct direct_session *session = wl_container_of(base, session, base);
+ struct direct_session *session = direct_session_from_session(base);
// Only seat0 has VTs associated with it
if (strcmp(session->base.seat, "seat0") != 0) {
@@ -87,7 +94,7 @@ static bool direct_change_vt(struct wlr_session *base, unsigned vt) {
}
static void direct_session_destroy(struct wlr_session *base) {
- struct direct_session *session = wl_container_of(base, session, base);
+ struct direct_session *session = direct_session_from_session(base);
if (strcmp(session->base.seat, "seat0") == 0) {
struct vt_mode mode = {