From 17682ba754b274c393c545b14811e4dc1160cd49 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 15 Mar 2026 13:30:45 -0700 Subject: [PATCH] xcb_util.c: don't build Unix domain socket path code on Windows Fixes build failure and compiler warnings: xcb_util.c: In function '_xcb_parse_display_path_to_socket': xcb_util.c:109:46: error: invalid use of undefined type 'struct sockaddr_un' 109 | char path[sizeof(((struct sockaddr_un*)0)->sun_path) + 1 + 10]; | ^~ xcb_util.c: In function '_xcb_open': xcb_util.c:256:11: warning: unused variable 'file' [-Wunused-variable] 256 | char *file = NULL; | ^~~~ xcb_util.c:255:12: warning: unused variable 'filelen' [-Wunused-variable] 255 | size_t filelen; | ^~~~~~~ xcb_util.c:254:17: warning: unused variable 'base' [-Wunused-variable] 254 | const char *base = unix_base; | ^~~~ xcb_util.c:248:9: warning: unused variable 'fd' [-Wunused-variable] 248 | int fd; | ^~ Fixes: 6a7661f ("Get rid of PATH_MAX") Closes: #87 Signed-off-by: Alan Coopersmith Part-of: --- src/xcb_util.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/xcb_util.c b/src/xcb_util.c index 8d8149a..e71dc28 100644 --- a/src/xcb_util.c +++ b/src/xcb_util.c @@ -93,6 +93,7 @@ int xcb_sumof(uint8_t *list, int len) return s; } +#ifndef _WIN32 /* Return true and parse if name matches [.] * Upon success: * host = @@ -156,6 +157,7 @@ static int _xcb_parse_display_path_to_socket(const char *name, char **host, char return 1; } +#endif __WIN32 static int _xcb_parse_display(const char *name, char **host, char **protocol, int *displayp, int *screenp) @@ -168,12 +170,14 @@ static int _xcb_parse_display(const char *name, char **host, char **protocol, if(!name) return 0; +#ifndef _WIN32 /* First check for [.] */ if (name[0] == '/') return _xcb_parse_display_path_to_socket(name, host, protocol, displayp, screenp); if (strncmp(name, "unix:", 5) == 0) return _xcb_parse_display_path_to_socket(name + 5, host, protocol, displayp, screenp); +#endif slash = strrchr(name, '/'); @@ -245,6 +249,7 @@ static int _xcb_open_unix(char *protocol, const char *file); static int _xcb_open(const char *host, char *protocol, const int display) { +#ifndef _WIN32 int fd; #ifdef __hpux static const char unix_base[] = "/usr/spool/sockets/X11/"; @@ -255,7 +260,6 @@ static int _xcb_open(const char *host, char *protocol, const int display) size_t filelen; char *file = NULL; -#ifndef _WIN32 if (protocol && strcmp("unix", protocol) == 0 && host && host[0] == '/') { /* Full path to socket provided, ignore everything else */ filelen = strlen(host) + 1; @@ -266,7 +270,8 @@ static int _xcb_open(const char *host, char *protocol, const int display) return -1; memcpy(file, host, filelen); } else { -#endif +#endif /* _WIN32 */ + /* If protocol or host is "unix", fall through to Unix socket code below */ if ((!protocol || (strcmp("unix",protocol) != 0)) && (*host != '\0') && (strcmp("unix",host) != 0))