silenced a -Wunused-but-set-variable warning.

This commit is contained in:
Ozkan Sezer 2022-06-16 14:55:50 +03:00
parent 65195f9c1a
commit 0d4e9aac45
1 changed files with 13 additions and 7 deletions

View File

@ -155,18 +155,27 @@ int __PHYSFS_platformMkDir(const char *path)
} /* __PHYSFS_platformMkDir */
#if !defined(O_CLOEXEC) && defined(FD_CLOEXEC)
static inline void set_CLOEXEC(int fildes)
{
int flags = fcntl(fildes, F_GETFD);
if (flags != -1) {
fcntl(fildes, F_SETFD, flags | FD_CLOEXEC);
}
}
#endif
static void *doOpen(const char *filename, int mode)
{
const int appending = (mode & O_APPEND);
int fd;
int *retval;
int flags;
flags = -1;
errno = 0;
/* O_APPEND doesn't actually behave as we'd like. */
mode &= ~O_APPEND;
#ifdef O_CLOEXEC
/* Add O_CLOEXEC if defined */
mode |= O_CLOEXEC;
@ -178,10 +187,7 @@ static void *doOpen(const char *filename, int mode)
BAIL_IF(fd < 0, errcodeFromErrno(), NULL);
#if !defined(O_CLOEXEC) && defined(FD_CLOEXEC)
flags = fcntl(fd, F_GETFD);
if (flags != -1) {
fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
}
set_CLOEXEC(fd);
#endif
if (appending)