From: Heinrich Schuchardt Date: Sun, 14 Jul 2019 20:02:13 +0000 (+0200) Subject: net: unaligned copying of unsigned long X-Git-Tag: v2019.10-rc1~23^2 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=bbfc562719c463ba6e7b03125aedd5720a325d2d;p=oweals%2Fu-boot.git net: unaligned copying of unsigned long The inline functions net_read_u32() and net_copy_u32() have been created to copy unaligned u32. But this is not obvious to the compiler. GCC 9.1 introduces a check -Werror=address-of-packed-member which leads to a build error on Travis CI: net/bootp.c: In function ‘dhcp_send_request_packet’: net/bootp.c:1011:27: error: taking address of packed member of ‘struct bootp_hdr’ may result in an unaligned pointer value [-Werror=address-of-packed-member] 1011 | net_copy_u32(&bp->bp_id, &bp_offer->bp_id); Change the type of the function parameters to void * to avoid the build error. Reported-by: Ramon Fried Signed-off-by: Heinrich Schuchardt Acked-by: Joe Hershberger --- diff --git a/include/net.h b/include/net.h index 44b32385c4..7684076af6 100644 --- a/include/net.h +++ b/include/net.h @@ -728,7 +728,7 @@ static inline struct in_addr net_read_ip(void *from) } /* return ulong *in network byteorder* */ -static inline u32 net_read_u32(u32 *from) +static inline u32 net_read_u32(void *from) { u32 l; @@ -749,7 +749,7 @@ static inline void net_copy_ip(void *to, void *from) } /* copy ulong */ -static inline void net_copy_u32(u32 *to, u32 *from) +static inline void net_copy_u32(void *to, void *from) { memcpy((void *)to, (void *)from, sizeof(u32)); }