[PATCH] simplify container_of()

From: Alexey Dobriyan
Date: Fri Jul 19 2024 - 15:08:58 EST


* delete unnecessary variable,
* delete unnecessary parenthesis.

This changes generated code for some reason :-\

add/remove: 6/0 grow/shrink: 26/42 up/down: 1945/-1591 (354)
Function old new delta
ip_route_output_ports - 724 +724
...
udp_lib_setsockopt 2785 2291 -494
Total: Before=83970531, After=83970885, chg +0.00%

But it shouldn't: cast is unnecessary and static_assert() doesn't
generate code. Variable "__mptr" is ised only in one place.
offsetof() is evaluated at compile time.

It is not clear what's going on.

Signed-off-by: Alexey Dobriyan <adobriyan@xxxxxxxxx>
---

include/linux/container_of.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

--- a/include/linux/container_of.h
+++ b/include/linux/container_of.h
@@ -16,11 +16,11 @@
* WARNING: any const qualifier of @ptr is lost.
*/
#define container_of(ptr, type, member) ({ \
- void *__mptr = (void *)(ptr); \
static_assert(__same_type(*(ptr), ((type *)0)->member) || \
__same_type(*(ptr), void), \
"pointer type mismatch in container_of()"); \
- ((type *)(__mptr - offsetof(type, member))); })
+ (type *)((void *)(ptr) - offsetof(type, member)); \
+})

/**
* container_of_const - cast a member of a structure out to the containing