Make libseat_seat_listener const
libseat will never write to that struct. Let's allow callers to make it read-only.
This commit is contained in:
parent
309650aa4d
commit
166feaea33
6 changed files with 10 additions and 10 deletions
|
@ -16,7 +16,7 @@ struct named_backend {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct seat_impl {
|
struct seat_impl {
|
||||||
struct libseat *(*open_seat)(struct libseat_seat_listener *listener, void *data);
|
struct libseat *(*open_seat)(const struct libseat_seat_listener *listener, void *data);
|
||||||
int (*disable_seat)(struct libseat *seat);
|
int (*disable_seat)(struct libseat *seat);
|
||||||
int (*close_seat)(struct libseat *seat);
|
int (*close_seat)(struct libseat *seat);
|
||||||
const char *(*seat_name)(struct libseat *seat);
|
const char *(*seat_name)(struct libseat *seat);
|
||||||
|
|
|
@ -55,7 +55,7 @@ struct libseat_seat_listener {
|
||||||
* Returns a pointer to an opaque libseat struct on success. Returns NULL and
|
* Returns a pointer to an opaque libseat struct on success. Returns NULL and
|
||||||
* sets errno on error.
|
* sets errno on error.
|
||||||
*/
|
*/
|
||||||
struct libseat *libseat_open_seat(struct libseat_seat_listener *listener, void *userdata);
|
struct libseat *libseat_open_seat(const struct libseat_seat_listener *listener, void *userdata);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Disables a seat, used in response to a disable_seat event. After disabling
|
* Disables a seat, used in response to a disable_seat event. After disabling
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
struct backend_logind {
|
struct backend_logind {
|
||||||
struct libseat base;
|
struct libseat base;
|
||||||
struct libseat_seat_listener *seat_listener;
|
const struct libseat_seat_listener *seat_listener;
|
||||||
void *seat_listener_data;
|
void *seat_listener_data;
|
||||||
|
|
||||||
sd_bus *bus;
|
sd_bus *bus;
|
||||||
|
@ -621,7 +621,7 @@ static int set_type(struct backend_logind *backend, const char *type) {
|
||||||
return ret;
|
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));
|
struct backend_logind *backend = calloc(1, sizeof(struct backend_logind));
|
||||||
if (backend == NULL) {
|
if (backend == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
struct backend_noop {
|
struct backend_noop {
|
||||||
struct libseat base;
|
struct libseat base;
|
||||||
struct libseat_seat_listener *seat_listener;
|
const struct libseat_seat_listener *seat_listener;
|
||||||
void *seat_listener_data;
|
void *seat_listener_data;
|
||||||
|
|
||||||
bool initial_setup;
|
bool initial_setup;
|
||||||
|
@ -103,7 +103,7 @@ static int dispatch_background(struct libseat *base, int timeout) {
|
||||||
return 0;
|
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));
|
struct backend_noop *backend = calloc(1, sizeof(struct backend_noop));
|
||||||
if (backend == NULL) {
|
if (backend == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -33,7 +33,7 @@ struct pending_event {
|
||||||
struct backend_seatd {
|
struct backend_seatd {
|
||||||
struct libseat base;
|
struct libseat base;
|
||||||
struct connection connection;
|
struct connection connection;
|
||||||
struct libseat_seat_listener *seat_listener;
|
const struct libseat_seat_listener *seat_listener;
|
||||||
void *seat_listener_data;
|
void *seat_listener_data;
|
||||||
struct linked_list pending_events;
|
struct linked_list pending_events;
|
||||||
bool error;
|
bool error;
|
||||||
|
@ -363,7 +363,7 @@ static int dispatch_and_execute(struct libseat *base, int timeout) {
|
||||||
return predispatch + postdispatch;
|
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 != NULL);
|
||||||
assert(listener->enable_seat != NULL && listener->disable_seat != NULL);
|
assert(listener->enable_seat != NULL && listener->disable_seat != NULL);
|
||||||
struct backend_seatd *backend = calloc(1, sizeof(struct backend_seatd));
|
struct backend_seatd *backend = calloc(1, sizeof(struct backend_seatd));
|
||||||
|
@ -411,7 +411,7 @@ alloc_error:
|
||||||
return NULL;
|
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();
|
int fd = seatd_connect();
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -34,7 +34,7 @@ static const struct named_backend impls[] = {
|
||||||
#error At least one backend must be enabled
|
#error At least one backend must be enabled
|
||||||
#endif
|
#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) {
|
if (listener == NULL || listener->enable_seat == NULL || listener->disable_seat == NULL) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue