[U-Boot] [PATCH 1/1] net: remove superfluous __packed attribute

Heinrich Schuchardt xypron.glpk at gmx.de
Thu Oct 3 17:01:22 UTC 2019


struct ip_udp_hdr is naturally packed. There is no point in adding a
__packed attribute. With the attribute the network stack does not compile
using GCC 9.2.1:

net/net.c: In function ‘net_process_received_packet’:
net/net.c:1288:23: error: taking address of packed member of ‘struct
ip_udp_hdr’ may result in an unaligned pointer value
[-Werror=address-of-packed-member]
 1288 |    sumptr = (ushort *)&(ip->udp_src);
      |                       ^~~~~~~~~~~~~~

So let's remove the attribute.

Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
---
 include/net.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net.h b/include/net.h
index 75a16e4c8f..bd875b56f5 100644
--- a/include/net.h
+++ b/include/net.h
@@ -390,7 +390,7 @@ struct ip_udp_hdr {
 	u16		udp_dst;	/* UDP destination port		*/
 	u16		udp_len;	/* Length of UDP packet		*/
 	u16		udp_xsum;	/* Checksum			*/
-} __attribute__((packed));
+};

 #define IP_UDP_HDR_SIZE		(sizeof(struct ip_udp_hdr))
 #define UDP_HDR_SIZE		(IP_UDP_HDR_SIZE - IP_HDR_SIZE)
--
2.23.0



More information about the U-Boot mailing list