From 4987a474469d6c7c50ea2a8997cdd79f5059cb0c Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sat, 12 Sep 2020 20:56:41 +0200 Subject: [PATCH] CLEANUP: tree-wide: use VAR_ARRAY instead of [0] in various definitions 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 | 4 ++-- include/haproxy/hpack-tbl-t.h | 2 +- include/haproxy/htx-t.h | 4 ++-- include/haproxy/port_range-t.h | 2 +- include/haproxy/proxy-t.h | 2 +- include/haproxy/shctx-t.h | 4 ++-- include/haproxy/ssl_ckch-t.h | 2 +- include/haproxy/ssl_sock-t.h | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/haproxy/connection-t.h b/include/haproxy/connection-t.h index 70119c16a4..3aab5d05ef 100644 --- a/include/haproxy/connection-t.h +++ b/include/haproxy/connection-t.h @@ -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)); diff --git a/include/haproxy/hpack-tbl-t.h b/include/haproxy/hpack-tbl-t.h index 7c8eb3224c..344f665dd0 100644 --- a/include/haproxy/hpack-tbl-t.h +++ b/include/haproxy/hpack-tbl-t.h @@ -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 */ diff --git a/include/haproxy/htx-t.h b/include/haproxy/htx-t.h index d57404a9d9..9ecc754e4a 100644 --- a/include/haproxy/htx-t.h +++ b/include/haproxy/htx-t.h @@ -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 */ diff --git a/include/haproxy/port_range-t.h b/include/haproxy/port_range-t.h index 2841166776..eea11320b1 100644 --- a/include/haproxy/port_range-t.h +++ b/include/haproxy/port_range-t.h @@ -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 ports, in host byte order */ + uint16_t ports[VAR_ARRAY]; /* array of ports, in host byte order */ }; #endif /* _HAPROXY_PORT_RANGE_T_H */ diff --git a/include/haproxy/proxy-t.h b/include/haproxy/proxy-t.h index bd68beebde..baffcc0deb 100644 --- a/include/haproxy/proxy-t.h +++ b/include/haproxy/proxy-t.h @@ -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 { diff --git a/include/haproxy/shctx-t.h b/include/haproxy/shctx-t.h index ea835af3d4..20d288769d 100644 --- a/include/haproxy/shctx-t.h +++ b/include/haproxy/shctx-t.h @@ -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 */ diff --git a/include/haproxy/ssl_ckch-t.h b/include/haproxy/ssl_ckch-t.h index a811ee30f5..1901060c3f 100644 --- a/include/haproxy/ssl_ckch-t.h +++ b/include/haproxy/ssl_ckch-t.h @@ -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 */ diff --git a/include/haproxy/ssl_sock-t.h b/include/haproxy/ssl_sock-t.h index 5db950b368..dd5f0f9339 100644 --- a/include/haproxy/ssl_sock-t.h +++ b/include/haproxy/ssl_sock-t.h @@ -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) -- 2.39.5