Commit 7dba562c authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

posix: assert that we do not close a corrupt FD

This helps detect double-close or other bugs.
parent 7c6fe437
......@@ -134,17 +134,19 @@ int vlc_memfd (void)
int vlc_close (int fd)
int ret;
return posix_close (fd, 0);
ret = posix_close(fd, 0);
int ret = close (fd);
ret = close(fd);
/* POSIX.2008 (and earlier) does not specify if the file descriptor is
* closed on failure. Assume it is as on Linux and most other common OSes.
* Also emulate the correct error code as per newer POSIX versions. */
if (unlikely(ret != 0) && unlikely(errno == EINTR))
return ret;
assert(ret == 0 || errno != EBADF); /* something is corrupt? */
return ret;
int vlc_mkdir (const char *dirname, mode_t mode)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment