public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH][next] drm/i915/gvt: Avoid -Wflex-array-member-not-at-end warning
@ 2026-04-27 23:58 Gustavo A. R. Silva
  2026-04-28  7:53 ` Jani Nikula
  0 siblings, 1 reply; 3+ messages in thread
From: Gustavo A. R. Silva @ 2026-04-27 23:58 UTC (permalink / raw)
  To: Zhenyu Wang, Zhi Wang, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
	Tvrtko Ursulin, David Airlie, Simona Vetter
  Cc: intel-gfx, dri-devel, 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/gpu/drm/i915/gvt/opregion.c:126:40: 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 efp_child_device_config child0; 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/gpu/drm/i915/gvt/opregion.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i915/gvt/opregion.c b/drivers/gpu/drm/i915/gvt/opregion.c
index d6e76ba31d60..efe457c02788 100644
--- a/drivers/gpu/drm/i915/gvt/opregion.c
+++ b/drivers/gpu/drm/i915/gvt/opregion.c
@@ -122,17 +122,21 @@ struct vbt {
 	struct bdb_data_header general_features_header;
 	struct bdb_general_features general_features;
 
-	struct bdb_data_header general_definitions_header;
-	struct bdb_general_definitions general_definitions;
-
-	struct efp_child_device_config child0;
-	struct efp_child_device_config child1;
-	struct efp_child_device_config child2;
-	struct efp_child_device_config child3;
-
 	struct bdb_data_header driver_features_header;
 	struct bdb_driver_features driver_features;
+
+	struct bdb_data_header general_definitions_header;
+
+	/* Must be last as it ends in a flexible-array member. */
+	TRAILING_OVERLAP(struct bdb_general_definitions, general_definitions, devices,
+		struct efp_child_device_config child0;
+		struct efp_child_device_config child1;
+		struct efp_child_device_config child2;
+		struct efp_child_device_config child3;
+	);
 };
+static_assert(offsetof(struct vbt, general_definitions.devices) ==
+	      offsetof(struct vbt, child0));
 
 static void virt_vbt_generation(struct vbt *v)
 {
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-04-28 16:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-27 23:58 [PATCH][next] drm/i915/gvt: Avoid -Wflex-array-member-not-at-end warning Gustavo A. R. Silva
2026-04-28  7:53 ` Jani Nikula
2026-04-28 16:32   ` 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