From e3c7beb6ea050abbb77da098bdd30a808a8cb2c2 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Wed, 12 Jul 2017 11:35:08 +0200 Subject: include: Use offsetof in list.h --- include/ouroboros/list.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/ouroboros/list.h b/include/ouroboros/list.h index 8811e291..40627651 100644 --- a/include/ouroboros/list.h +++ b/include/ouroboros/list.h @@ -26,6 +26,7 @@ #include #include +#include #include struct list_head { @@ -34,7 +35,7 @@ struct list_head { }; #define list_entry(ptr, type, mbr) \ - ((type *)((uint8_t *)(ptr)-(size_t)(&((type *)0)->mbr))) + ((type *)((uint8_t *)(ptr) - offsetof(type, mbr))) #define list_first_entry(ptr, type, mbr) \ list_entry((ptr)->nxt, type, mbr) -- cgit v1.2.3