diff options
Diffstat (limited to 'libusb')
-rw-r--r-- | libusb/io.c | 1 | ||||
-rw-r--r-- | libusb/libusbi.h | 14 | ||||
-rw-r--r-- | libusb/os/linux_udev.c | 6 | ||||
-rw-r--r-- | libusb/os/poll_windows.c | 4 | ||||
-rw-r--r-- | libusb/os/windows_common.c | 5 | ||||
-rw-r--r-- | libusb/os/windows_winusb.c | 43 | ||||
-rw-r--r-- | libusb/version_nano.h | 2 |
7 files changed, 57 insertions, 18 deletions
diff --git a/libusb/io.c b/libusb/io.c index 5457d0e..907d28e 100644 --- a/libusb/io.c +++ b/libusb/io.c @@ -1267,6 +1267,7 @@ struct libusb_transfer * LIBUSB_CALL libusb_alloc_transfer( priv_size = PTR_ALIGN(usbi_backend.transfer_priv_size); alloc_size = priv_size + sizeof(struct usbi_transfer) + + sizeof(struct libusb_transfer) + (sizeof(struct libusb_iso_packet_descriptor) * (size_t)iso_packets); ptr = calloc(1, alloc_size); if (!ptr) diff --git a/libusb/libusbi.h b/libusb/libusbi.h index 9eeb920..2fa4e11 100644 --- a/libusb/libusbi.h +++ b/libusb/libusbi.h @@ -503,8 +503,6 @@ struct usbi_transfer { usbi_mutex_t lock; void *priv; - - struct libusb_transfer libusb_transfer; }; enum usbi_transfer_state_flags { @@ -529,10 +527,14 @@ enum usbi_transfer_timeout_flags { USBI_TRANSFER_TIMED_OUT = 1U << 2, }; -#define USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer) \ - (&(itransfer)->libusb_transfer) -#define LIBUSB_TRANSFER_TO_USBI_TRANSFER(transfer) \ - container_of(transfer, struct usbi_transfer, libusb_transfer) +#define USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer) \ + ((struct libusb_transfer *) \ + ((unsigned char *)(itransfer) \ + + PTR_ALIGN(sizeof(struct usbi_transfer)))) +#define LIBUSB_TRANSFER_TO_USBI_TRANSFER(transfer) \ + ((struct usbi_transfer *) \ + ((unsigned char *)(transfer) \ + - PTR_ALIGN(sizeof(struct usbi_transfer)))) /* All standard descriptors have these 2 fields in common */ struct usb_descriptor_header { diff --git a/libusb/os/linux_udev.c b/libusb/os/linux_udev.c index d8851cf..33a9174 100644 --- a/libusb/os/linux_udev.c +++ b/libusb/os/linux_udev.c @@ -131,7 +131,7 @@ err: int linux_udev_stop_event_monitor(void) { char dummy = 1; - int r; + ssize_t r; assert(udev_ctx != NULL); assert(udev_monitor != NULL); @@ -176,13 +176,15 @@ static void *linux_udev_event_thread_main(void *arg) .events = POLLIN}, }; + UNUSED(arg); + #if defined(HAVE_PTHREAD_SETNAME_NP) r = pthread_setname_np(pthread_self(), "libusb_event"); if (r) usbi_warn(NULL, "failed to set hotplug event thread name, error=%d", r); #endif - usbi_dbg("udev event thread entering."); + usbi_dbg("udev event thread entering"); while ((r = poll(fds, 2, -1)) >= 0 || errno == EINTR) { if (r < 0) { diff --git a/libusb/os/poll_windows.c b/libusb/os/poll_windows.c index 490ee7f..5497088 100644 --- a/libusb/os/poll_windows.c +++ b/libusb/os/poll_windows.c @@ -222,7 +222,7 @@ static DWORD WINAPI WaitThread(LPVOID lpParam) DWORD status; status = WaitForMultipleObjects(thread_data->num_handles, thread_data->handles, FALSE, INFINITE); - if ((status >= WAIT_OBJECT_0) && (status < (WAIT_OBJECT_0 + thread_data->num_handles))) { + if (status < (WAIT_OBJECT_0 + thread_data->num_handles)) { if (status > WAIT_OBJECT_0) { // This will wake up all the other waiting threads SetEvent(notify_event); @@ -291,7 +291,7 @@ static DWORD poll_wait(const HANDLE *wait_handles, DWORD num_wait_handles, DWORD } status = WaitForMultipleObjects(MAXIMUM_WAIT_OBJECTS, handles, FALSE, timeout); - if ((status >= WAIT_OBJECT_0) && (status < (WAIT_OBJECT_0 + MAXIMUM_WAIT_OBJECTS))) { + if (status < (WAIT_OBJECT_0 + MAXIMUM_WAIT_OBJECTS)) { if (status > WAIT_OBJECT_0) { // Wake up all the waiting threads SetEvent(notify_event); diff --git a/libusb/os/windows_common.c b/libusb/os/windows_common.c index debff74..418b6b7 100644 --- a/libusb/os/windows_common.c +++ b/libusb/os/windows_common.c @@ -565,7 +565,7 @@ static int windows_set_option(struct libusb_context *ctx, enum libusb_option opt UNUSED(ap); - switch (option) { + switch ((int)option) { case LIBUSB_OPTION_USE_USBDK: if (usbdk_available) { usbi_dbg("switching context %p to use UsbDk backend", ctx); @@ -832,7 +832,8 @@ int usbi_clock_gettime(int clk_id, struct timespec *tp) tp->tv_nsec = (long)(((hires_counter.QuadPart % hires_frequency) * hires_ticks_to_ps) / UINT64_C(1000)); return 0; } - // Fall through and return real-time if monotonic was not detected @ timer init + // Return real-time if monotonic was not detected @ timer init + // Fall through case USBI_CLOCK_REALTIME: #if defined(_MSC_VER) && (_MSC_VER >= 1900) if (!timespec_get(tp, TIME_UTC)) { diff --git a/libusb/os/windows_winusb.c b/libusb/os/windows_winusb.c index 245df90..67013d6 100644 --- a/libusb/os/windows_winusb.c +++ b/libusb/os/windows_winusb.c @@ -1137,7 +1137,7 @@ static int winusb_get_device_list(struct libusb_context *ctx, struct discovered_ unsigned int guid_size = GUID_SIZE_STEP; unsigned int nb_guids; // Keep a list of PnP enumerator strings that are found - char *usb_enumerator[8] = { "USB" }; + const char *usb_enumerator[8] = { "USB" }; unsigned int nb_usb_enumerators = 1; unsigned int usb_enum_index = 0; // Keep a list of newly allocated devs to unref @@ -1518,7 +1518,7 @@ static int winusb_get_device_list(struct libusb_context *ctx, struct discovered_ // Free any PnP enumerator strings for (i = 1; i < nb_usb_enumerators; i++) - free(usb_enumerator[i]); + free((void *)usb_enumerator[i]); // Unref newly allocated devs for (i = 0; i < unref_cur; i++) @@ -1835,12 +1835,44 @@ const struct windows_usb_api_backend usb_api_backend[USB_API_MAX] = { { USB_API_UNSUPPORTED, "Unsupported API", - // No supported operations + NULL, /* driver_name_list */ + 0, /* nb_driver_names */ + NULL, /* init */ + NULL, /* exit */ + NULL, /* open */ + NULL, /* close */ + NULL, /* configure_endpoints */ + NULL, /* claim_interface */ + NULL, /* set_interface_altsetting */ + NULL, /* release_interface */ + NULL, /* clear_halt */ + NULL, /* reset_device */ + NULL, /* submit_bulk_transfer */ + NULL, /* submit_iso_transfer */ + NULL, /* submit_control_transfer */ + NULL, /* cancel_transfer */ + NULL, /* copy_transfer_data */ }, { USB_API_HUB, "HUB API", - // No supported operations + NULL, /* driver_name_list */ + 0, /* nb_driver_names */ + NULL, /* init */ + NULL, /* exit */ + NULL, /* open */ + NULL, /* close */ + NULL, /* configure_endpoints */ + NULL, /* claim_interface */ + NULL, /* set_interface_altsetting */ + NULL, /* release_interface */ + NULL, /* clear_halt */ + NULL, /* reset_device */ + NULL, /* submit_bulk_transfer */ + NULL, /* submit_iso_transfer */ + NULL, /* submit_control_transfer */ + NULL, /* cancel_transfer */ + NULL, /* copy_transfer_data */ }, { USB_API_COMPOSITE, @@ -3990,7 +4022,8 @@ static int composite_submit_control_transfer(int sub_api, struct usbi_transfer * libusb_free_config_descriptor(conf_desc); break; } - // Fall through if not able to determine interface + // No break if not able to determine interface + // Fall through default: iface = -1; break; diff --git a/libusb/version_nano.h b/libusb/version_nano.h index 5708a99..1958a1e 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 11479 +#define LIBUSB_NANO 11480 |