Skip to content

Commit

Permalink
Fix undefined behavior problem when using list_foreach_entry
Browse files Browse the repository at this point in the history
This upstream list.h offsetof implementation rely on undefined behavior implementation. Using __builtin_offsetof to fix this problem.
  • Loading branch information
Weinan Liu committed Aug 10, 2023
1 parent 6507700 commit fb22714
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kpatch-build/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fb22714

Please sign in to comment.