From e8b0486caf67a0f49ef44eacac1b3c8da4421997 Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Wed, 27 Dec 2023 23:47:19 -0500 Subject: [PATCH] libusb.h: Rename ZERO_SIZED_ARRAY to LIBUSB_FLEXIBLE_ARRAY This reflects the C99 terminology, instead of the old hack of using a zero sized array. Also adds the LIBUSB prefix to avoid namespace colisions, as this is present in a public header. References #1409 --- libusb/libusb.h | 12 ++++++------ libusb/libusbi.h | 4 ++-- libusb/version_nano.h | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libusb/libusb.h b/libusb/libusb.h index ec14e7e79..0f443ed12 100644 --- a/libusb/libusb.h +++ b/libusb/libusb.h @@ -50,9 +50,9 @@ typedef SSIZE_T ssize_t; #include #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) -#define ZERO_SIZED_ARRAY /* [] - valid C99 code */ +#define LIBUSB_FLEXIBLE_ARRAY /* [] - valid C99 code */ #else -#define ZERO_SIZED_ARRAY 0 /* [0] - non-standard, but usually working code */ +#define LIBUSB_FLEXIBLE_ARRAY 0 /* [0] - non-standard, but usually working code */ #endif /* __STDC_VERSION__ */ /* 'interface' might be defined as a macro on Windows, so we need to @@ -857,7 +857,7 @@ struct libusb_bos_dev_capability_descriptor { uint8_t bDevCapabilityType; /** Device Capability data (bLength - 3 bytes) */ - uint8_t dev_capability_data[ZERO_SIZED_ARRAY]; + uint8_t dev_capability_data[LIBUSB_FLEXIBLE_ARRAY]; }; /** \ingroup libusb_desc @@ -882,7 +882,7 @@ struct libusb_bos_descriptor { uint8_t bNumDeviceCaps; /** bNumDeviceCap Device Capability Descriptors */ - struct libusb_bos_dev_capability_descriptor *dev_capability[ZERO_SIZED_ARRAY]; + struct libusb_bos_dev_capability_descriptor *dev_capability[LIBUSB_FLEXIBLE_ARRAY]; }; /** \ingroup libusb_desc @@ -1004,7 +1004,7 @@ struct libusb_platform_descriptor { uint8_t PlatformCapabilityUUID[16]; /** Capability data (bLength - 20) */ - uint8_t CapabilityData[ZERO_SIZED_ARRAY]; + uint8_t CapabilityData[LIBUSB_FLEXIBLE_ARRAY]; }; /** \ingroup libusb_asyncio @@ -1384,7 +1384,7 @@ struct libusb_transfer { int num_iso_packets; /** Isochronous packet descriptors, for isochronous transfers only. */ - struct libusb_iso_packet_descriptor iso_packet_desc[ZERO_SIZED_ARRAY]; + struct libusb_iso_packet_descriptor iso_packet_desc[LIBUSB_FLEXIBLE_ARRAY]; }; /** \ingroup libusb_misc diff --git a/libusb/libusbi.h b/libusb/libusbi.h index 5c65dc29a..d0d44177c 100644 --- a/libusb/libusbi.h +++ b/libusb/libusbi.h @@ -679,7 +679,7 @@ struct usbi_interface_descriptor { struct usbi_string_descriptor { uint8_t bLength; uint8_t bDescriptorType; - uint16_t wData[ZERO_SIZED_ARRAY]; + uint16_t wData[LIBUSB_FLEXIBLE_ARRAY]; } LIBUSB_PACKED; struct usbi_bos_descriptor { @@ -893,7 +893,7 @@ static inline void *usbi_get_transfer_priv(struct usbi_transfer *itransfer) struct discovered_devs { size_t len; size_t capacity; - struct libusb_device *devices[ZERO_SIZED_ARRAY]; + struct libusb_device *devices[LIBUSB_FLEXIBLE_ARRAY]; }; struct discovered_devs *discovered_devs_append( diff --git a/libusb/version_nano.h b/libusb/version_nano.h index a3f12625a..1e3ac7183 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 11857 +#define LIBUSB_NANO 11858