Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netlink: simplify NLMSG_DATA with NLMSG_HDRLEN

The NLMSG_LENGTH(0) may confuse the API users,
NLMSG_HDRLEN is much more clear.

Besides, some code style problems are also fixed.
Signed-off-by: Chen Li <chenli@uniontech.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Chen Li and committed by
David S. Miller
d409989b 0d155170

+3 -2
+3 -2
include/uapi/linux/netlink.h
··· 91 91 #define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr))) 92 92 #define NLMSG_LENGTH(len) ((len) + NLMSG_HDRLEN) 93 93 #define NLMSG_SPACE(len) NLMSG_ALIGN(NLMSG_LENGTH(len)) 94 - #define NLMSG_DATA(nlh) ((void*)(((char*)nlh) + NLMSG_LENGTH(0))) 94 + #define NLMSG_DATA(nlh) ((void *)(((char *)nlh) + NLMSG_HDRLEN)) 95 95 #define NLMSG_NEXT(nlh,len) ((len) -= NLMSG_ALIGN((nlh)->nlmsg_len), \ 96 - (struct nlmsghdr*)(((char*)(nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len))) 96 + (struct nlmsghdr *)(((char *)(nlh)) + \ 97 + NLMSG_ALIGN((nlh)->nlmsg_len))) 97 98 #define NLMSG_OK(nlh,len) ((len) >= (int)sizeof(struct nlmsghdr) && \ 98 99 (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \ 99 100 (nlh)->nlmsg_len <= (len))