From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
"Kees Cook" <kees@kernel.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/2] stddef: Simplify TRAILING_OVERLAP() and improve docs
Date: Fri, 12 Sep 2025 12:51:15 +0200 [thread overview]
Message-ID: <7a3964b9-e21e-4ece-98f0-f0a2bb013d2c@embeddedor.com> (raw)
In-Reply-To: <cover.1757672423.git.u.kleine-koenig@baylibre.com>
On 9/12/25 12:28, Uwe Kleine-König wrote:
> Hello,
>
> as a follup to the discussion I had with Gustavo in reply to
> https://lore.kernel.org/linux-pwm/aJtRPZpc-Lv-C6zD@kspp here comes my
> suggestion to improve TRAILING_OVERLAP() for wider audience.
>
> While working at it, I wonder if __packed should also better be part of the
> macro to ensure that
I have patch ready for this:
diff --git a/include/linux/stddef.h b/include/linux/stddef.h
index dab49e2ec8c0..b20ff76778d5 100644
--- a/include/linux/stddef.h
+++ b/include/linux/stddef.h
@@ -93,6 +93,14 @@ enum {
#define DECLARE_FLEX_ARRAY(TYPE, NAME) \
__DECLARE_FLEX_ARRAY(TYPE, NAME)
+#define __TRAILING_OVERLAP(TYPE, NAME, FAM, MEMBERS, ATTRS) \
+ union { \
+ TYPE NAME; \
+ struct { \
+ unsigned char __offset_to_##FAM[offsetof(TYPE, FAM)]; \
+ MEMBERS \
+ } ATTRS; \
+ }
/**
* TRAILING_OVERLAP() - Overlap a flexible-array member with trailing members.
*
Thanks
-Gustavo
prev parent reply other threads:[~2025-09-12 10:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-12 10:28 Uwe Kleine-König
2025-09-12 10:28 ` [PATCH 1/2] stddef: Add a comment about why TRAILING_OVERLAP() exists Uwe Kleine-König
2025-09-12 10:28 ` [PATCH 2/2] stddef: Stop using FAM parameter of TRAILING_OVERLAP() Uwe Kleine-König
2025-09-12 11:00 ` Gustavo A. R. Silva
2025-09-12 10:51 ` Gustavo A. R. Silva [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7a3964b9-e21e-4ece-98f0-f0a2bb013d2c@embeddedor.com \
--to=gustavo@embeddedor.com \
--cc=gustavoars@kernel.org \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=u.kleine-koenig@baylibre.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®