Guard Inotify stuff with macro

This fix implicit declaration of close and unused variable warning.
This commit is contained in:
Mathieu Eyraud 2021-02-22 13:32:42 +01:00 committed by Sam Lantinga
parent 8481229ff7
commit 7a2b6f331b
1 changed files with 7 additions and 0 deletions

View File

@ -61,6 +61,7 @@
#include <unistd.h> #include <unistd.h>
#endif #endif
#if defined(SDL_USE_LIBUDEV)
typedef enum typedef enum
{ {
ENUMERATION_UNSET, ENUMERATION_UNSET,
@ -69,6 +70,7 @@ typedef enum
} LinuxEnumerationMethod; } LinuxEnumerationMethod;
static LinuxEnumerationMethod linux_enumeration_method = ENUMERATION_UNSET; static LinuxEnumerationMethod linux_enumeration_method = ENUMERATION_UNSET;
#endif
struct joystick_hwdata struct joystick_hwdata
{ {
@ -108,7 +110,10 @@ static SDL_HIDAPI_Device *SDL_HIDAPI_devices;
static int SDL_HIDAPI_numjoysticks = 0; static int SDL_HIDAPI_numjoysticks = 0;
static SDL_bool initialized = SDL_FALSE; static SDL_bool initialized = SDL_FALSE;
static SDL_bool shutting_down = SDL_FALSE; static SDL_bool shutting_down = SDL_FALSE;
#if defined(HAVE_INOTIFY)
static int inotify_fd = -1; static int inotify_fd = -1;
#endif
#if defined(SDL_USE_LIBUDEV) #if defined(SDL_USE_LIBUDEV)
static const SDL_UDEV_Symbols * usyms = NULL; static const SDL_UDEV_Symbols * usyms = NULL;
@ -1411,10 +1416,12 @@ HIDAPI_JoystickQuit(void)
SDL_HIDAPI_QuitRumble(); SDL_HIDAPI_QuitRumble();
#if defined(HAVE_INOTIFY)
if (inotify_fd >= 0) { if (inotify_fd >= 0) {
close(inotify_fd); close(inotify_fd);
inotify_fd = -1; inotify_fd = -1;
} }
#endif
while (SDL_HIDAPI_devices) { while (SDL_HIDAPI_devices) {
HIDAPI_DelDevice(SDL_HIDAPI_devices); HIDAPI_DelDevice(SDL_HIDAPI_devices);