[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0c66d2f3dc875664bf0eba7707044e48bb029dc6.1757672423.git.u.kleine-koenig@baylibre.com>
Date: Fri, 12 Sep 2025 12:28:02 +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 2/2] stddef: Stop using FAM parameter of TRAILING_OVERLAP()
According to my understanding of flexible array members and the c99 docs
("In most situations, the flexible array member is ignored. In
particular, the size of the structure is as if the flexible array member
were omitted except that it may have more trailing padding than the
omission would imply.") sizeof(TYPE) yields the same value as
offsetof(TYPE, FAM). To make FAM unused rename the padding struct member
to use NAME instead of FAM. This makes the macro easier to use and thus
less prone to error.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@...libre.com>
--
Hello,
This allows in a followup change to drop the parameter. As this has to
happen in sync with all users of the macro, I delay this change until
after this patch was accepted and hits Linus' tree and then coordinate a
tree-wide change with him before the next -rc1.
Best regards
Uwe
---
include/linux/stddef.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/stddef.h b/include/linux/stddef.h
index a748efcd626f..305e25a67271 100644
--- a/include/linux/stddef.h
+++ b/include/linux/stddef.h
@@ -118,7 +118,7 @@ enum {
union { \
TYPE NAME; \
struct { \
- unsigned char __offset_to_##FAM[offsetof(TYPE, FAM)]; \
+ unsigned char __offset_to_end_of_##NAME[sizeof(TYPE)]; \
MEMBERS \
}; \
}
--
2.50.1
Powered by blists - more mailing lists