From 49184fb938e1c9bc6486c0936872224d85df27b8 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Mon, 3 May 2021 16:13:48 +0200 Subject: [PATCH] net: circumvent stringop-overflow error With the update to GCC 10, the compiler stopped with an error when compiling places where a MAC address is copied from outside into a packed object using the Net::Netaddress::copy method (e.g. in Net::Arp_packet::dst_mac(Mac_address)): ! error: writing 6 bytes into a region of size 4 [-Werror=stringop-overflow=] While trying to find a clean solution for this error, I found posts on gcc.gnu.org and github that stated that the size calculations that cause these errors are incorrect. Indeed, I could verify that the actual size of the two regions was static and exactly the same in places were the error occured. Furthermore, I couldn't find a way of making it more clear to the compiler that the sizes are the same. By accident, we found that using the address of the first element of the array that forms the second region instead of the array address itself, somehow circumvents the error. Fixes #4109 --- repos/os/include/net/netaddress.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repos/os/include/net/netaddress.h b/repos/os/include/net/netaddress.h index 83c5120839..f70c0d80f5 100644 --- a/repos/os/include/net/netaddress.h +++ b/repos/os/include/net/netaddress.h @@ -52,7 +52,7 @@ struct Net::Network_address ** Helper methods ** *********************/ - void copy(void *dst) { Genode::memcpy(dst, addr, LEN); } + void copy(void *dst) { Genode::memcpy(dst, &addr[0], LEN); } void print(Genode::Output &output) const {