Fix various libusb warnings and possible bugs on linux build.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
diff --git a/compat/libusb-1.0/libusb/descriptor.c b/compat/libusb-1.0/libusb/descriptor.c
index 70de0b8..4f81dab 100644
--- a/compat/libusb-1.0/libusb/descriptor.c
+++ b/compat/libusb-1.0/libusb/descriptor.c
@@ -805,6 +805,7 @@ int API_EXPORTED libusb_parse_bos_descriptor(const void *buf, int len,
struct libusb_bos_descriptor *bos_desc;
int i;
+ len = len;
bos_desc = calloc (1, sizeof (*bos_desc));
if (!bos_desc) {
return LIBUSB_ERROR_NO_MEM;
diff --git a/compat/libusb-1.0/libusb/io.c b/compat/libusb-1.0/libusb/io.c
index 01fc780..f488478 100644
--- a/compat/libusb-1.0/libusb/io.c
+++ b/compat/libusb-1.0/libusb/io.c
@@ -1942,7 +1942,7 @@ static int handle_events(struct libusb_context *ctx, struct timeval *tv)
/* fd[1] is always the hotplug pipe */
if (libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG) && fds[1].revents) {
libusb_hotplug_message message;
- int ret;
+ unsigned int ret;
/* read the message from the hotplug thread */
ret = read(ctx->hotplug_pipe[0], &message, sizeof (message));
diff --git a/compat/libusb-1.0/libusb/os/linux_udev.c b/compat/libusb-1.0/libusb/os/linux_udev.c
index 3662e4e..abe1e66 100644
--- a/compat/libusb-1.0/libusb/os/linux_udev.c
+++ b/compat/libusb-1.0/libusb/os/linux_udev.c
@@ -109,7 +109,7 @@ int linux_udev_stop_event_monitor(void)
return LIBUSB_SUCCESS;
}
-static void *linux_udev_event_thread_main(void *arg)
+static void *linux_udev_event_thread_main(void __attribute__((unused)) *arg)
{
struct pollfd fds = {.fd = udev_monitor_fd,
.events = POLLIN};
diff --git a/compat/libusb-1.0/libusb/os/linux_usbfs.c b/compat/libusb-1.0/libusb/os/linux_usbfs.c
index 9539b2a..57603e6 100644
--- a/compat/libusb-1.0/libusb/os/linux_usbfs.c
+++ b/compat/libusb-1.0/libusb/os/linux_usbfs.c
@@ -664,7 +664,7 @@ static int seek_to_next_config(struct libusb_context *ctx, int fd,
if (r < 0) {
usbi_err(ctx, "read failed ret=%d errno=%d", r, errno);
return LIBUSB_ERROR_IO;
- } else if (r < sizeof(tmp)) {
+ } else if (r < (ssize_t)sizeof(tmp)) {
usbi_err(ctx, "short descriptor read %d/%d", r, sizeof(tmp));
return LIBUSB_ERROR_IO;
}
@@ -733,7 +733,7 @@ static int sysfs_get_active_config_descriptor(struct libusb_device *dev,
usbi_err(DEVICE_CTX(dev), "read failed, ret=%d errno=%d",
fd, errno);
return LIBUSB_ERROR_IO;
- } else if (r < sizeof(tmp)) {
+ } else if (r < (ssize_t)sizeof(tmp)) {
usbi_err(DEVICE_CTX(dev), "short read %d/%d", r, sizeof(tmp));
return LIBUSB_ERROR_IO;
}
@@ -763,7 +763,7 @@ static int sysfs_get_active_config_descriptor(struct libusb_device *dev,
} else if (r == 0) {
usbi_dbg("device is unconfigured");
r = LIBUSB_ERROR_NOT_FOUND;
- } else if (r < len - sizeof(tmp)) {
+ } else if ((size_t)r < len - sizeof(tmp)) {
usbi_err(DEVICE_CTX(dev), "short read %d/%d", r, len);
r = LIBUSB_ERROR_IO;
}
@@ -779,6 +779,8 @@ int linux_get_device_address (struct libusb_context *ctx, int detached,
uint8_t *busnum, uint8_t *devaddr,
const char *dev_node, const char *sys_name)
{
+ int retbus, retdev;
+
usbi_dbg("getting address for device: %s detached: %d",
sys_name, detached);
/* can't use sysfs to read the bus and device number if the
@@ -800,16 +802,16 @@ int linux_get_device_address (struct libusb_context *ctx, int detached,
usbi_dbg("scan %s", sys_name);
- *busnum = __read_sysfs_attr(ctx, sys_name, "busnum");
- if (0 > *busnum)
- return *busnum;
+ *busnum = retbus = __read_sysfs_attr(ctx, sys_name, "busnum");
+ if (retbus < 0)
+ return retbus;
- *devaddr = __read_sysfs_attr(ctx, sys_name, "devnum");
- if (0 > *devaddr)
- return *devaddr;
+ *devaddr = retdev = __read_sysfs_attr(ctx, sys_name, "devnum");
+ if (retdev < 0)
+ return retdev;
usbi_dbg("bus=%d dev=%d", *busnum, *devaddr);
- if (*busnum > 255 || *devaddr > 255)
+ if (retbus > 255 || retdev > 255)
return LIBUSB_ERROR_INVALID_PARAM;
return LIBUSB_SUCCESS;
@@ -818,6 +820,7 @@ int linux_get_device_address (struct libusb_context *ctx, int detached,
static int op_get_active_config_descriptor(struct libusb_device *dev,
unsigned char *buffer, size_t len, int *host_endian)
{
+ *host_endian = *host_endian;
if (sysfs_has_descriptors) {
return sysfs_get_active_config_descriptor(dev, buffer, len);
} else {
@@ -853,7 +856,7 @@ static int get_config_descriptor(struct libusb_context *ctx, int fd,
if (r < 0) {
usbi_err(ctx, "read failed ret=%d errno=%d", r, errno);
return LIBUSB_ERROR_IO;
- } else if (r < len) {
+ } else if ((size_t)r < len) {
usbi_err(ctx, "short output read %d/%d", r, len);
return LIBUSB_ERROR_IO;
}
@@ -868,6 +871,7 @@ static int op_get_config_descriptor(struct libusb_device *dev,
int fd;
int r;
+ *host_endian = *host_endian;
/* always read from usbfs: sysfs only has the active descriptor
* this will involve waking the device up, but oh well! */
@@ -1161,7 +1165,7 @@ void linux_hotplug_disconnected(uint8_t busnum, uint8_t devaddr, const char *sys
if (NULL != dev) {
usbi_disconnect_device (dev);
} else {
- usbi_err(ctx, "device not found for session %x", busnum << 8 | devaddr);
+ usbi_err(ctx, "device not found for session %x %s", busnum << 8 | devaddr, sys_name);
}
}
}