* [PATCH][next] ASoC: soc-topology: Avoid -Wflex-array-member-not-at-end warning
@ 2026-04-29 23:19 Gustavo A. R. Silva
2026-04-30 4:36 ` Mark Brown
0 siblings, 1 reply; 3+ messages in thread
From: Gustavo A. R. Silva @ 2026-04-29 23:19 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai
Cc: linux-sound, linux-kernel, Gustavo A. R. Silva, linux-hardening
-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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH][next] ASoC: soc-topology: Avoid -Wflex-array-member-not-at-end warning
2026-04-29 23:19 [PATCH][next] ASoC: soc-topology: Avoid -Wflex-array-member-not-at-end warning Gustavo A. R. Silva
@ 2026-04-30 4:36 ` Mark Brown
2026-04-30 17:43 ` Gustavo A. R. Silva
0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2026-04-30 4:36 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, linux-sound,
linux-kernel, linux-hardening
[-- Attachment #1: Type: text/plain, Size: 626 bytes --]
On Wed, Apr 29, 2026 at 05:19:49PM -0600, Gustavo A. R. Silva wrote:
> -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]
Sashiko is complaining about this breaking some of the users:
https://sashiko.dev/#/patchset/afKSFY3qrlSOJ0EJ%40kspp
I don't know enough to tell if that's actually a sensible report or not.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH][next] ASoC: soc-topology: Avoid -Wflex-array-member-not-at-end warning
2026-04-30 4:36 ` Mark Brown
@ 2026-04-30 17:43 ` Gustavo A. R. Silva
0 siblings, 0 replies; 3+ messages in thread
From: Gustavo A. R. Silva @ 2026-04-30 17:43 UTC (permalink / raw)
To: Mark Brown, Gustavo A. R. Silva
Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, linux-sound,
linux-kernel, linux-hardening
On 4/29/26 22:36, Mark Brown wrote:
> On Wed, Apr 29, 2026 at 05:19:49PM -0600, Gustavo A. R. Silva wrote:
>> -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]
>
> Sashiko is complaining about this breaking some of the users:
>
> https://sashiko.dev/#/patchset/afKSFY3qrlSOJ0EJ%40kspp
>
> I don't know enough to tell if that's actually a sensible report or not.
It seems Sashiko is correct here.
I'll rework this patch.
Thanks!
-Gustavo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-04-30 17:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-29 23:19 [PATCH][next] ASoC: soc-topology: Avoid -Wflex-array-member-not-at-end warning Gustavo A. R. Silva
2026-04-30 4:36 ` Mark Brown
2026-04-30 17:43 ` Gustavo A. R. Silva
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox