From 7f4600de1bf53b3acde3db2c8552c38b75b255a2 Mon Sep 17 00:00:00 2001 From: Chrissie Caulfield Date: Thu, 20 Feb 2020 14:29:33 +0000 Subject: [PATCH] list: fix list handling for gcc10 (#383) -Wpointer-arith has been removed from warnings as with GCC10 that warns every time qb_list_entry is used, which is just noise. --- configure.ac | 1 - include/qb/qblist.h | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index ec8736c..108b2f1 100644 --- a/configure.ac +++ b/configure.ac @@ -601,7 +601,6 @@ WARNLIST=" suggest-attribute=format property-attribute-mismatch strict-prototypes - pointer-arith write-strings cast-align bad-function-cast diff --git a/include/qb/qblist.h b/include/qb/qblist.h index e3ae3f1..8064c87 100644 --- a/include/qb/qblist.h +++ b/include/qb/qblist.h @@ -193,8 +193,8 @@ static inline void qb_list_splice_tail(struct qb_list_head *list, * @param type: the type of the struct this is embedded in. * @param member: the name of the list_struct within the struct. */ -#define qb_list_entry(ptr,type,member)\ - ((type *)((char *)(ptr)-(char*)(&((type *)0)->member))) +#define qb_list_entry(ptr,type,member) ({ \ + ((type *)((void*)ptr - offsetof(type, member))); }) /** * Get the first element from a list