GeezerVison is showing github.com — Fixed many compiler warnings about sign and size mismatch · Raghuvardhan-Reddy78/libusb@8a05a3f
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: Xcode/common.xcconfig +9Lines changed: 9 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -37,12 +37,21 @@ GCC_WARN_UNKNOWN_PRAGMAS = YES | 37 | 37 | GCC_WARN_UNUSED_FUNCTION = YES | 38 | 38 | GCC_WARN_UNUSED_LABEL = YES | 39 | 39 | GCC_WARN_UNUSED_VARIABLE = YES | | 40 | +GCC_WARN_UNUSED_PARAMETER = YES | 40 | 41 | CLANG_WARN_EMPTY_BODY = YES | 41 | 42 | CLANG_WARN_CONSTANT_CONVERSION = YES | 42 | 43 | CLANG_WARN_ENUM_CONVERSION = YES | 43 | 44 | CLANG_WARN_INT_CONVERSION = YES | 44 | 45 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES | 45 | 46 | CLANG_WARN_BOOL_CONVERSION = YES | | 47 | +CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES | | 48 | +CLANG_WARN_FLOAT_CONVERSION = YES | | 49 | +CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES | | 50 | +CLANG_WARN_INFINITE_RECURSION = YES | | 51 | +CLANG_WARN_ASSIGN_ENUM = YES | | 52 | +CLANG_WARN_STRICT_PROTOTYPES = YES | | 53 | +CLANG_WARN_COMMA = YES | | 54 | +CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES | 46 | 55 |
| 47 | 56 | // Static analyzer warnings. | 48 | 57 | CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES | |
Collapse file Copy file name to clipboardExpand all lines: examples/ezusb.c +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -299,7 +299,7 @@ static int parse_ihex(FILE *image, void *context, | 299 | 299 | /* Read the target offset (address up to 64KB) */ | 300 | 300 | tmp = buf[7]; | 301 | 301 | buf[7] = 0; | 302 | | - off = (int)strtoul(buf+3, NULL, 16); | | 302 | + off = (unsigned int)strtoul(buf+3, NULL, 16); | 303 | 303 | buf[7] = tmp; | 304 | 304 |
| 305 | 305 | /* Initialize data_addr */ | |
Collapse file Copy file name to clipboardExpand all lines: examples/sam3u_benchmark.c +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -55,11 +55,11 @@ static void LIBUSB_CALL cb_xfr(struct libusb_transfer *xfr) | 55 | 55 | struct libusb_iso_packet_descriptor *pack = &xfr->iso_packet_desc[i]; | 56 | 56 |
| 57 | 57 | if (pack->status != LIBUSB_TRANSFER_COMPLETED) { | 58 | | - fprintf(stderr, "Error: pack %u status %d\n", i, pack->status); | | 58 | + fprintf(stderr, "Error: pack %d status %d\n", i, pack->status); | 59 | 59 | exit(5); | 60 | 60 | } | 61 | 61 |
| 62 | | - printf("pack%u length:%u, actual_length:%u\n", i, pack->length, pack->actual_length); | | 62 | + printf("pack%d length:%u, actual_length:%u\n", i, pack->length, pack->actual_length); | 63 | 63 | } | 64 | 64 | } | 65 | 65 |
| |
Collapse file Copy file name to clipboardExpand all lines: examples/xusb.c +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -627,7 +627,7 @@ static int test_hid(libusb_device_handle *handle, uint8_t endpoint_in) | 627 | 627 | } | 628 | 628 | display_buffer_hex(hid_report_descriptor, descriptor_size); | 629 | 629 | if ((binary_dump) && ((fd = fopen(binary_name, "w")) != NULL)) { | 630 | | - if (fwrite(hid_report_descriptor, 1, descriptor_size, fd) != descriptor_size) { | | 630 | + if (fwrite(hid_report_descriptor, 1, descriptor_size, fd) != (size_t)descriptor_size) { | 631 | 631 | printf(" Error writing descriptor to file\n"); | 632 | 632 | } | 633 | 633 | fclose(fd); | |
Collapse file Copy file name to clipboardExpand all lines: libusb/core.c +14-14Lines changed: 14 additions & 14 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -845,8 +845,8 @@ ssize_t API_EXPORTED libusb_get_device_list(libusb_context *ctx, | 845 | 845 | } | 846 | 846 |
| 847 | 847 | /* convert discovered_devs into a list */ | 848 | | - len = discdevs->len; | 849 | | - ret = calloc(len + 1, sizeof(struct libusb_device *)); | | 848 | + len = (ssize_t)discdevs->len; | | 849 | + ret = calloc((size_t)len + 1, sizeof(struct libusb_device *)); | 850 | 850 | if (!ret) { | 851 | 851 | len = LIBUSB_ERROR_NO_MEM; | 852 | 852 | goto out; | @@ -1680,12 +1680,12 @@ int API_EXPORTED libusb_claim_interface(libusb_device_handle *dev_handle, | 1680 | 1680 | return LIBUSB_ERROR_NO_DEVICE; | 1681 | 1681 |
| 1682 | 1682 | usbi_mutex_lock(&dev_handle->lock); | 1683 | | - if (dev_handle->claimed_interfaces & (1 << interface_number)) | | 1683 | + if (dev_handle->claimed_interfaces & (1U << interface_number)) | 1684 | 1684 | goto out; | 1685 | 1685 |
| 1686 | 1686 | r = usbi_backend.claim_interface(dev_handle, interface_number); | 1687 | 1687 | if (r == 0) | 1688 | | - dev_handle->claimed_interfaces |= 1 << interface_number; | | 1688 | + dev_handle->claimed_interfaces |= 1U << interface_number; | 1689 | 1689 |
| 1690 | 1690 | out: | 1691 | 1691 | usbi_mutex_unlock(&dev_handle->lock); | @@ -1721,14 +1721,14 @@ int API_EXPORTED libusb_release_interface(libusb_device_handle *dev_handle, | 1721 | 1721 | return LIBUSB_ERROR_INVALID_PARAM; | 1722 | 1722 |
| 1723 | 1723 | usbi_mutex_lock(&dev_handle->lock); | 1724 | | - if (!(dev_handle->claimed_interfaces & (1 << interface_number))) { | | 1724 | + if (!(dev_handle->claimed_interfaces & (1U << interface_number))) { | 1725 | 1725 | r = LIBUSB_ERROR_NOT_FOUND; | 1726 | 1726 | goto out; | 1727 | 1727 | } | 1728 | 1728 |
| 1729 | 1729 | r = usbi_backend.release_interface(dev_handle, interface_number); | 1730 | 1730 | if (r == 0) | 1731 | | - dev_handle->claimed_interfaces &= ~(1 << interface_number); | | 1731 | + dev_handle->claimed_interfaces &= ~(1U << interface_number); | 1732 | 1732 |
| 1733 | 1733 | out: | 1734 | 1734 | usbi_mutex_unlock(&dev_handle->lock); | @@ -1770,7 +1770,7 @@ int API_EXPORTED libusb_set_interface_alt_setting(libusb_device_handle *dev_hand | 1770 | 1770 | return LIBUSB_ERROR_NO_DEVICE; | 1771 | 1771 | } | 1772 | 1772 |
| 1773 | | - if (!(dev_handle->claimed_interfaces & (1 << interface_number))) { | | 1773 | + if (!(dev_handle->claimed_interfaces & (1U << interface_number))) { | 1774 | 1774 | usbi_mutex_unlock(&dev_handle->lock); | 1775 | 1775 | return LIBUSB_ERROR_NOT_FOUND; | 1776 | 1776 | } | @@ -2507,7 +2507,7 @@ static void usbi_log_str(enum libusb_log_level level, const char *str) | 2507 | 2507 | case LIBUSB_LOG_LEVEL_DEBUG: syslog_level = LOG_DEBUG; break; | 2508 | 2508 | } | 2509 | 2509 | syslog(syslog_level, "%s", str); | 2510 | | -#else /* All of gcc, Clang, XCode seem to use #warning */ | | 2510 | +#else /* All of gcc, Clang, Xcode seem to use #warning */ | 2511 | 2511 | #warning System logging is not supported on this platform. Logging to stderr will be used instead. | 2512 | 2512 | fputs(str, stderr); | 2513 | 2513 | #endif | @@ -2589,8 +2589,8 @@ void usbi_log_v(struct libusb_context *ctx, enum libusb_log_level level, | 2589 | 2589 |
| 2590 | 2590 | if (global_debug) { | 2591 | 2591 | header_len = snprintf(buf, sizeof(buf), | 2592 | | - "[%2d.%06d] [%08x] libusb: %s [%s] ", | 2593 | | - (int)now.tv_sec, (int)(now.tv_nsec / 1000L), usbi_get_tid(), prefix, function); | | 2592 | + "[%2ld.%06ld] [%08x] libusb: %s [%s] ", | | 2593 | + (long)now.tv_sec, (long)(now.tv_nsec / 1000L), usbi_get_tid(), prefix, function); | 2594 | 2594 | } else { | 2595 | 2595 | header_len = snprintf(buf, sizeof(buf), | 2596 | 2596 | "libusb: %s [%s] ", prefix, function); | @@ -2603,16 +2603,16 @@ void usbi_log_v(struct libusb_context *ctx, enum libusb_log_level level, | 2603 | 2603 | } | 2604 | 2604 | /* Make sure buffer is NUL terminated */ | 2605 | 2605 | buf[header_len] = '\0'; | 2606 | | - text_len = vsnprintf(buf + header_len, sizeof(buf) - header_len, | | 2606 | + text_len = vsnprintf(buf + header_len, sizeof(buf) - (size_t)header_len, | 2607 | 2607 | format, args); | 2608 | 2608 | if (text_len < 0 || text_len + header_len >= (int)sizeof(buf)) { | 2609 | 2609 | /* Truncated log output. On some platforms a -1 return value means | 2610 | 2610 | * that the output was truncated. */ | 2611 | | - text_len = sizeof(buf) - header_len; | | 2611 | + text_len = (int)sizeof(buf) - header_len; | 2612 | 2612 | } | 2613 | | - if (header_len + text_len + sizeof(USBI_LOG_LINE_END) >= sizeof(buf)) { | | 2613 | + if (header_len + text_len + (int)sizeof(USBI_LOG_LINE_END) >= (int)sizeof(buf)) { | 2614 | 2614 | /* Need to truncate the text slightly to fit on the terminator. */ | 2615 | | - text_len -= (header_len + text_len + sizeof(USBI_LOG_LINE_END)) - sizeof(buf); | | 2615 | + text_len -= (header_len + text_len + (int)sizeof(USBI_LOG_LINE_END)) - (int)sizeof(buf); | 2616 | 2616 | } | 2617 | 2617 | strcpy(buf + header_len + text_len, USBI_LOG_LINE_END); | 2618 | 2618 |
| |
Collapse file Copy file name to clipboardExpand all lines: libusb/descriptor.c +11-11Lines changed: 11 additions & 11 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -62,7 +62,7 @@ int usbi_parse_descriptor(const unsigned char *source, const char *descriptor, | 62 | 62 | if (host_endian) { | 63 | 63 | memcpy(dp, sp, 2); | 64 | 64 | } else { | 65 | | - w = (sp[1] << 8) | sp[0]; | | 65 | + w = (uint16_t)((sp[1] << 8) | sp[0]); | 66 | 66 | *((uint16_t *)dp) = w; | 67 | 67 | } | 68 | 68 | sp += 2; | @@ -74,8 +74,8 @@ int usbi_parse_descriptor(const unsigned char *source, const char *descriptor, | 74 | 74 | if (host_endian) { | 75 | 75 | memcpy(dp, sp, 4); | 76 | 76 | } else { | 77 | | - d = (sp[3] << 24) | (sp[2] << 16) | | 78 | | - (sp[1] << 8) | sp[0]; | | 77 | + d = (uint32_t)((sp[3] << 24) | (sp[2] << 16) | | | 78 | + (sp[1] << 8) | sp[0]); | 79 | 79 | *((uint32_t *)dp) = d; | 80 | 80 | } | 81 | 81 | sp += 4; | @@ -168,13 +168,13 @@ static int parse_endpoint(struct libusb_context *ctx, | 168 | 168 | /* Copy any unknown descriptors into a storage area for drivers */ | 169 | 169 | /* to later parse */ | 170 | 170 | len = (int)(buffer - begin); | 171 | | - if (!len) { | | 171 | + if (len <= 0) { | 172 | 172 | endpoint->extra = NULL; | 173 | 173 | endpoint->extra_length = 0; | 174 | 174 | return parsed; | 175 | 175 | } | 176 | 176 |
| 177 | | - extra = malloc(len); | | 177 | + extra = malloc((size_t)len); | 178 | 178 | endpoint->extra = extra; | 179 | 179 | if (!extra) { | 180 | 180 | endpoint->extra_length = 0; | @@ -230,7 +230,7 @@ static int parse_interface(libusb_context *ctx, | 230 | 230 | (struct libusb_interface_descriptor *) usb_interface->altsetting; | 231 | 231 | altsetting = usbi_reallocf(altsetting, | 232 | 232 | sizeof(struct libusb_interface_descriptor) * | 233 | | - (usb_interface->num_altsetting + 1)); | | 233 | + ((size_t)usb_interface->num_altsetting + 1)); | 234 | 234 | if (!altsetting) { | 235 | 235 | r = LIBUSB_ERROR_NO_MEM; | 236 | 236 | goto err; | @@ -307,8 +307,8 @@ static int parse_interface(libusb_context *ctx, | 307 | 307 | /* Copy any unknown descriptors into a storage area for */ | 308 | 308 | /* drivers to later parse */ | 309 | 309 | len = (int)(buffer - begin); | 310 | | - if (len) { | 311 | | - ifp->extra = malloc(len); | | 310 | + if (len > 0) { | | 311 | + ifp->extra = malloc((size_t)len); | 312 | 312 | if (!ifp->extra) { | 313 | 313 | r = LIBUSB_ERROR_NO_MEM; | 314 | 314 | goto err; | @@ -453,10 +453,10 @@ static int parse_configuration(struct libusb_context *ctx, | 453 | 453 | /* Copy any unknown descriptors into a storage area for */ | 454 | 454 | /* drivers to later parse */ | 455 | 455 | len = (int)(buffer - begin); | 456 | | - if (len) { | | 456 | + if (len > 0) { | 457 | 457 | /* FIXME: We should realloc and append here */ | 458 | 458 | if (!config->extra_length) { | 459 | | - config->extra = malloc(len); | | 459 | + config->extra = malloc((size_t)len); | 460 | 460 | if (!config->extra) { | 461 | 461 | r = LIBUSB_ERROR_NO_MEM; | 462 | 462 | goto err; | @@ -1163,7 +1163,7 @@ int API_EXPORTED libusb_get_string_descriptor_ascii(libusb_device_handle *dev_ha | 1163 | 1163 | if (r < 4) | 1164 | 1164 | return LIBUSB_ERROR_IO; | 1165 | 1165 |
| 1166 | | - langid = tbuf[2] | (tbuf[3] << 8); | | 1166 | + langid = (uint16_t)(tbuf[2] | (tbuf[3] << 8)); | 1167 | 1167 |
| 1168 | 1168 | r = libusb_get_string_descriptor(dev_handle, desc_index, langid, tbuf, | 1169 | 1169 | sizeof(tbuf)); | |
Collapse file Copy file name to clipboardExpand all lines: libusb/hotplug.h +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -36,16 +36,16 @@ enum usbi_hotplug_flags { | 36 | 36 | */ | 37 | 37 |
| 38 | 38 | /* The vendor_id field is valid for matching */ | 39 | | - USBI_HOTPLUG_VENDOR_ID_VALID = (1 << 3), | | 39 | + USBI_HOTPLUG_VENDOR_ID_VALID = (1U << 3), | 40 | 40 |
| 41 | 41 | /* The product_id field is valid for matching */ | 42 | | - USBI_HOTPLUG_PRODUCT_ID_VALID = (1 << 4), | | 42 | + USBI_HOTPLUG_PRODUCT_ID_VALID = (1U << 4), | 43 | 43 |
| 44 | 44 | /* The dev_class field is valid for matching */ | 45 | | - USBI_HOTPLUG_DEV_CLASS_VALID = (1 << 5), | | 45 | + USBI_HOTPLUG_DEV_CLASS_VALID = (1U << 5), | 46 | 46 |
| 47 | 47 | /* This callback has been unregistered and needs to be freed */ | 48 | | - USBI_HOTPLUG_NEEDS_FREE = (1 << 6), | | 48 | + USBI_HOTPLUG_NEEDS_FREE = (1U << 6), | 49 | 49 | }; | 50 | 50 |
| 51 | 51 | /** \ingroup hotplug | |
Collapse file Copy file name to clipboardExpand all lines: libusb/io.c +11-5Lines changed: 11 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1248,20 +1248,26 @@ static int calculate_timeout(struct usbi_transfer *transfer) | 1248 | 1248 | * use it on a non-isochronous endpoint. If you do this, ensure that at time | 1249 | 1249 | * of submission, num_iso_packets is 0 and that type is set appropriately. | 1250 | 1250 | * | 1251 | | - * \param iso_packets number of isochronous packet descriptors to allocate | | 1251 | + * \param iso_packets number of isochronous packet descriptors to allocate. Must be non-negative. | 1252 | 1252 | * \returns a newly allocated transfer, or NULL on error | 1253 | 1253 | */ | 1254 | 1254 | DEFAULT_VISIBILITY | 1255 | 1255 | struct libusb_transfer * LIBUSB_CALL libusb_alloc_transfer( | 1256 | 1256 | int iso_packets) | 1257 | 1257 | { | 1258 | 1258 | struct libusb_transfer *transfer; | 1259 | | - size_t os_alloc_size = usbi_backend.transfer_priv_size; | 1260 | | - size_t alloc_size = sizeof(struct usbi_transfer) | | 1259 | + size_t os_alloc_size; | | 1260 | + size_t alloc_size; | | 1261 | + struct usbi_transfer *itransfer; | | 1262 | + | | 1263 | + assert(iso_packets >= 0); | | 1264 | + | | 1265 | + os_alloc_size = usbi_backend.transfer_priv_size; | | 1266 | + alloc_size = sizeof(struct usbi_transfer) | 1261 | 1267 | + sizeof(struct libusb_transfer) | 1262 | | - + (sizeof(struct libusb_iso_packet_descriptor) * iso_packets) | | 1268 | + + (sizeof(struct libusb_iso_packet_descriptor) * (size_t)iso_packets) | 1263 | 1269 | + os_alloc_size; | 1264 | | - struct usbi_transfer *itransfer = calloc(1, alloc_size); | | 1270 | + itransfer = calloc(1, alloc_size); | 1265 | 1271 | if (!itransfer) | 1266 | 1272 | return NULL; | 1267 | 1273 |
| |
Collapse file Copy file name to clipboardExpand all lines: libusb/libusb.h +15-14Lines changed: 15 additions & 14 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -577,7 +577,7 @@ struct libusb_endpoint_descriptor { | 577 | 577 | * it will store them here, should you wish to parse them. */ | 578 | 578 | const unsigned char *extra; | 579 | 579 |
| 580 | | - /** Length of the extra descriptors, in bytes. */ | | 580 | + /** Length of the extra descriptors, in bytes. Must be non-negative. */ | 581 | 581 | int extra_length; | 582 | 582 | }; | 583 | 583 |
| @@ -627,7 +627,7 @@ struct libusb_interface_descriptor { | 627 | 627 | * it will store them here, should you wish to parse them. */ | 628 | 628 | const unsigned char *extra; | 629 | 629 |
| 630 | | - /** Length of the extra descriptors, in bytes. */ | | 630 | + /** Length of the extra descriptors, in bytes. Must be non-negative. */ | 631 | 631 | int extra_length; | 632 | 632 | }; | 633 | 633 |
| @@ -639,7 +639,8 @@ struct libusb_interface { | 639 | 639 | * by the num_altsetting field. */ | 640 | 640 | const struct libusb_interface_descriptor *altsetting; | 641 | 641 |
| 642 | | - /** The number of alternate settings that belong to this interface */ | | 642 | + /** The number of alternate settings that belong to this interface. | | 643 | + * Must be non-negative. */ | 643 | 644 | int num_altsetting; | 644 | 645 | }; | 645 | 646 |
| @@ -686,7 +687,7 @@ struct libusb_config_descriptor { | 686 | 687 | * descriptors, it will store them here, should you wish to parse them. */ | 687 | 688 | const unsigned char *extra; | 688 | 689 |
| 689 | | - /** Length of the extra descriptors, in bytes. */ | | 690 | + /** Length of the extra descriptors, in bytes. Must be non-negative. */ | 690 | 691 | int extra_length; | 691 | 692 | }; | 692 | 693 |
| @@ -1134,19 +1135,19 @@ enum libusb_transfer_status { | 1134 | 1135 | * libusb_transfer.flags values */ | 1135 | 1136 | enum libusb_transfer_flags { | 1136 | 1137 | /** Report short frames as errors */ | 1137 | | - LIBUSB_TRANSFER_SHORT_NOT_OK = 1<<0, | | 1138 | + LIBUSB_TRANSFER_SHORT_NOT_OK = 1U << 0, | 1138 | 1139 |
| 1139 | 1140 | /** Automatically free() transfer buffer during libusb_free_transfer(). | 1140 | 1141 | * Note that buffers allocated with libusb_dev_mem_alloc() should not | 1141 | 1142 | * be attempted freed in this way, since free() is not an appropriate | 1142 | 1143 | * way to release such memory. */ | 1143 | | - LIBUSB_TRANSFER_FREE_BUFFER = 1<<1, | | 1144 | + LIBUSB_TRANSFER_FREE_BUFFER = 1U << 1, | 1144 | 1145 |
| 1145 | 1146 | /** Automatically call libusb_free_transfer() after callback returns. | 1146 | 1147 | * If this flag is set, it is illegal to call libusb_free_transfer() | 1147 | 1148 | * from your transfer callback, as this will result in a double-free | 1148 | 1149 | * when this flag is acted upon. */ | 1149 | | - LIBUSB_TRANSFER_FREE_TRANSFER = 1<<2, | | 1150 | + LIBUSB_TRANSFER_FREE_TRANSFER = 1U << 2, | 1150 | 1151 |
| 1151 | 1152 | /** Terminate transfers that are a multiple of the endpoint's | 1152 | 1153 | * wMaxPacketSize with an extra zero length packet. This is useful | @@ -1171,7 +1172,7 @@ enum libusb_transfer_flags { | 1171 | 1172 | * | 1172 | 1173 | * Available since libusb-1.0.9. | 1173 | 1174 | */ | 1174 | | - LIBUSB_TRANSFER_ADD_ZERO_PACKET = 1 << 3, | | 1175 | + LIBUSB_TRANSFER_ADD_ZERO_PACKET = 1U << 3, | 1175 | 1176 | }; | 1176 | 1177 |
| 1177 | 1178 | /** \ingroup libusb_asyncio | @@ -1232,7 +1233,7 @@ struct libusb_transfer { | 1232 | 1233 | * to determine if errors occurred. */ | 1233 | 1234 | enum libusb_transfer_status status; | 1234 | 1235 |
| 1235 | | - /** Length of the data buffer */ | | 1236 | + /** Length of the data buffer. Must be non-negative. */ | 1236 | 1237 | int length; | 1237 | 1238 |
| 1238 | 1239 | /** Actual length of data that was transferred. Read-only, and only for | @@ -1251,7 +1252,7 @@ struct libusb_transfer { | 1251 | 1252 | unsigned char *buffer; | 1252 | 1253 |
| 1253 | 1254 | /** Number of isochronous packets. Only used for I/O with isochronous | 1254 | | - * endpoints. */ | | 1255 | + * endpoints. Must be non-negative. */ | 1255 | 1256 | int num_iso_packets; | 1256 | 1257 |
| 1257 | 1258 | /** Isochronous packet descriptors, for isochronous transfers only. */ | @@ -1910,10 +1911,10 @@ typedef int libusb_hotplug_callback_handle; | 1910 | 1911 | * Flags for hotplug events */ | 1911 | 1912 | typedef enum { | 1912 | 1913 | /** Default value when not using any flags. */ | 1913 | | - LIBUSB_HOTPLUG_NO_FLAGS = 0, | | 1914 | + LIBUSB_HOTPLUG_NO_FLAGS = 0U, | 1914 | 1915 |
| 1915 | 1916 | /** Arm the callback and fire it for all matching currently attached devices. */ | 1916 | | - LIBUSB_HOTPLUG_ENUMERATE = 1<<0, | | 1917 | + LIBUSB_HOTPLUG_ENUMERATE = 1U << 0, | 1917 | 1918 | } libusb_hotplug_flag; | 1918 | 1919 |
| 1919 | 1920 | /** \ingroup libusb_hotplug | @@ -1923,12 +1924,12 @@ typedef enum { | 1923 | 1924 | * Hotplug events */ | 1924 | 1925 | typedef enum { | 1925 | 1926 | /** A device has been plugged in and is ready to use */ | 1926 | | - LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED = 0x01, | | 1927 | + LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED = 0x01U, | 1927 | 1928 |
| 1928 | 1929 | /** A device has left and is no longer available. | 1929 | 1930 | * It is the user's responsibility to call libusb_close on any handle associated with a disconnected device. | 1930 | 1931 | * It is safe to call libusb_get_device_descriptor on a device that has left */ | 1931 | | - LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT = 0x02, | | 1932 | + LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT = 0x02U, | 1932 | 1933 | } libusb_hotplug_event; | 1933 | 1934 |
| 1934 | 1935 | /** \ingroup libusb_hotplug | |
|