Misc: Refactor zero-length array declarations
authorChris Dickens <christopher.a.dickens@gmail.com>
Wed, 5 Jul 2017 20:09:29 +0000 (13:09 -0700)
committerChris Dickens <christopher.a.dickens@gmail.com>
Thu, 6 Jul 2017 21:26:46 +0000 (14:26 -0700)
Instead of checking for __STDC_VERSION__ at every instance, define a
ZERO_SIZED_ARRAY macro that has the appropriate definition and use that
everywhere it is needed.

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
libusb/libusb.h
libusb/libusbi.h
libusb/version_nano.h

index f0f6d71..70ee2ca 100644 (file)
@@ -61,6 +61,12 @@ typedef unsigned __int32  uint32_t;
 #include <time.h>
 #include <limits.h>
 
+#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
+#define ZERO_SIZED_ARRAY               /* [] - valid C99 code */
+#else
+#define ZERO_SIZED_ARRAY       0       /* [0] - non-standard, but usually working code */
+#endif
+
 /* 'interface' might be defined as a macro on Windows, so we need to
  * undefine it so as not to break the current libusb API, because
  * libusb_config_descriptor has an 'interface' member
@@ -729,13 +735,7 @@ struct libusb_bos_dev_capability_descriptor {
        /** Device Capability type */
        uint8_t bDevCapabilityType;
        /** Device Capability data (bLength - 3 bytes) */
-       uint8_t dev_capability_data
-#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
-       [] /* valid C99 code */
-#else
-       [0] /* non-standard, but usually working code */
-#endif
-       ;
+       uint8_t dev_capability_data[ZERO_SIZED_ARRAY];
 };
 
 /** \ingroup libusb_desc
@@ -760,13 +760,7 @@ struct libusb_bos_descriptor {
        uint8_t  bNumDeviceCaps;
 
        /** bNumDeviceCap Device Capability Descriptors */
-       struct libusb_bos_dev_capability_descriptor *dev_capability
-#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
-       [] /* valid C99 code */
-#else
-       [0] /* non-standard, but usually working code */
-#endif
-       ;
+       struct libusb_bos_dev_capability_descriptor *dev_capability[ZERO_SIZED_ARRAY];
 };
 
 /** \ingroup libusb_desc
@@ -1256,13 +1250,7 @@ struct libusb_transfer {
        int num_iso_packets;
 
        /** Isochronous packet descriptors, for isochronous transfers only. */
-       struct libusb_iso_packet_descriptor iso_packet_desc
-#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
-       [] /* valid C99 code */
-#else
-       [0] /* non-standard, but usually working code */
-#endif
-       ;
+       struct libusb_iso_packet_descriptor iso_packet_desc[ZERO_SIZED_ARRAY];
 };
 
 /** \ingroup libusb_misc
index 026ed0f..3ae4635 100644 (file)
@@ -396,12 +396,7 @@ struct libusb_device {
        struct libusb_device_descriptor device_descriptor;
        int attached;
 
-       unsigned char os_priv
-#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
-       [] /* valid C99 code */
-#else
-       [0] /* non-standard, but usually working code */
-#endif
+       unsigned char os_priv[ZERO_SIZED_ARRAY]
 #if defined(OS_SUNOS)
        __attribute__ ((aligned (8)));
 #else
@@ -417,12 +412,8 @@ struct libusb_device_handle {
        struct list_head list;
        struct libusb_device *dev;
        int auto_detach_kernel_driver;
-       unsigned char os_priv
-#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
-       [] /* valid C99 code */
-#else
-       [0] /* non-standard, but usually working code */
-#endif
+
+       unsigned char os_priv[ZERO_SIZED_ARRAY]
 #if defined(OS_SUNOS)
        __attribute__ ((aligned (8)));
 #else
@@ -581,13 +572,7 @@ void usbi_remove_pollfd(struct libusb_context *ctx, int fd);
 struct discovered_devs {
        size_t len;
        size_t capacity;
-       struct libusb_device *devices
-#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
-       [] /* valid C99 code */
-#else
-       [0] /* non-standard, but usually working code */
-#endif
-       ;
+       struct libusb_device *devices[ZERO_SIZED_ARRAY];
 };
 
 struct discovered_devs *discovered_devs_append(
index f2515f9..90736cc 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 11203
+#define LIBUSB_NANO 11204