[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211119113644.1600-2-alx.manpages@gmail.com>
Date: Fri, 19 Nov 2021 12:36:29 +0100
From: Alejandro Colomar <alx.manpages@...il.com>
To: LKML <linux-kernel@...r.kernel.org>
Cc: Alejandro Colomar <alx.manpages@...il.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Miguel Ojeda <ojeda@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
Jonathan Cameron <Jonathan.Cameron@...wei.com>,
Bjorn Andersson <bjorn.andersson@...aro.org>,
Mike Rapoport <rppt@...ux.ibm.com>,
Corey Minyard <cminyard@...sta.com>,
Christian Brauner <christian.brauner@...ntu.com>,
Arnd Bergmann <arnd@...db.de>,
Kees Cook <keescook@...omium.org>
Subject: [PATCH 01/17] linux/container_of.h: Add memberof(T, m)
Many xxxof_member() macros make use of the same construction
to refer to a member of a struct
without needing a variable of the struct type.
memberof(T, m)
simplifies all of those,
avoids possible mistakes in repetition,
adds a meaningful name to the construction,
and improves readability by avoiding too many parentheses together.
Signed-off-by: Alejandro Colomar <alx.manpages@...il.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: Miguel Ojeda <ojeda@...nel.org>
Cc: Nick Desaulniers <ndesaulniers@...gle.com>
Cc: Rasmus Villemoes <linux@...musvillemoes.dk>
Cc: Jonathan Cameron <Jonathan.Cameron@...wei.com>
Cc: Bjorn Andersson <bjorn.andersson@...aro.org>
Cc: Mike Rapoport <rppt@...ux.ibm.com>
Cc: Corey Minyard <cminyard@...sta.com>
Cc: Christian Brauner <christian.brauner@...ntu.com>
Cc: Arnd Bergmann <arnd@...db.de>
Cc: Kees Cook <keescook@...omium.org>
---
include/linux/container_of.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/linux/container_of.h b/include/linux/container_of.h
index 2f4944b791b8..199c78a3bf29 100644
--- a/include/linux/container_of.h
+++ b/include/linux/container_of.h
@@ -5,6 +5,9 @@
#include <linux/build_bug.h>
#include <linux/err.h>
+
+#define memberof(T, m) (((T *) NULL)->m)
+
#define typeof_member(T, m) typeof(((T*)0)->m)
/**
--
2.33.1
Powered by blists - more mailing lists