* [PATCH][next] media: xilinx: Avoid -Wflex-array-member-not-at-end warning
@ 2026-04-29 19:55 Gustavo A. R. Silva
2026-04-29 20:24 ` Laurent Pinchart
0 siblings, 1 reply; 4+ messages in thread
From: Gustavo A. R. Silva @ 2026-04-29 19:55 UTC (permalink / raw)
To: Laurent Pinchart, Mauro Carvalho Chehab, Michal Simek
Cc: linux-media, linux-arm-kernel, 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:
drivers/media/platform/xilinx/xilinx-dma.h:99:41: 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 data_chunk sgl; is not inadvertently changed, and it's
intentionally placed inmediately after the related structure (that
is, no blank line in between).
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
drivers/media/platform/xilinx/xilinx-dma.h | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/xilinx/xilinx-dma.h b/drivers/media/platform/xilinx/xilinx-dma.h
index 18f77e1a7b39..65f6147ff6c6 100644
--- a/drivers/media/platform/xilinx/xilinx-dma.h
+++ b/drivers/media/platform/xilinx/xilinx-dma.h
@@ -96,9 +96,14 @@ struct xvip_dma {
struct dma_chan *dma;
unsigned int align;
- struct dma_interleaved_template xt;
- struct data_chunk sgl;
+
+ /* Must be last as it ends in a flexible-array member. */
+ TRAILING_OVERLAP(struct dma_interleaved_template, xt, sgl,
+ struct data_chunk sgl;
+ );
};
+static_assert(offsetof(struct xvip_dma, xt.sgl) ==
+ offsetof(struct xvip_dma, sgl));
#define to_xvip_dma(vdev) container_of(vdev, struct xvip_dma, video)
--
2.51.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH][next] media: xilinx: Avoid -Wflex-array-member-not-at-end warning
2026-04-29 19:55 [PATCH][next] media: xilinx: Avoid -Wflex-array-member-not-at-end warning Gustavo A. R. Silva
@ 2026-04-29 20:24 ` Laurent Pinchart
2026-04-29 20:28 ` Laurent Pinchart
0 siblings, 1 reply; 4+ messages in thread
From: Laurent Pinchart @ 2026-04-29 20:24 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Mauro Carvalho Chehab, Michal Simek, linux-media,
linux-arm-kernel, linux-kernel, linux-hardening, Tomi Valkeinen
CC'ing Tomi Valkeinen.
On a side note, Tomi, can I send a patch to add you to the "XILINX VIDEO
IP CORES" section of MAINTAINERS ?
On Wed, Apr 29, 2026 at 01:55:27PM -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:
>
> drivers/media/platform/xilinx/xilinx-dma.h:99:41: 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 data_chunk sgl; is not inadvertently changed, and it's
> intentionally placed inmediately after the related structure (that
> is, no blank line in between).
>
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
> drivers/media/platform/xilinx/xilinx-dma.h | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/platform/xilinx/xilinx-dma.h b/drivers/media/platform/xilinx/xilinx-dma.h
> index 18f77e1a7b39..65f6147ff6c6 100644
> --- a/drivers/media/platform/xilinx/xilinx-dma.h
> +++ b/drivers/media/platform/xilinx/xilinx-dma.h
> @@ -96,9 +96,14 @@ struct xvip_dma {
>
> struct dma_chan *dma;
> unsigned int align;
> - struct dma_interleaved_template xt;
> - struct data_chunk sgl;
> +
> + /* Must be last as it ends in a flexible-array member. */
> + TRAILING_OVERLAP(struct dma_interleaved_template, xt, sgl,
> + struct data_chunk sgl;
> + );
> };
> +static_assert(offsetof(struct xvip_dma, xt.sgl) ==
> + offsetof(struct xvip_dma, sgl));
>
> #define to_xvip_dma(vdev) container_of(vdev, struct xvip_dma, video)
>
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][next] media: xilinx: Avoid -Wflex-array-member-not-at-end warning
2026-04-29 20:24 ` Laurent Pinchart
@ 2026-04-29 20:28 ` Laurent Pinchart
2026-04-29 22:46 ` Gustavo A. R. Silva
0 siblings, 1 reply; 4+ messages in thread
From: Laurent Pinchart @ 2026-04-29 20:28 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Mauro Carvalho Chehab, Michal Simek, linux-media,
linux-arm-kernel, linux-kernel, linux-hardening, Tomi Valkeinen
I forgot to ask, how do you want to get this merged? Will you collect
all similar patches and send a tree-wide pull request, or should they be
merged by individual subsystems ? In the latter case, Tomi, could you
please handle this with other Xilinx patches ?
On Wed, Apr 29, 2026 at 11:24:50PM +0300, Laurent Pinchart wrote:
> CC'ing Tomi Valkeinen.
>
> On a side note, Tomi, can I send a patch to add you to the "XILINX VIDEO
> IP CORES" section of MAINTAINERS ?
>
> On Wed, Apr 29, 2026 at 01:55:27PM -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:
> >
> > drivers/media/platform/xilinx/xilinx-dma.h:99:41: 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 data_chunk sgl; is not inadvertently changed, and it's
> > intentionally placed inmediately after the related structure (that
> > is, no blank line in between).
> >
> > Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>
> > ---
> > drivers/media/platform/xilinx/xilinx-dma.h | 9 +++++++--
> > 1 file changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/media/platform/xilinx/xilinx-dma.h b/drivers/media/platform/xilinx/xilinx-dma.h
> > index 18f77e1a7b39..65f6147ff6c6 100644
> > --- a/drivers/media/platform/xilinx/xilinx-dma.h
> > +++ b/drivers/media/platform/xilinx/xilinx-dma.h
> > @@ -96,9 +96,14 @@ struct xvip_dma {
> >
> > struct dma_chan *dma;
> > unsigned int align;
> > - struct dma_interleaved_template xt;
> > - struct data_chunk sgl;
> > +
> > + /* Must be last as it ends in a flexible-array member. */
> > + TRAILING_OVERLAP(struct dma_interleaved_template, xt, sgl,
> > + struct data_chunk sgl;
> > + );
> > };
> > +static_assert(offsetof(struct xvip_dma, xt.sgl) ==
> > + offsetof(struct xvip_dma, sgl));
> >
> > #define to_xvip_dma(vdev) container_of(vdev, struct xvip_dma, video)
> >
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][next] media: xilinx: Avoid -Wflex-array-member-not-at-end warning
2026-04-29 20:28 ` Laurent Pinchart
@ 2026-04-29 22:46 ` Gustavo A. R. Silva
0 siblings, 0 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2026-04-29 22:46 UTC (permalink / raw)
To: Laurent Pinchart, Gustavo A. R. Silva
Cc: Mauro Carvalho Chehab, Michal Simek, linux-media,
linux-arm-kernel, linux-kernel, linux-hardening, Tomi Valkeinen
On 4/29/26 14:28, Laurent Pinchart wrote:
> I forgot to ask, how do you want to get this merged? Will you collect
> all similar patches and send a tree-wide pull request, or should they be
> merged by individual subsystems ? In the latter case, Tomi, could you
> please handle this with other Xilinx patches ?
You folks can take this in your tree. :)
Thanks!
-Gustavo
>
> On Wed, Apr 29, 2026 at 11:24:50PM +0300, Laurent Pinchart wrote:
>> CC'ing Tomi Valkeinen.
>>
>> On a side note, Tomi, can I send a patch to add you to the "XILINX VIDEO
>> IP CORES" section of MAINTAINERS ?
>>
>> On Wed, Apr 29, 2026 at 01:55:27PM -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:
>>>
>>> drivers/media/platform/xilinx/xilinx-dma.h:99:41: 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 data_chunk sgl; is not inadvertently changed, and it's
>>> intentionally placed inmediately after the related structure (that
>>> is, no blank line in between).
>>>
>>> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
>>
>> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>>
>>> ---
>>> drivers/media/platform/xilinx/xilinx-dma.h | 9 +++++++--
>>> 1 file changed, 7 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/media/platform/xilinx/xilinx-dma.h b/drivers/media/platform/xilinx/xilinx-dma.h
>>> index 18f77e1a7b39..65f6147ff6c6 100644
>>> --- a/drivers/media/platform/xilinx/xilinx-dma.h
>>> +++ b/drivers/media/platform/xilinx/xilinx-dma.h
>>> @@ -96,9 +96,14 @@ struct xvip_dma {
>>>
>>> struct dma_chan *dma;
>>> unsigned int align;
>>> - struct dma_interleaved_template xt;
>>> - struct data_chunk sgl;
>>> +
>>> + /* Must be last as it ends in a flexible-array member. */
>>> + TRAILING_OVERLAP(struct dma_interleaved_template, xt, sgl,
>>> + struct data_chunk sgl;
>>> + );
>>> };
>>> +static_assert(offsetof(struct xvip_dma, xt.sgl) ==
>>> + offsetof(struct xvip_dma, sgl));
>>>
>>> #define to_xvip_dma(vdev) container_of(vdev, struct xvip_dma, video)
>>>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-04-29 22:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-29 19:55 [PATCH][next] media: xilinx: Avoid -Wflex-array-member-not-at-end warning Gustavo A. R. Silva
2026-04-29 20:24 ` Laurent Pinchart
2026-04-29 20:28 ` Laurent Pinchart
2026-04-29 22:46 ` 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