diff options
author | Petr Štetiar <ynezz@true.cz> | 2019-10-29 06:40:57 +0100 |
---|---|---|
committer | rofl0r <rofl0r@users.noreply.github.com> | 2022-09-16 01:29:50 +0000 |
commit | f6ceefdb1ee06f092f30ee4d0c04e57cda67c5da (patch) | |
tree | 698781eb02762033e4c2bbfead911f9d1ad7be1e /include | |
parent | 0aeb127f3cfe4abbc9a894c236541467396ed5ff (diff) | |
download | libnl-tiny-f6ceefdb1ee06f092f30ee4d0c04e57cda67c5da.tar.gz |
use offsetof macro to make scan-build happy
scan-build from clang version 9 complains about following:
cache.c:106:2: warning: Dereference of null pointer
nl_list_for_each_entry_safe(obj, tmp, &cache->c_items, ce_list)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/netlink/list.h:83:20: note: expanded from macro 'nl_list_for_each_entry_safe'
pos = n, n = nl_list_entry(n->member.next, typeof(*n), member))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/netlink/list.h:60:2: note: expanded from macro 'nl_list_entry'
nl_container_of(ptr, type, member)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/netlink/list.h:56:55: note: expanded from macro 'nl_container_of'
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
^~~~~
Signed-off-by: Petr Štetiar <ynezz@true.cz>
Diffstat (limited to 'include')
-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 c6876a7..6eae216 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; @@ -54,7 +56,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) |