drm: xlnx: zynqmp_disp: Avoid -Wflex-array-member-not-at-end warning
Subsystems (4)
PATCH 1/1 drm: xlnx: zynqmp_disp: Avoid -Wflex-array-member-not-at-end warning
-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/gpu/drm/xlnx/zynqmp_disp.c:102: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),
--- drivers/gpu/drm/xlnx/zynqmp_disp.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/xlnx/zynqmp_disp.c +7 -2
@@ -99,9 +99,14 @@ struct zynqmp_disp_format {*/ struct zynqmp_disp_layer_dma {struct dma_chan *chan; -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 zynqmp_disp_layer_dma, xt.sgl) == + offsetof(struct zynqmp_disp_layer_dma, sgl));/** * struct zynqmp_disp_layer_info - Static layer information
Signature · 1 line
2.51.0