aboutsummaryrefslogtreecommitdiff
path: root/libseat/backend/seatd.c
diff options
context:
space:
mode:
authorKenny Levinsen <kl@kl.wtf>2020-08-29 20:27:02 +0200
committerKenny Levinsen <kl@kl.wtf>2020-08-29 20:29:35 +0200
commit69d57aaf332268e3dea8795c2b9f091059f3b5b4 (patch)
tree370d6673390774eb190792c66555ab80389eda09 /libseat/backend/seatd.c
parentde96b3938b19b091e16a757b9cae3b1909ee1ea0 (diff)
libseat: Assert that listener is non-NULL
Diffstat (limited to 'libseat/backend/seatd.c')
-rw-r--r--libseat/backend/seatd.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/libseat/backend/seatd.c b/libseat/backend/seatd.c
index 413282e..6321d39 100644
--- a/libseat/backend/seatd.c
+++ b/libseat/backend/seatd.c
@@ -88,20 +88,6 @@ static struct backend_seatd *backend_seatd_from_libseat_backend(struct libseat *
return (struct backend_seatd *)base;
}
-static void handle_enable_seat(struct backend_seatd *backend) {
- log_info("Enabling seat");
- if (backend->seat_listener != NULL && backend->seat_listener->enable_seat != NULL) {
- backend->seat_listener->enable_seat(&backend->base, backend->seat_listener_data);
- }
-}
-
-static void handle_disable_seat(struct backend_seatd *backend) {
- log_info("Disabling seat");
- if (backend->seat_listener != NULL && backend->seat_listener->disable_seat != NULL) {
- backend->seat_listener->disable_seat(&backend->base, backend->seat_listener_data);
- }
-}
-
static size_t read_header(struct connection *connection, uint16_t expected_opcode) {
struct proto_header header;
if (connection_get(connection, &header, sizeof header) == -1) {
@@ -155,12 +141,17 @@ static void execute_events(struct backend_seatd *backend) {
switch (opcode) {
case SERVER_DISABLE_SEAT:
- handle_disable_seat(backend);
+ log_info("Disabling seat");
+ backend->seat_listener->disable_seat(&backend->base,
+ backend->seat_listener_data);
break;
case SERVER_ENABLE_SEAT:
- handle_enable_seat(backend);
+ log_info("Enabling seat");
+ backend->seat_listener->enable_seat(&backend->base,
+ backend->seat_listener_data);
break;
default:
+ log_errorf("Invalid opcode: %d", opcode);
abort();
}
}
@@ -283,6 +274,8 @@ static void destroy(struct backend_seatd *backend) {
}
static struct libseat *_open_seat(struct libseat_seat_listener *listener, void *data, int fd) {
+ assert(listener != NULL);
+ assert(listener->enable_seat != NULL && listener->disable_seat != NULL);
struct backend_seatd *backend = calloc(1, sizeof(struct backend_seatd));
if (backend == NULL) {
close(fd);