[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7ac4049bf1b8fc31490e2f54a93abeb198112d3b.1757672423.git.u.kleine-koenig@baylibre.com>
Date: Fri, 12 Sep 2025 12:28:01 +0200
From: Uwe Kleine-König <u.kleine-koenig@...libre.com>
To: "Gustavo A. R. Silva" <gustavoars@...nel.org>,
Kees Cook <kees@...nel.org>
Cc: linux-kernel@...r.kernel.org
Subject: [PATCH 1/2] stddef: Add a comment about why TRAILING_OVERLAP() exists
Just from reading the definition it's not obvious what the macro does
and why it's needed and sensible to be used.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@...libre.com>
---
include/linux/stddef.h | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/include/linux/stddef.h b/include/linux/stddef.h
index dab49e2ec8c0..a748efcd626f 100644
--- a/include/linux/stddef.h
+++ b/include/linux/stddef.h
@@ -97,7 +97,17 @@ enum {
* TRAILING_OVERLAP() - Overlap a flexible-array member with trailing members.
*
* Creates a union between a flexible-array member (FAM) in a struct and a set
- * of additional members that would otherwise follow it.
+ * of additional members that would otherwise follow it. This is needed because
+ * the traditional
+ *
+ * struct {
+ * struct some_struct_with_FAM mystruct;
+ * struct some_other_struct fill_FAM;
+ * }
+ *
+ * with the purpose that fill_FAM overlaps the flexible-array in mystruct
+ * triggers a compiler warning about the flexible array member not being at the
+ * end of the structure.
*
* @TYPE: Flexible structure type name, including "struct" keyword.
* @NAME: Name for a variable to define.
--
2.50.1
Powered by blists - more mailing lists