From: "Gustavo A. R. Silva" <gustavoars@kernel.org>
To: Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.com>
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
linux-hardening@vger.kernel.org
Subject: [PATCH][next] ASoC: soc-topology: Avoid -Wflex-array-member-not-at-end warning
Date: Wed, 29 Apr 2026 17:19:49 -0600 [thread overview]
Message-ID: <afKSFY3qrlSOJ0EJ@kspp> (raw)
-Wflex-array-member-not-at-end was introduced in GCC-14, and we are
getting ready to enable it, globally.
Use the __TRAILING_OVERLAP() helper to fix the following warning:
sound/soc/soc-topology-test.c:136:38: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
This helper creates a union between a flexible-array member (FAM)
and a set of members that would otherwise follow it. This overlays
the trailing members onto the FAM while preserving the original
memory layout.
Lastly, the static_assert() ensures the alignment between the FAM
and struct snd_soc_tplg_hdr pcm_header; is not inadvertently changed,
and it's intentionally placed immediately after the related structure
(that is, no blank line in between).
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
sound/soc/soc-topology-test.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/sound/soc/soc-topology-test.c b/sound/soc/soc-topology-test.c
index c8f2ec29e970..ef6725613b01 100644
--- a/sound/soc/soc-topology-test.c
+++ b/sound/soc/soc-topology-test.c
@@ -133,10 +133,15 @@ static struct tplg_tmpl_001 tplg_tmpl_empty = {
struct tplg_tmpl_002 {
struct snd_soc_tplg_hdr header;
- struct snd_soc_tplg_manifest manifest;
- struct snd_soc_tplg_hdr pcm_header;
- struct snd_soc_tplg_pcm pcm;
+
+ /* Must be last as it ends in a flexible-array member. */
+ __TRAILING_OVERLAP(struct snd_soc_tplg_manifest, manifest, priv.data, __packed,
+ struct snd_soc_tplg_hdr pcm_header;
+ struct snd_soc_tplg_pcm pcm;
+ );
} __packed;
+static_assert(offsetof(struct tplg_tmpl_002, manifest.priv.data) ==
+ offsetof(struct tplg_tmpl_002, pcm_header));
static struct tplg_tmpl_002 tplg_tmpl_with_pcm = {
.header = {
--
2.51.0
next reply other threads:[~2026-04-29 23:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-29 23:19 Gustavo A. R. Silva [this message]
2026-04-30 4:36 ` [PATCH][next] ASoC: soc-topology: Avoid -Wflex-array-member-not-at-end warning Mark Brown
2026-04-30 17:43 ` Gustavo A. R. Silva
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=afKSFY3qrlSOJ0EJ@kspp \
--to=gustavoars@kernel.org \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.