From: Roy Marples Date: Tue, 23 Jun 2020 10:31:25 +0000 (+0100) Subject: Linux: redefine NLA_ALIGNTO as 4U X-Git-Tag: v9.1.3~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=449ed1897e27251f0c09cd6729aed93462f32d42;p=thirdparty%2Fdhcpcd.git Linux: redefine NLA_ALIGNTO as 4U This removes the last of the alignment issues reported by clang in the linux driver for dhcpcd. Upstream has no interest in fixing this and local testing shows it works fine on all platforms I have. https://www.spinics.net/lists/netdev/msg646934.html --- diff --git a/src/if-linux.c b/src/if-linux.c index 2ff720c6..6493cd03 100644 --- a/src/if-linux.c +++ b/src/if-linux.c @@ -110,7 +110,19 @@ int if_getssid_wext(const char *ifname, uint8_t *ssid); #define SOL_NETLINK 270 #endif -/* Someone should fix kernel headers for clang alignment warnings . */ +/* + * Someone should fix kernel headers for clang alignment warnings. + * But this is unlikely. + * https://www.spinics.net/lists/netdev/msg646934.html + */ + +#undef NLA_ALIGNTO +#undef NLA_ALIGN +#undef NLA_HDRLEN +#define NLA_ALIGNTO 4U +#define NLA_ALIGN(len) (((len) + NLA_ALIGNTO - 1) & ~(NLA_ALIGNTO - 1)) +#define NLA_HDRLEN ((int) NLA_ALIGN(sizeof(struct nlattr))) + #undef IFA_RTA #define IFA_RTA(r) ((struct rtattr *)(void *)(((char *)(r)) \ + NLMSG_ALIGN(sizeof(struct ifaddrmsg))))