[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211119113644.1600-12-alx.manpages@gmail.com>
Date: Fri, 19 Nov 2021 12:36:39 +0100
From: Alejandro Colomar <alx.manpages@...il.com>
To: LKML <linux-kernel@...r.kernel.org>
Cc: Alejandro Colomar <alx.manpages@...il.com>
Subject: [PATCH 11/17] linux/container_of.h: Cosmetic
Place braces more similar to where a function would have them.
Signed-off-by: Alejandro Colomar <alx.manpages@...il.com>
---
include/linux/container_of.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/include/linux/container_of.h b/include/linux/container_of.h
index addd3993fa60..2100adb9d109 100644
--- a/include/linux/container_of.h
+++ b/include/linux/container_of.h
@@ -15,12 +15,16 @@
* @member: the name of the member within the struct.
*
*/
-#define container_of(ptr, type, member) ({ \
+#define container_of(ptr, type, member) ( \
+{ \
void *__mptr = (void *)(ptr); \
+ \
static_assert(__same_type(*(ptr), memberof(type, member)) || \
__same_type(*(ptr), void), \
"pointer type mismatch in container_of()"); \
- ((type *)(__mptr - offsetof(type, member))); })
+ ((type *)(__mptr - offsetof(type, member))); \
+} \
+)
/**
* container_of_safe - cast a member of a structure out to the containing structure
--
2.33.1
Powered by blists - more mailing lists