CLEANUP: tree-wide: use VAR_ARRAY instead of [0] in various definitions
authorWilly Tarreau <w@1wt.eu>
Sat, 12 Sep 2020 18:56:41 +0000 (20:56 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 12 Sep 2020 18:56:41 +0000 (20:56 +0200)
Surprisingly there were still a number of [0] definitions for variable
sized arrays in certain structures all over the code. We need to use
VAR_ARRAY instead of zero to accommodate various compilers' preferences,
as zero was used only on old ones and tends to report errors on new ones.

include/haproxy/connection-t.h
include/haproxy/hpack-tbl-t.h
include/haproxy/htx-t.h
include/haproxy/port_range-t.h
include/haproxy/proxy-t.h
include/haproxy/shctx-t.h
include/haproxy/ssl_ckch-t.h
include/haproxy/ssl_sock-t.h

index 70119c1..3aab5d0 100644 (file)
@@ -589,14 +589,14 @@ struct tlv {
        uint8_t type;
        uint8_t length_hi;
        uint8_t length_lo;
-       uint8_t value[0];
+       uint8_t value[VAR_ARRAY];
 }__attribute__((packed));
 
 struct tlv_ssl {
        struct tlv tlv;
        uint8_t client;
        uint32_t verify;
-       uint8_t sub_tlv[0];
+       uint8_t sub_tlv[VAR_ARRAY];
 }__attribute__((packed));
 
 
index 7c8eb32..344f665 100644 (file)
@@ -102,7 +102,7 @@ struct hpack_dht {
        uint16_t wrap;  /* number of allocated slots, wraps here */
        uint16_t head;  /* last inserted slot number */
        uint16_t used;  /* number of slots in use */
-       struct hpack_dte dte[0]; /* dynamic table entries */
+       struct hpack_dte dte[VAR_ARRAY]; /* dynamic table entries */
 };
 
 /* supported hpack encoding/decoding errors */
index d57404a..9ecc754 100644 (file)
@@ -194,7 +194,7 @@ struct htx_sl {
                              * corresponding EOH. -1 if unknown */
 
        unsigned int len[3]; /* length of different parts of the start-line */
-       char         l[0];
+       char         l[VAR_ARRAY];
 };
 
 /* Internal representation of an HTTP message */
@@ -218,7 +218,7 @@ struct htx {
        /* XXX 4 bytes unused */
 
        /* Blocks representing the HTTP message itself */
-       char blocks[0] __attribute__((aligned(8)));
+       char blocks[VAR_ARRAY] __attribute__((aligned(8)));
 };
 
 #endif /* _HAPROXY_HTX_T_H */
index 2841166..eea1132 100644 (file)
@@ -27,7 +27,7 @@
 
 struct port_range {
        int size, get, put_h, put_t;    /* range size, and get/put positions */
-       uint16_t ports[0];              /* array of <size> ports, in host byte order */
+       uint16_t ports[VAR_ARRAY];      /* array of <size> ports, in host byte order */
 };
 
 #endif /* _HAPROXY_PORT_RANGE_T_H */
index bd68bee..baffcc0 100644 (file)
@@ -249,7 +249,7 @@ struct error_snapshot {
 
        /**** protocol-specific part ****/
        union error_snapshot_ctx ctx;
-       char buf[0];                    /* copy of the beginning of the message for bufsize bytes */
+       char buf[VAR_ARRAY];                    /* copy of the beginning of the message for bufsize bytes */
 };
 
 struct proxy {
index ea835af..20d2887 100644 (file)
@@ -44,7 +44,7 @@ struct shared_block {
        unsigned int refcount;
        struct shared_block *last_reserved;
        struct shared_block *last_append;
-       unsigned char data[0];
+       unsigned char data[VAR_ARRAY];
 };
 
 struct shared_context {
@@ -61,7 +61,7 @@ struct shared_context {
        unsigned int max_obj_size;   /* maximum object size (in bytes). */
        void (*free_block)(struct shared_block *first, struct shared_block *block);
        short int block_size;
-       unsigned char data[0];
+       unsigned char data[VAR_ARRAY];
 };
 
 #endif /* __HAPROXY_SHCTX_T_H */
index a811ee3..1901060 100644 (file)
@@ -69,7 +69,7 @@ struct ckch_store {
        struct list ckch_inst; /* list of ckch_inst which uses this ckch_node */
        struct list crtlist_entry; /* list of entries which use this store */
        struct ebmb_node node;
-       char path[0];
+       char path[VAR_ARRAY];
 };
 
 /* forward declarations for ckch_inst */
index 5db950b..dd5f0f9 100644 (file)
@@ -223,7 +223,7 @@ struct ssl_sock_msg_callback {
 struct ssl_capture {
        unsigned long long int xxh64;
        unsigned char ciphersuite_len;
-       char ciphersuite[0];
+       char ciphersuite[VAR_ARRAY];
 };
 
 #if (HA_OPENSSL_VERSION_NUMBER >= 0x10101000L)