Skip to content

Commit

Permalink
tools headers: Add non-NULL assert to container_of
Browse files Browse the repository at this point in the history
container_of on a NULL may yield a non-NULL, confusion and errors.
  • Loading branch information
captain5050 committed Dec 13, 2024
1 parent 684ea1a commit 3dec077
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions tools/include/linux/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
static_assert(__same_type(*(ptr), ((type *)0)->member) || \
__same_type(*(ptr), void), \
"pointer type mismatch in container_of()"); \
assert(ptr != NULL); \
((type *)(__mptr - offsetof(type, member))); })
#endif

Expand Down

0 comments on commit 3dec077

Please sign in to comment.