XlibInt.c: use correct type for Win32 in SocketBytesReadable()

Fixes compiler error of:

XlibInt.c: In function 'SocketBytesReadable':
XlibInt.c:1254:50: error: passing argument 3 of 'ioctlsocket' from
 incompatible pointer type [-Wincompatible-pointer-types]
 1254 |     ioctlsocket(ConnectionNumber(dpy), FIONREAD, &bytes);
      |                                                  ^~~~~~
      |                                                  |
      |                                                  int *
In file included from /usr/share/mingw-w64/include/windows.h:92,
                 from /usr/i686-w64-mingw32/include/X11/Xwindows.h:77,
                 from /usr/i686-w64-mingw32/include/X11/Xthreads.h:98:
/usr/share/mingw-w64/include/winsock.h:281:76: note: expected 'u_long *' {aka 'long unsigned int *'} but argument is of type 'int *'
  281 |   WINSOCK_API_LINKAGE int WSAAPI ioctlsocket(SOCKET s,__LONG32 cmd,u_long *argp);
      |                                                                    ~~~~~~~~^~~~

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/299>
This commit is contained in:
Alan Coopersmith 2026-03-15 14:52:08 -07:00
parent 92d226e34a
commit 13fd1cbb6f

View file

@ -1248,17 +1248,19 @@ _XWireToEvent(
static int
SocketBytesReadable(Display *dpy)
{
int bytes = 0, last_error;
#ifdef WIN32
last_error = WSAGetLastError();
u_long bytes = 0;
int last_error = WSAGetLastError();
ioctlsocket(ConnectionNumber(dpy), FIONREAD, &bytes);
WSASetLastError(last_error);
return (int) bytes;
#else
last_error = errno;
int bytes = 0;
int last_error = errno;
ioctl(ConnectionNumber(dpy), FIONREAD, &bytes);
errno = last_error;
#endif
return bytes;
#endif
}
_X_NORETURN void _XDefaultIOErrorExit(