linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] platform/chrome: cros_ec: Avoid -Wflex-array-member-not-at-end warning
@ 2025-08-11 13:27 Gustavo A. R. Silva
  2025-08-13  9:55 ` Tzung-Bi Shih
  0 siblings, 1 reply; 2+ messages in thread
From: Gustavo A. R. Silva @ 2025-08-11 13:27 UTC (permalink / raw)
  To: Benson Leung, Tzung-Bi Shih, Guenter Roeck
  Cc: chrome-platform, 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 new TRAILING_OVERLAP() helper to fix the following warning:

drivers/platform/chrome/cros_ec.c:106: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.

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
Changes in v2:
 - Use the new TRAILING_OVERLAP() helper instead of DEFINE_RAW_FLEX().

v1:
 - Link: https://lore.kernel.org/linux-hardening/Z-apE0ZmckBjRDyx@kspp/

 drivers/platform/chrome/cros_ec.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec.c b/drivers/platform/chrome/cros_ec.c
index fd58781a2fb7..b1730362e399 100644
--- a/drivers/platform/chrome/cros_ec.c
+++ b/drivers/platform/chrome/cros_ec.c
@@ -102,14 +102,13 @@ EXPORT_SYMBOL(cros_ec_irq_thread);
 static int cros_ec_sleep_event(struct cros_ec_device *ec_dev, u8 sleep_event)
 {
 	int ret;
-	struct {
-		struct cros_ec_command msg;
+	TRAILING_OVERLAP(struct cros_ec_command, msg, data,
 		union {
 			struct ec_params_host_sleep_event req0;
 			struct ec_params_host_sleep_event_v1 req1;
 			struct ec_response_host_sleep_event_v1 resp1;
 		} u;
-	} __packed buf;
+	) __packed buf;
 
 	memset(&buf, 0, sizeof(buf));
 
-- 
2.43.0


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

* Re: [PATCH v2] platform/chrome: cros_ec: Avoid -Wflex-array-member-not-at-end warning
  2025-08-11 13:27 [PATCH v2] platform/chrome: cros_ec: Avoid -Wflex-array-member-not-at-end warning Gustavo A. R. Silva
@ 2025-08-13  9:55 ` Tzung-Bi Shih
  0 siblings, 0 replies; 2+ messages in thread
From: Tzung-Bi Shih @ 2025-08-13  9:55 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Benson Leung, Guenter Roeck, chrome-platform, linux-kernel,
	linux-hardening

On Mon, Aug 11, 2025 at 10:27:22PM +0900, 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 new TRAILING_OVERLAP() helper to fix the following warning:
> 
> drivers/platform/chrome/cros_ec.c:106:40: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
>
> [...]

Applied to

    https://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux.git for-next

[1/1] platform/chrome: cros_ec: Avoid -Wflex-array-member-not-at-end warning
      commit: 8abbbbb588f1f1bf95ae56c1531a17520ce487e2

Thanks!

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

end of thread, other threads:[~2025-08-13  9:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-11 13:27 [PATCH v2] platform/chrome: cros_ec: Avoid -Wflex-array-member-not-at-end warning Gustavo A. R. Silva
2025-08-13  9:55 ` Tzung-Bi Shih

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).