[FFmpeg-devel] [PATCH 01/10] avformat/os_support: check invalid socket value correctly on Windows
Kacper Michajlow
kasper93 at gmail.com
Fri Jul 25 18:58:16 EEST 2025
On Tue, 22 Jul 2025 at 21:16, Kacper Michajłow <kasper93 at gmail.com> wrote:
>
> 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
>
Will apply this patchset later. It's mostly warning suppression and
small fixes, let me know if there are some objections.
- Kacper
More information about the ffmpeg-devel
mailing list