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
91#define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))91#define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))
92#define NLMSG_LENGTH(len) ((len) + NLMSG_HDRLEN)92#define NLMSG_LENGTH(len) ((len) + NLMSG_HDRLEN)
93#define NLMSG_SPACE(len) NLMSG_ALIGN(NLMSG_LENGTH(len))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#define NLMSG_NEXT(nlh,len) ((len) -= NLMSG_ALIGN((nlh)->nlmsg_len), \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#define NLMSG_OK(nlh,len) ((len) >= (int)sizeof(struct nlmsghdr) && \98#define NLMSG_OK(nlh,len) ((len) >= (int)sizeof(struct nlmsghdr) && \
98 (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \99 (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \
99 (nlh)->nlmsg_len <= (len))100 (nlh)->nlmsg_len <= (len))