libusb: rename bNumDeviceCapabilities to bNumDeviceCaps for compatibility with libusb
THe member bNumDeviceCapabilities is referred to as bNumDeviceCaps in the upstream libusb project. To improve compatibility, we are renaming the member accordingly. For backward compatibility, a mocro will be defined to map bNumDeviceCapabilities to bNumDeviceCaps. See: https://github.com/libusb/libusb/commit/02ebafc85d3f219842cbabaf78abc8100b6656e5 Reviewed by: kevans Approved by: markj (mentor) MFC after: 2 weeks Sponsored by: FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D50740
This commit is contained in:
+4
-1
@@ -418,7 +418,10 @@ typedef struct libusb_bos_descriptor {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint16_t wTotalLength;
|
||||
uint8_t bNumDeviceCapabilities;
|
||||
#ifndef bNumDeviceCapabilities
|
||||
#define bNumDeviceCapabilities bNumDeviceCaps
|
||||
#endif
|
||||
uint8_t bNumDeviceCaps;
|
||||
struct libusb_usb_2_0_device_capability_descriptor *usb_2_0_ext_cap;
|
||||
struct libusb_ss_usb_device_capability_descriptor *ss_usb_cap;
|
||||
struct libusb_bos_dev_capability_descriptor **dev_capability;
|
||||
|
||||
@@ -470,10 +470,11 @@ libusb_parse_bos_descriptor(const void *buf, int len,
|
||||
ptr->bDescriptorType = dtype;
|
||||
ptr->wTotalLength = ((const uint8_t *)buf)[2] |
|
||||
(((const uint8_t *)buf)[3] << 8);
|
||||
ptr->bNumDeviceCapabilities = ((const uint8_t *)buf)[4];
|
||||
ptr->bNumDeviceCaps = ((const uint8_t *)buf)[4];
|
||||
ptr->usb_2_0_ext_cap = NULL;
|
||||
ptr->ss_usb_cap = NULL;
|
||||
ptr->dev_capability = calloc(ptr->bNumDeviceCapabilities, sizeof(void *));
|
||||
ptr->dev_capability = calloc(ptr->bNumDeviceCaps,
|
||||
sizeof(void *));
|
||||
if (ptr->dev_capability == NULL) {
|
||||
free(ptr);
|
||||
return (LIBUSB_ERROR_NO_MEM);
|
||||
@@ -485,7 +486,7 @@ libusb_parse_bos_descriptor(const void *buf, int len,
|
||||
if (dlen >= 3 &&
|
||||
ptr != NULL &&
|
||||
dtype == LIBUSB_DT_DEVICE_CAPABILITY) {
|
||||
if (index != ptr->bNumDeviceCapabilities) {
|
||||
if (index != ptr->bNumDeviceCaps) {
|
||||
ptr->dev_capability[index] = malloc(dlen);
|
||||
if (ptr->dev_capability[index] == NULL) {
|
||||
libusb_free_bos_descriptor(ptr);
|
||||
@@ -542,7 +543,7 @@ libusb_parse_bos_descriptor(const void *buf, int len,
|
||||
}
|
||||
|
||||
if (ptr != NULL) {
|
||||
ptr->bNumDeviceCapabilities = index;
|
||||
ptr->bNumDeviceCaps = index;
|
||||
return (0); /* success */
|
||||
}
|
||||
|
||||
@@ -557,7 +558,7 @@ libusb_free_bos_descriptor(struct libusb_bos_descriptor *bos)
|
||||
if (bos == NULL)
|
||||
return;
|
||||
|
||||
for (i = 0; i != bos->bNumDeviceCapabilities; i++)
|
||||
for (i = 0; i != bos->bNumDeviceCaps; i++)
|
||||
free(bos->dev_capability[i]);
|
||||
free(bos->dev_capability);
|
||||
free(bos);
|
||||
|
||||
@@ -298,11 +298,15 @@ LIBUSB20_MAKE_STRUCT(LIBUSB20_USB_20_DEVCAP_DESC);
|
||||
|
||||
LIBUSB20_MAKE_STRUCT(LIBUSB20_SS_USB_DEVCAP_DESC);
|
||||
|
||||
#ifndef bNumDeviceCapabilities
|
||||
#define bNumDeviceCapabilities bNumDeviceCaps
|
||||
#endif
|
||||
|
||||
#define LIBUSB20_BOS_DESCRIPTOR(m,n) \
|
||||
m(n, UINT8_T, bLength, ) \
|
||||
m(n, UINT8_T, bDescriptorType, ) \
|
||||
m(n, UINT16_T, wTotalLength, ) \
|
||||
m(n, UINT8_T, bNumDeviceCapabilities, ) \
|
||||
m(n, UINT8_T, bNumDeviceCaps, ) \
|
||||
|
||||
LIBUSB20_MAKE_STRUCT(LIBUSB20_BOS_DESCRIPTOR);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user