[FFmpeg-devel] [PATCH 01/10] avformat/os_support: check invalid socket value correctly on Windows

Kacper Michajłow kasper93 at gmail.com
Tue Jul 22 22:16:02 EEST 2025


SOCKET defined in winsock2.h is unsigned and invalid value is defined as
INVALID_SOCKET. Check this explicity to avoid compiler warnings.

See: https://learn.microsoft.com/en-us/windows/win32/winsock/socket-data-type-2
Signed-off-by: Kacper Michajłow <kasper93 at gmail.com>
---
 libavformat/os_support.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavformat/os_support.c b/libavformat/os_support.c
index 4d6eb8a74c..17d77a01d5 100644
--- a/libavformat/os_support.c
+++ b/libavformat/os_support.c
@@ -244,13 +244,16 @@ int ff_poll(struct pollfd *fds, nfds_t numfds, int timeout)
 
     n = 0;
     for (i = 0; i < numfds; i++) {
+#if !HAVE_WINSOCK2_H
         if (fds[i].fd < 0)
             continue;
-#if !HAVE_WINSOCK2_H
         if (fds[i].fd >= FD_SETSIZE) {
             errno = EINVAL;
             return -1;
         }
+#else
+        if (fds[i].fd == INVALID_SOCKET)
+            continue;
 #endif /* !HAVE_WINSOCK2_H */
 
         if (fds[i].events & POLLIN)
-- 
2.50.1



More information about the ffmpeg-devel mailing list