]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Linux: redefine NLA_ALIGNTO as 4U
authorRoy Marples <roy@marples.name>
Tue, 23 Jun 2020 10:31:25 +0000 (11:31 +0100)
committerRoy Marples <roy@marples.name>
Tue, 23 Jun 2020 10:31:25 +0000 (11:31 +0100)
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

src/if-linux.c

index 2ff720c6d5f5c70d83cc709412c53c6c9067059b..6493cd031fa6cffd625db69c605441291459a9db 100644 (file)
@@ -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))))