diff options
author | Nick Lewycky <nlewycky@google.com> | 2016-01-29 03:49:31 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2016-02-12 12:21:40 (GMT) |
commit | 58396ae2ae7c91fb95d1de9654be5b12fd2343d2 (patch) | |
tree | dd07a11591494f7dc791ed199c7ff9ce8d86ced7 | |
parent | eccca1acfc7242136256185746d93ec7bd10be82 (diff) | |
download | libnl-58396ae2ae7c91fb95d1de9654be5b12fd2343d2.zip libnl-58396ae2ae7c91fb95d1de9654be5b12fd2343d2.tar.gz libnl-58396ae2ae7c91fb95d1de9654be5b12fd2343d2.tar.bz2 |
remove null dereference from netlink/link.h
Replace a null pointer dereference with a use of the 'offsetof' macro in stddef.h.
http://lists.infradead.org/pipermail/libnl/2016-January/002085.html
Signed-off-by: Nick Lewycky <nlewycky@google.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r-- | include/netlink/list.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/include/netlink/list.h b/include/netlink/list.h index 28712ed..fcfb826 100644 --- a/include/netlink/list.h +++ b/include/netlink/list.h @@ -12,6 +12,8 @@ #ifndef NETLINK_LIST_H_ #define NETLINK_LIST_H_ +#include <stddef.h> + struct nl_list_head { struct nl_list_head * next; @@ -59,7 +61,7 @@ static inline int nl_list_empty(struct nl_list_head *head) #define nl_container_of(ptr, type, member) ({ \ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - ((size_t) &((type *)0)->member));}) + (type *)( (char *)__mptr - (offsetof(type, member)));}) #define nl_list_entry(ptr, type, member) \ nl_container_of(ptr, type, member) |