Skip to content

Commit

Permalink
libusb.h: Rename ZERO_SIZED_ARRAY to LIBUSB_FLEXIBLE_ARRAY
Browse files Browse the repository at this point in the history
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 libusb#1409
  • Loading branch information
seanm authored and tormodvolden committed Jan 9, 2024
1 parent 5ad1d99 commit e8b0486
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions libusb/libusb.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ typedef SSIZE_T ssize_t;
#include <time.h>

#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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions libusb/libusbi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion libusb/version_nano.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define LIBUSB_NANO 11857
#define LIBUSB_NANO 11858

0 comments on commit e8b0486

Please sign in to comment.