Build fails with gcc 9: CC slirp/ndp_table.o slirp/ndp_table.c: In function ‘ndp_table_add’: slirp/ndp_table.c:31:23: error: taking address of packed member of ‘struct ndpentry’ may result in an unaligned pointer value [-Werror=address-of-packed-member] 31 | if (in6_equal(&ndp_table->table[i].ip_addr, &ip_addr)) { | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ slirp/ndp_table.c: In function ‘ndp_table_search’: slirp/ndp_table.c:75:23: error: taking address of packed member of ‘struct ndpentry’ may result in an unaligned pointer value [-Werror=address-of-packed-member] 75 | if (in6_equal(&ndp_table->table[i].ip_addr, &ip_addr)) { | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors
All members of struct ndpentry are naturally aligned. Drop the QEMU_PACKED attribute and check there isn't unwanted padding at build time. Signed-off-by: Greg Kurz <gr...@kaod.org> --- slirp/slirp.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/slirp/slirp.h b/slirp/slirp.h index 752a4cd8c81c..97552962697a 100644 --- a/slirp/slirp.h +++ b/slirp/slirp.h @@ -106,7 +106,9 @@ bool arp_table_search(Slirp *slirp, uint32_t ip_addr, struct ndpentry { unsigned char eth_addr[ETH_ALEN]; /* sender hardware address */ struct in6_addr ip_addr; /* sender IP address */ -} SLIRP_PACKED; +}; + +G_STATIC_ASSERT(sizeof(struct ndpentry) == 22); #define NDP_TABLE_SIZE 16