[vlc-commits] core: ensure getsockopt/setsockopt use the proper pointer size on Windows
Steve Lhomme
git at videolan.org
Fri Jul 10 10:32:37 CEST 2020
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Jul 7 08:12:02 2020 +0200| [440ef7a13c2ade65b52ea1a6ca58658ca93050c1] | committer: Steve Lhomme
core: ensure getsockopt/setsockopt use the proper pointer size on Windows
Unlike most UNIX calls [1] on Windows many calls expect a BOOL instead of an
int [2]. It should be the same size, but make sure this is the case when
building.
We don't seem to use any of the options with a DWORD, LINGER or Service
Provider values.
[1] https://www.man7.org/linux/man-pages/man7/socket.7.html
[2] https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-setsockopt
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=440ef7a13c2ade65b52ea1a6ca58658ca93050c1
---
src/network/io.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/network/io.c b/src/network/io.c
index 5b17e67f6b..5285edc169 100644
--- a/src/network/io.c
+++ b/src/network/io.c
@@ -74,6 +74,10 @@ int net_Socket (vlc_object_t *p_this, int family, int socktype,
return -1;
}
+#ifdef _WIN32
+ // Windows expects a BOOL for some getsockopt/setsockopt options
+ static_assert(sizeof(int)==sizeof(BOOL), "mismatching type for setsockopt");
+#endif
setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, &(int){ 1 }, sizeof (int));
#ifdef IPV6_V6ONLY
More information about the vlc-commits
mailing list