summaryrefslogtreecommitdiff
path: root/libusb/libusbi.h
diff options
context:
space:
mode:
authorChris Dickens <christopher.a.dickens@gmail.com>2020-09-28 17:10:04 -0700
committerChris Dickens <christopher.a.dickens@gmail.com>2020-09-28 17:10:04 -0700
commiteee6998395184d87bd8e9c07ce2637caed1207f4 (patch)
tree32f68947c637f6a443faed675dd9f67d0c78eb4e /libusb/libusbi.h
parent70c0a51ba3a1daaf8fd51f1457dba86dd389debe (diff)
downloadlibusb-eee6998395184d87bd8e9c07ce2637caed1207f4.tar.gz
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>
Diffstat (limited to 'libusb/libusbi.h')
-rw-r--r--libusb/libusbi.h14
1 files changed, 10 insertions, 4 deletions
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 @@ static inline void usbi_localize_device_descriptor(struct libusb_device_descript
#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