mirror of
https://github.com/torvalds/linux.git
synced 2026-11-23 23:11:40 +00:00
tools/nolibc: use __builtin_offsetof()
The current custom implementation of offsetof() fails UBSAN: runtime error: member access within null pointer of type 'struct ...' This means that all its users, including container_of(), free() and realloc(), fail. Use __builtin_offsetof() instead which does not have this issue and has been available since GCC 4 and clang 3. Signed-off-by: Thomas Weißschuh <[email protected]> Acked-by: Willy Tarreau <[email protected]> Link: https://patch.msgid.link/[email protected]
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef offsetof
|
||||
#define offsetof(TYPE, FIELD) ((size_t) &((TYPE *)0)->FIELD)
|
||||
#define offsetof(TYPE, FIELD) __builtin_offsetof(TYPE, FIELD)
|
||||
#endif
|
||||
|
||||
#endif /* _NOLIBC_STDDEF_H */
|
||||
|
||||
Reference in New Issue
Block a user