mirror of
https://github.com/nmap/nmap.git
synced 2026-08-27 11:55:27 +00:00
Avoid null pointer dereference to implement container_of
Using offsetof instead of actually dereferencing a 0 pointer is still standards compliant (works under gcc -ansi, clang -ansi), and is more in line with how Linux kernel defines this macro (kernel.h). Can't exactly lift the kernel implementation because it uses gnu-extension typeof. Not really a necessary change, but it was causing clang's address sanitizer to complain.
This commit is contained in:
parent
a5ce7f6083
commit
e4ce527a38
1 changed files with 1 additions and 1 deletions
|
|
@ -73,7 +73,7 @@
|
|||
|
||||
#if !defined(container_of)
|
||||
#define container_of(ptr, type, member) \
|
||||
((type *)((char *)(ptr)-(char *)(&((type *)0)->member)))
|
||||
((type *)((char *)(ptr) - offsetof(type, member)))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue