aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorKenny Levinsen <kl@kl.wtf>2020-08-29 20:31:51 +0200
committerKenny Levinsen <kl@kl.wtf>2020-08-29 20:56:42 +0200
commit8b4d139873acfb3351ad335830b2689720d21552 (patch)
treee2ea9c432c55ea2dc261e8699bc6ed8f400a3c41 /common
parent69d57aaf332268e3dea8795c2b9f091059f3b5b4 (diff)
libseat: Improve logging with seatd conn helpers
Add helpers around connection access to have all logging centralized and reduce code duplication. Improve existing helpers to further reduce code duplication. The seatd backend should have much better logging after this.
Diffstat (limited to 'common')
-rw-r--r--common/connection.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/common/connection.c b/common/connection.c
index a6739c0..6b2c366 100644
--- a/common/connection.c
+++ b/common/connection.c
@@ -284,15 +284,14 @@ int connection_get(struct connection *connection, void *dst, size_t count) {
return count;
}
-int connection_get_fd(struct connection *connection) {
- int fd;
- if (sizeof fd > connection_buffer_size(&connection->fds_in)) {
+int connection_get_fd(struct connection *connection, int *fd) {
+ if (sizeof(int) > connection_buffer_size(&connection->fds_in)) {
errno = EAGAIN;
return -1;
}
- connection_buffer_copy(&connection->fds_in, &fd, sizeof fd);
- connection_buffer_consume(&connection->fds_in, sizeof fd);
- return fd;
+ connection_buffer_copy(&connection->fds_in, fd, sizeof(int));
+ connection_buffer_consume(&connection->fds_in, sizeof(int));
+ return 0;
}
void connection_close_fds(struct connection *connection) {