]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
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 70119c16a40985ed4d00929cbb7e06270aa72036..3aab5d05ef35b9dd7f02840a969db41a81406f13 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 7c8eb3224cc95c7baa4e5f1fbb1fff65b1843666..344f665dd067c32996aa90aca4e90d676ed7c54b 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 d57404a9d9f3e358017817cd53bce32f74eb528b..9ecc754e4ae3d62f06a475e70bd1e831b8506522 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 28411667766ab6eb8c3f88a4c029c1c0082ec061..eea11320b1c289fba4b44bac8f4963693c2de32d 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 bd68beebde4d15651a7fe5643372790351ef2de0..baffcc0deb986b22dcb250d1e0d889fb9f0fe17a 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 ea835af3d468830f891bed001089795a717c30f3..20d288769d002be4007af6495d541ab6022b486f 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 a811ee30f58707eaeb67936c144306f5ef4cb106..1901060c3f817cbd6a0a8fe5aadfb06b3a3b347f 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 5db950b368f432eecea5b0c3ccc33d6c24c4cb0b..dd5f0f9339b6e0948433ca6e853444ba3183d588 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)