History

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>

Chen Li committed 5 years ago

Commit d4099891 parent 0d155171 file · +3 −2Browse files

Showing the changes to include/uapi (1 of 1 file). Show all

Unified · Split

include/uapi/linux/netlink.h+3−2
@@ -91,9 +91,10 @@ struct nlmsghdr { · 90 unmodified lines
9191 #define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))
9292 #define NLMSG_LENGTH(len) ((len) + NLMSG_HDRLEN)
9393 #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))
9595 #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)))
9798 #define NLMSG_OK(nlh,len) ((len) >= (int)sizeof(struct nlmsghdr) && \
9899 (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \
99100 (nlh)->nlmsg_len <= (len))