Re: [PATCH][net-next] ipv6: drop container_of when convert dst to rt6_info
From: Stephen Hemminger <stephen@networkplumber.org>
Date: 2018-09-30 16:05:15
From: Stephen Hemminger <stephen@networkplumber.org>
Date: 2018-09-30 16:05:15
On Sun, 30 Sep 2018 13:02:52 +0800 Li RongQing [off-list ref] wrote:
we can save container_of computation and return dst directly, since dst is always first member of struct rt6_info Add a BUILD_BUG_ON() to catch any change that could break this assertion. Signed-off-by: Li RongQing <redacted>
I don't understand why you are doing this? It is not going to be faster (or safer) than container_of. container_of provides the same functionality and is safe against position of the member in the structure.