From db58166e9bb107a3008a8c37abe6e859dd3f30b6 Mon Sep 17 00:00:00 2001
From: David Gow <[EMAIL REDACTED]>
Date: Sun, 21 Feb 2021 17:28:08 +0800
Subject: [PATCH] joystick: hidapi: Properly include <unistd.h> when inotify
not available
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
In the extremely unlikely event that inotify is not available (and,
therefore, HAVE_INOTIFY is not #defined), SDL will no-longer build.
This is because <unistd.h> is only included when HAVE_INOTIFY is
defined, and PR #4098 adds a call to access(…, F_OK), which requires
<unistd.h>.
(Note that the F_OK symbol is the only one which actually prevented
SDL from compiling, but both access() and close() fell back to implicit
definitions, which is a bit concerning.)
Fixes: 8d43f45a7b ("Don't use udev for joystick enumeration if running in a container")
---
src/joystick/hidapi/SDL_hidapijoystick.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/joystick/hidapi/SDL_hidapijoystick.c b/src/joystick/hidapi/SDL_hidapijoystick.c
index 899da9ee2..f36ec08e7 100644
--- a/src/joystick/hidapi/SDL_hidapijoystick.c
+++ b/src/joystick/hidapi/SDL_hidapijoystick.c
@@ -57,8 +57,8 @@
#include <fcntl.h>
#include <limits.h> /* For the definition of NAME_MAX */
#include <sys/inotify.h>
-#include <unistd.h>
#endif
+#include <unistd.h>
#endif
typedef enum