core: Fix unused variable warnings on release builds

The recently introduced PTHREAD_CHECK and WINAPI_CHECK macros cause a
large number of compiler warnings for unused variables on release
builds. Fix this by implementing those macros in terms of some new
macros that are defined based on the definition of NDEBUG.

Closes #788

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
diff --git a/libusb/libusbi.h b/libusb/libusbi.h
index a3c361b..0d4fbe1 100644
--- a/libusb/libusbi.h
+++ b/libusb/libusbi.h
@@ -44,6 +44,14 @@
 #define static_assert(cond, msg) _Static_assert(cond, msg)
 #endif
 
+#ifdef NDEBUG
+#define ASSERT_EQ(expression, value)	(void)expression
+#define ASSERT_NE(expression, value)	(void)expression
+#else
+#define ASSERT_EQ(expression, value)	assert(expression == value)
+#define ASSERT_NE(expression, value)	assert(expression != value)
+#endif
+
 #define container_of(ptr, type, member) \
 	((type *)((uintptr_t)(ptr) - (uintptr_t)offsetof(type, member)))
 
@@ -495,13 +503,11 @@
 #ifdef HAVE_CLOCK_GETTIME
 static inline void usbi_get_monotonic_time(struct timespec *tp)
 {
-	int r = clock_gettime(CLOCK_MONOTONIC, tp);
-	assert(r == 0);
+	ASSERT_EQ(clock_gettime(CLOCK_MONOTONIC, tp), 0);
 }
 static inline void usbi_get_real_time(struct timespec *tp)
 {
-	int r = clock_gettime(CLOCK_REALTIME, tp);
-	assert(r == 0);
+	ASSERT_EQ(clock_gettime(CLOCK_REALTIME, tp), 0);
 }
 #else
 /* If the platform doesn't provide the clock_gettime() function, the backend
diff --git a/libusb/os/threads_posix.h b/libusb/os/threads_posix.h
index 8a59fe2..9322834 100644
--- a/libusb/os/threads_posix.h
+++ b/libusb/os/threads_posix.h
@@ -23,11 +23,7 @@
 
 #include <pthread.h>
 
-#define PTHREAD_CHECK(expr)			\
-	do {					\
-		int pthread_result = (expr);	\
-		assert(pthread_result == 0);	\
-	} while (0)
+#define PTHREAD_CHECK(expression)	ASSERT_EQ(expression, 0)
 
 #define USBI_MUTEX_INITIALIZER	PTHREAD_MUTEX_INITIALIZER
 typedef pthread_mutex_t usbi_mutex_static_t;
diff --git a/libusb/os/threads_windows.h b/libusb/os/threads_windows.h
index ed57f7f..dfef158 100644
--- a/libusb/os/threads_windows.h
+++ b/libusb/os/threads_windows.h
@@ -21,11 +21,7 @@
 #ifndef LIBUSB_THREADS_WINDOWS_H
 #define LIBUSB_THREADS_WINDOWS_H
 
-#define WINAPI_CHECK(expr)			\
-	do {					\
-		BOOL winapi_result = (expr);	\
-		assert(winapi_result != 0);	\
-	} while (0)
+#define WINAPI_CHECK(expression)	ASSERT_NE(expression, 0)
 
 #define USBI_MUTEX_INITIALIZER	0L
 typedef LONG usbi_mutex_static_t;
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index 8f04ad2..89f331a 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 11565
+#define LIBUSB_NANO 11566