summaryrefslogtreecommitdiff
path: root/libusb/hotplug.c
diff options
context:
space:
mode:
authorChris Dickens <christopher.a.dickens@gmail.com>2020-01-25 12:10:04 -0800
committerChris Dickens <christopher.a.dickens@gmail.com>2020-01-25 12:10:04 -0800
commit7bc0ff3ce94572f3e52718938e4beb4c7a86bfff (patch)
treed94640a7edf402b2373b5cc4cfb84881e9c4bfb6 /libusb/hotplug.c
parent221e8196221a6ede462914daf6c2652d57843df6 (diff)
downloadlibusb-7bc0ff3ce94572f3e52718938e4beb4c7a86bfff.tar.gz
core: Convert internal macros to static inline functions
Older versions of the Visual Studio compiler are picky about macros constructed with the 'do { ... } while (0)' construct. Convert these internal ones to static inline functions. The result is functionally equivalent but gets us type checking and a bit more readability. Also address some compiler warnings due to some header files that are being included in a different order than before. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Diffstat (limited to 'libusb/hotplug.c')
-rw-r--r--libusb/hotplug.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/libusb/hotplug.c b/libusb/hotplug.c
index 71ec3fb..85e161c 100644
--- a/libusb/hotplug.c
+++ b/libusb/hotplug.c
@@ -243,7 +243,7 @@ int API_EXPORTED libusb_hotplug_register_callback(libusb_context *ctx,
return LIBUSB_ERROR_NOT_SUPPORTED;
}
- USBI_GET_CONTEXT(ctx);
+ ctx = usbi_get_context(ctx);
new_callback = calloc(1, sizeof(*new_callback));
if (!new_callback) {
@@ -319,10 +319,10 @@ void API_EXPORTED libusb_hotplug_deregister_callback(struct libusb_context *ctx,
return;
}
- USBI_GET_CONTEXT(ctx);
-
usbi_dbg("deregister hotplug cb %d", callback_handle);
+ ctx = usbi_get_context(ctx);
+
usbi_mutex_lock(&ctx->hotplug_cbs_lock);
list_for_each_entry(hotplug_cb, &ctx->hotplug_cbs, list, struct libusb_hotplug_callback) {
if (callback_handle == hotplug_cb->handle) {
@@ -357,10 +357,10 @@ void * LIBUSB_CALL libusb_hotplug_get_user_data(struct libusb_context *ctx,
return NULL;
}
- USBI_GET_CONTEXT(ctx);
-
usbi_dbg("get hotplug user data %d", callback_handle);
+ ctx = usbi_get_context(ctx);
+
usbi_mutex_lock(&ctx->hotplug_cbs_lock);
list_for_each_entry(hotplug_cb, &ctx->hotplug_cbs, list, struct libusb_hotplug_callback) {
if (callback_handle == hotplug_cb->handle) {