From: "Gustavo A. R. Silva" <gustavoars@kernel.org>
To: Zhenyu Wang <zhenyuw.linux@gmail.com>,
Zhi Wang <zhi.wang.linux@gmail.com>,
Jani Nikula <jani.nikula@linux.intel.com>,
Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
Tvrtko Ursulin <tursulin@ursulin.net>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
linux-hardening@vger.kernel.org
Subject: [PATCH][next] drm/i915/gvt: Avoid -Wflex-array-member-not-at-end warning
Date: Mon, 27 Apr 2026 17:58:18 -0600 [thread overview]
Message-ID: <ae_4GkBsNl_0SYTm@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:
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
next reply other threads:[~2026-04-27 23:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-27 23:58 Gustavo A. R. Silva [this message]
2026-04-28 7:53 ` [PATCH][next] drm/i915/gvt: Avoid -Wflex-array-member-not-at-end warning Jani Nikula
2026-04-28 16:32 ` 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=ae_4GkBsNl_0SYTm@kspp \
--to=gustavoars@kernel.org \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rodrigo.vivi@intel.com \
--cc=simona@ffwll.ch \
--cc=tursulin@ursulin.net \
--cc=zhenyuw.linux@gmail.com \
--cc=zhi.wang.linux@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox