summaryrefslogtreecommitdiff
path: root/libusb/os/threads_windows.c
diff options
context:
space:
mode:
authorChris Dickens <christopher.a.dickens@gmail.com>2020-08-26 17:42:59 -0700
committerChris Dickens <christopher.a.dickens@gmail.com>2020-09-13 00:06:11 -0700
commit11cc9952823fbb47b7596aec30a205f68f3a8062 (patch)
tree2ee8b88459c08d2b91faeed59c3095d34e25c2b1 /libusb/os/threads_windows.c
parentda5df37c4d1a2841c6f9cdc626386d096f5f312d (diff)
downloadlibusb-11cc9952823fbb47b7596aec30a205f68f3a8062.tar.gz
core: Simplify thread abstractions and add debug checks
The POSIX thread mutex initialization function can potentially fail, but in practice this is unlikely to occur. There is also inconsistent use of the result of the mutex initialization within the library. The result is only checked for mutexes in the libusb_device and libusb_device_handle structures but is ignored in all other cases. Simplify the mutex initialization function by changing the abstraction's wrapper to a void function, much like all the other functions that already exist. To that end, introduce macros for the abstractions that will check the return value on debug builds. Also remove the dependence on the core library needing errno.h to translate errors from usbi_cond_timedwait(). The abstraction will convert the implementation-specific error codes to LIBUSB_ERROR values. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Diffstat (limited to 'libusb/os/threads_windows.c')
-rw-r--r--libusb/os/threads_windows.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libusb/os/threads_windows.c b/libusb/os/threads_windows.c
index cf72694..4a57f42 100644
--- a/libusb/os/threads_windows.c
+++ b/libusb/os/threads_windows.c
@@ -34,7 +34,7 @@ int usbi_cond_timedwait(usbi_cond_t *cond,
if (SleepConditionVariableCS(cond, mutex, millis))
return 0;
else if (GetLastError() == ERROR_TIMEOUT)
- return ETIMEDOUT;
+ return LIBUSB_ERROR_TIMEOUT;
else
- return EINVAL;
+ return LIBUSB_ERROR_OTHER;
}