From eb06d5d4b2f54a98b5779c11c3813832d6f98db2 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 20 Jul 2018 15:22:35 +0200 Subject: include/list, include/c: update and container_of() * update container_of() to version without "const" qualifier * use container_of() in list_entry() Signed-off-by: Karel Zak --- include/list.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'include/list.h') diff --git a/include/list.h b/include/list.h index cf022fb22..f3ffc7985 100644 --- a/include/list.h +++ b/include/list.h @@ -12,6 +12,8 @@ #ifndef UTIL_LINUX_LIST_H #define UTIL_LINUX_LIST_H +#include "c.h" + /* TODO: use AC_C_INLINE */ #ifdef __GNUC__ #define _INLINE_ static __inline__ @@ -161,10 +163,7 @@ _INLINE_ void list_splice(struct list_head *list, struct list_head *head) * @type: the type of the struct this is embedded in. * @member: the name of the list_struct within the struct. */ -#define list_entry(ptr, type, member) __extension__ ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) - +#define list_entry(ptr, type, member) container_of(ptr, type, member) #define list_first_entry(head, type, member) \ ((head) && (head)->next != (head) ? list_entry((head)->next, type, member) : NULL) -- cgit v1.2.3-55-g7522