#else
static int test_wrapped_device(const char *device_name)
{
+ (void)device_name;
printf("Testing wrapped devices is not supported on your platform\n");
return 1;
}
#if defined(__ANDROID__)
int priority;
switch (level) {
+ case LIBUSB_LOG_LEVEL_NONE: return; /* Impossible, but keeps compiler happy */
case LIBUSB_LOG_LEVEL_ERROR: priority = ANDROID_LOG_ERROR; break;
case LIBUSB_LOG_LEVEL_WARNING: priority = ANDROID_LOG_WARN; break;
case LIBUSB_LOG_LEVEL_INFO: priority = ANDROID_LOG_INFO; break;
#elif defined(HAVE_SYSLOG)
int syslog_level;
switch (level) {
+ case LIBUSB_LOG_LEVEL_NONE: return; /* Impossible, but keeps compiler happy */
case LIBUSB_LOG_LEVEL_ERROR: syslog_level = LOG_ERR; break;
case LIBUSB_LOG_LEVEL_WARNING: syslog_level = LOG_WARNING; break;
case LIBUSB_LOG_LEVEL_INFO: syslog_level = LOG_INFO; break;
#endif
switch (level) {
+ case LIBUSB_LOG_LEVEL_NONE: /* Impossible, but keeps compiler happy */
+ return;
case LIBUSB_LOG_LEVEL_ERROR:
prefix = "error";
break;
UNUSED(ctx);
UNUSED(ap);
- switch (option) {
#ifdef __ANDROID__
- case LIBUSB_OPTION_WEAK_AUTHORITY:
+ if (option == LIBUSB_OPTION_WEAK_AUTHORITY) {
usbi_dbg("set libusb has weak authority");
weak_authority = 1;
return LIBUSB_SUCCESS;
-#endif
- default:
- return LIBUSB_ERROR_NOT_SUPPORTED;
}
+#else
+ UNUSED(option);
+#endif
+
+ return LIBUSB_ERROR_NOT_SUPPORTED;
}
static int linux_scan_devices(struct libusb_context *ctx)
uint8_t *buffer;
size_t remaining;
- device_desc = (struct usbi_device_descriptor *)priv->descriptors;
+ device_desc = priv->descriptors;
num_configs = device_desc->bNumConfigurations;
if (num_configs == 0)
if (!priv->config_descriptors)
return LIBUSB_ERROR_NO_MEM;
- buffer = priv->descriptors + LIBUSB_DT_DEVICE_SIZE;
+ buffer = (uint8_t *)priv->descriptors + LIBUSB_DT_DEVICE_SIZE;
remaining = priv->descriptors_len - LIBUSB_DT_DEVICE_SIZE;
for (idx = 0; idx < num_configs; idx++) {
alloc_len = 0;
do {
- alloc_len += 256;
+ const size_t desc_read_length = 256;
+ uint8_t *read_ptr;
+
+ alloc_len += desc_read_length;
priv->descriptors = usbi_reallocf(priv->descriptors, alloc_len);
if (!priv->descriptors) {
if (fd != wrapped_fd)
close(fd);
return LIBUSB_ERROR_NO_MEM;
}
+ read_ptr = (uint8_t *)priv->descriptors + priv->descriptors_len;
/* usbfs has holes in the file */
if (!sysfs_dir)
- memset(priv->descriptors + priv->descriptors_len,
- 0, alloc_len - priv->descriptors_len);
- nb = read(fd, priv->descriptors + priv->descriptors_len,
- alloc_len - priv->descriptors_len);
+ memset(read_ptr, 0, desc_read_length);
+ nb = read(fd, read_ptr, desc_read_length);
if (nb < 0) {
usbi_err(ctx, "read descriptor failed, errno=%d", errno);
if (fd != wrapped_fd)
UNUSED(ap);
- switch ((int)option) {
- case LIBUSB_OPTION_USE_USBDK:
- if (usbdk_available) {
- usbi_dbg("switching context %p to use UsbDk backend", ctx);
- priv->backend = &usbdk_backend;
- } else {
+ if (option == LIBUSB_OPTION_USE_USBDK) {
+ if (!usbdk_available) {
usbi_err(ctx, "UsbDk backend not available");
return LIBUSB_ERROR_NOT_FOUND;
}
+ usbi_dbg("switching context %p to use UsbDk backend", ctx);
+ priv->backend = &usbdk_backend;
return LIBUSB_SUCCESS;
- default:
- return LIBUSB_ERROR_NOT_SUPPORTED;
}
+
+ return LIBUSB_ERROR_NOT_SUPPORTED;
}
static int windows_get_device_list(struct libusb_context *ctx, struct discovered_devs **discdevs)
config_desc_length = ROOT_HUB_HS_CONFIG_DESC_LENGTH;
ep_interval = 0x0c; // 256ms
break;
- default:
- // The default case means absolutely no information about this root hub was
- // determined. There is not much choice than to be pessimistic and label this
- // as a full-speed device.
+ case LIBUSB_SPEED_LOW: // Not used, but keeps compiler happy
+ case LIBUSB_SPEED_UNKNOWN:
+ // This case means absolutely no information about this root hub was determined.
+ // There is not much choice than to be pessimistic and label this as a
+ // full-speed device.
speed = LIBUSB_SPEED_FULL;
+ // fallthrough
+ case LIBUSB_SPEED_FULL:
dev->device_descriptor.bcdUSB = 0x0110;
config_desc_length = ROOT_HUB_FS_CONFIG_DESC_LENGTH;
ep_interval = 0xff; // 255ms
+ break;
}
if (speed >= LIBUSB_SPEED_SUPER) {
-#define LIBUSB_NANO 11572
+#define LIBUSB_NANO 11573