From fb22714ae934a6a9b8ab0cc635519fb3a24c2052 Mon Sep 17 00:00:00 2001 From: Weinan Liu Date: Wed, 9 Aug 2023 22:31:21 +0000 Subject: [PATCH] Fix undefined behavior problem when using list_foreach_entry This upstream list.h offsetof implementation rely on undefined behavior implementation. Using __builtin_offsetof to fix this problem. --- kpatch-build/list.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kpatch-build/list.h b/kpatch-build/list.h index e95593c83..ad4643c10 100644 --- a/kpatch-build/list.h +++ b/kpatch-build/list.h @@ -30,7 +30,7 @@ /** * Get offset of a member */ -#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) +#define offsetof(TYPE, MEMBER) ((size_t) __builtin_offsetof(TYPE, MEMBER)) /** * Casts a member of a structure out to the containing structure