From 166feaea3394e00af14418e074ae090e31922f33 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sat, 14 Aug 2021 09:03:23 +0000 Subject: Make libseat_seat_listener const libseat will never write to that struct. Let's allow callers to make it read-only. --- libseat/backend/logind.c | 4 ++-- libseat/backend/noop.c | 4 ++-- libseat/backend/seatd.c | 6 +++--- libseat/libseat.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'libseat') diff --git a/libseat/backend/logind.c b/libseat/backend/logind.c index aa659a6..d62b976 100644 --- a/libseat/backend/logind.c +++ b/libseat/backend/logind.c @@ -30,7 +30,7 @@ struct backend_logind { struct libseat base; - struct libseat_seat_listener *seat_listener; + const struct libseat_seat_listener *seat_listener; void *seat_listener_data; sd_bus *bus; @@ -621,7 +621,7 @@ static int set_type(struct backend_logind *backend, const char *type) { return ret; } -static struct libseat *logind_open_seat(struct libseat_seat_listener *listener, void *data) { +static struct libseat *logind_open_seat(const struct libseat_seat_listener *listener, void *data) { struct backend_logind *backend = calloc(1, sizeof(struct backend_logind)); if (backend == NULL) { return NULL; diff --git a/libseat/backend/noop.c b/libseat/backend/noop.c index 71d0224..7436c48 100644 --- a/libseat/backend/noop.c +++ b/libseat/backend/noop.c @@ -13,7 +13,7 @@ struct backend_noop { struct libseat base; - struct libseat_seat_listener *seat_listener; + const struct libseat_seat_listener *seat_listener; void *seat_listener_data; bool initial_setup; @@ -103,7 +103,7 @@ static int dispatch_background(struct libseat *base, int timeout) { return 0; } -static struct libseat *noop_open_seat(struct libseat_seat_listener *listener, void *data) { +static struct libseat *noop_open_seat(const struct libseat_seat_listener *listener, void *data) { struct backend_noop *backend = calloc(1, sizeof(struct backend_noop)); if (backend == NULL) { return NULL; diff --git a/libseat/backend/seatd.c b/libseat/backend/seatd.c index 97971aa..25d8e95 100644 --- a/libseat/backend/seatd.c +++ b/libseat/backend/seatd.c @@ -33,7 +33,7 @@ struct pending_event { struct backend_seatd { struct libseat base; struct connection connection; - struct libseat_seat_listener *seat_listener; + const struct libseat_seat_listener *seat_listener; void *seat_listener_data; struct linked_list pending_events; bool error; @@ -363,7 +363,7 @@ static int dispatch_and_execute(struct libseat *base, int timeout) { return predispatch + postdispatch; } -static struct libseat *_open_seat(struct libseat_seat_listener *listener, void *data, int fd) { +static struct libseat *_open_seat(const 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)); @@ -411,7 +411,7 @@ alloc_error: return NULL; } -static struct libseat *open_seat(struct libseat_seat_listener *listener, void *data) { +static struct libseat *open_seat(const struct libseat_seat_listener *listener, void *data) { int fd = seatd_connect(); if (fd == -1) { return NULL; diff --git a/libseat/libseat.c b/libseat/libseat.c index 42449a8..8cc9ab2 100644 --- a/libseat/libseat.c +++ b/libseat/libseat.c @@ -34,7 +34,7 @@ static const struct named_backend impls[] = { #error At least one backend must be enabled #endif -struct libseat *libseat_open_seat(struct libseat_seat_listener *listener, void *data) { +struct libseat *libseat_open_seat(const struct libseat_seat_listener *listener, void *data) { if (listener == NULL || listener->enable_seat == NULL || listener->disable_seat == NULL) { errno = EINVAL; return NULL; -- cgit v1.2.3