From 7e9fa0dee4cacccc79d41aaf66458cea140a97df Mon Sep 17 00:00:00 2001 From: NRK Date: Sun, 8 Mar 2026 01:26:42 +0000 Subject: [PATCH] osdep/io: remove redundant errno setting according to the docs _get_osfhandle() sets errno to EBADF upon failure already: https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/get-osfhandle?view=msvc-170 --- osdep/io.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/osdep/io.c b/osdep/io.c index cc1a096532..f7e6927187 100644 --- a/osdep/io.c +++ b/osdep/io.c @@ -284,10 +284,8 @@ int mp_stat(const char *path, struct mp_stat *buf) int mp_fstat(int fd, struct mp_stat *buf) { HANDLE h = (HANDLE)_get_osfhandle(fd); - if (h == INVALID_HANDLE_VALUE) { - errno = EBADF; + if (h == INVALID_HANDLE_VALUE) return -1; - } // Use mpv's hstat() function rather than MSVCRT's fstat() because mpv's // supports directories and device/inode numbers. return hstat(h, buf); @@ -815,10 +813,8 @@ void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset) mp_assert(flags == MAP_SHARED); // not implemented HANDLE osf = (HANDLE)_get_osfhandle(fd); - if (osf == INVALID_HANDLE_VALUE) { - errno = EBADF; + if (osf == INVALID_HANDLE_VALUE) return MAP_FAILED; - } DWORD protect = 0; DWORD access = 0;