From 3605cde8eaf9388d0321a250d0d85bd0d8708381 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Tue, 23 Aug 2016 00:22:15 +0300 Subject: [PATCH] dinput: Explicitly check for -1 as open() failure code. Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/dinput/joystick_linux.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c index 3086e689316..1f8f94d7382 100644 --- a/dlls/dinput/joystick_linux.c +++ b/dlls/dinput/joystick_linux.c @@ -150,8 +150,7 @@ static BOOL read_sys_id_variable(int index, const char *property, WORD *value) BOOL ret = FALSE; sprintf(sys_path, SYS_PATH_FORMAT, index, property); - sys_fd = open(sys_path, O_RDONLY); - if (sys_fd > 0) + if ((sys_fd = open(sys_path, O_RDONLY)) != -1) { if (read(sys_fd, id_str, 4) == 4) { @@ -180,10 +179,10 @@ static INT find_joystick_devices(void) BYTE axes_map[ABS_MAX + 1]; snprintf(joydev.device, sizeof(joydev.device), "%s%d", JOYDEV_NEW, i); - if ((fd = open(joydev.device, O_RDONLY)) < 0) + if ((fd = open(joydev.device, O_RDONLY)) == -1) { snprintf(joydev.device, sizeof(joydev.device), "%s%d", JOYDEV_OLD, i); - if ((fd = open(joydev.device, O_RDONLY)) < 0) continue; + if ((fd = open(joydev.device, O_RDONLY)) == -1) continue; } strcpy(joydev.name, "Wine Joystick"); @@ -355,7 +354,7 @@ static HRESULT joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINS ((dwDevType == DIDEVTYPE_JOYSTICK) && (version > 0x0300 && version < 0x0800)) || (((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))) { /* check whether we have a joystick */ - if ((fd = open(joystick_devices[id].device, O_RDONLY)) < 0) + if ((fd = open(joystick_devices[id].device, O_RDONLY)) == -1) { WARN("open(%s, O_RDONLY) failed: %s\n", joystick_devices[id].device, strerror(errno)); return S_FALSE; @@ -384,7 +383,7 @@ static HRESULT joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINS ((dwDevType == DIDEVTYPE_JOYSTICK) && (version > 0x0300 && version < 0x0800)) || (((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))) { /* check whether we have a joystick */ - if ((fd = open(joystick_devices[id].device, O_RDONLY)) < 0) + if ((fd = open(joystick_devices[id].device, O_RDONLY)) == -1) { WARN("open(%s, O_RDONLY) failed: %s\n", joystick_devices[id].device, strerror(errno)); return S_FALSE;