From 89ea61cf0ca033b1e3bf0b312c950b57d235de5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 14 Dec 2019 12:59:38 +0100 Subject: [PATCH] server: use socket-path from config --- server.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/server.c b/server.c index ae3f22b4..143af512 100644 --- a/server.c +++ b/server.c @@ -27,7 +27,7 @@ struct server { struct wayland *wayl; int fd; - char *sock_path; + const char *sock_path; tll(struct client *) clients; }; @@ -273,18 +273,6 @@ fdm_server(struct fdm *fdm, int fd, int events, void *data) return true; } -static char * -get_socket_path(void) -{ - const char *xdg_runtime = getenv("XDG_RUNTIME_DIR"); - if (xdg_runtime == NULL) - return strdup("/tmp/foot.sock"); - - char *path = malloc(strlen(xdg_runtime) + 1 + strlen("foot.sock") + 1); - sprintf(path, "%s/foot.sock", xdg_runtime); - return path; -} - enum connect_status {CONNECT_ERR, CONNECT_FAIL, CONNECT_SUCCESS}; static enum connect_status @@ -328,10 +316,7 @@ server_init(const struct config *conf, struct fdm *fdm, struct wayland *wayl) } struct server *server = NULL; - char *sock_path = NULL; - - if ((sock_path = get_socket_path()) == NULL) - goto err; + const char *sock_path = conf->server_socket_path; switch (try_connect(sock_path)) { case CONNECT_FAIL: @@ -381,7 +366,6 @@ server_init(const struct config *conf, struct fdm *fdm, struct wayland *wayl) err: free(server); - free(sock_path); if (fd != -1) close(fd); return NULL; @@ -406,6 +390,5 @@ server_destroy(struct server *server) fdm_del(server->fdm, server->fd); if (server->sock_path != NULL) unlink(server->sock_path); - free(server->sock_path); free(server); }