Skip to contentSkip to conversation

netlink: remove duplicated NLMSG_ALIGN

PATCH Applied Hong Zhiguo 3 participants 3 messages Mar 26, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netlink: remove duplicated NLMSG_ALIGN

NLMSG_HDRLEN is already aligned value. It's for directly reference without extra alignment.

The redundant alignment here may confuse the API users.

---
 include/uapi/linux/netlink.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/netlink.h +1 -1
index 78d5b8a..32a354f 100644
@@ -78,7 +78,7 @@ struct nlmsghdr {
 #define NLMSG_ALIGNTO	4U
 #define NLMSG_ALIGN(len) ( ((len)+NLMSG_ALIGNTO-1) & ~(NLMSG_ALIGNTO-1) )
 #define NLMSG_HDRLEN	 ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))
-#define NLMSG_LENGTH(len) ((len)+NLMSG_ALIGN(NLMSG_HDRLEN))
+#define NLMSG_LENGTH(len) ((len) + NLMSG_HDRLEN)
 #define NLMSG_SPACE(len) NLMSG_ALIGN(NLMSG_LENGTH(len))
 #define NLMSG_DATA(nlh)  ((void*)(((char*)nlh) + NLMSG_LENGTH(0)))
 #define NLMSG_NEXT(nlh,len)	 ((len) -= NLMSG_ALIGN((nlh)->nlmsg_len), \
Signature · 1 line
1.7.10.4
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Hong Zhiguo

NLMSG_HDRLEN is already aligned value. It's for directly reference without extra alignment.

The redundant alignment here may confuse the API users.

This is actually an obsoleted API that we only want to keep around for backwards compatibility with user space. It would be great to replace all in kernel usages of NLMSG_LENGTH() with the type safe variants nlmsg_*() in <net/netlink.h>