dhcp: split out DHCP_MESSAGE_HEADER_DEFINITION to allow building test-dhcp-server.c with -Werror=flex-array-member-not-at-end

This commit is contained in:
Yu Watanabe
2025-04-04 01:12:54 +09:00
parent cec81b234c
commit 5b160db520
2 changed files with 21 additions and 16 deletions

View File

@@ -19,22 +19,25 @@
* MIN_V6ONLY_WAIT: The lower boundary for V6ONLY_WAIT. Value: 300 seconds */
#define MIN_V6ONLY_WAIT_USEC (300U * USEC_PER_SEC)
struct DHCPMessage {
uint8_t op;
uint8_t htype;
uint8_t hlen;
uint8_t hops;
be32_t xid;
be16_t secs;
be16_t flags;
be32_t ciaddr;
be32_t yiaddr;
be32_t siaddr;
be32_t giaddr;
uint8_t chaddr[16];
uint8_t sname[64];
uint8_t file[128];
#define DHCP_MESSAGE_HEADER_DEFINITION \
uint8_t op; \
uint8_t htype; \
uint8_t hlen; \
uint8_t hops; \
be32_t xid; \
be16_t secs; \
be16_t flags; \
be32_t ciaddr; \
be32_t yiaddr; \
be32_t siaddr; \
be32_t giaddr; \
uint8_t chaddr[16]; \
uint8_t sname[64]; \
uint8_t file[128]; \
be32_t magic;
struct DHCPMessage {
DHCP_MESSAGE_HEADER_DEFINITION;
uint8_t options[];
} _packed_;

View File

@@ -82,7 +82,9 @@ static int test_basic(bool bind_to_interface) {
static void test_message_handler(void) {
_cleanup_(sd_dhcp_server_unrefp) sd_dhcp_server *server = NULL;
struct {
DHCPMessage message;
struct {
DHCP_MESSAGE_HEADER_DEFINITION;
} _packed_ message;
struct {
uint8_t code;
uint8_t length;