platform/chrome: cros_ec: Avoid -Wflex-array-member-not-at-end warning
authorGustavo A. R. Silva <gustavoars@kernel.org>
Mon, 11 Aug 2025 13:27:22 +0000 (22:27 +0900)
committerTzung-Bi Shih <tzungbi@kernel.org>
Wed, 13 Aug 2025 09:52:41 +0000 (09:52 +0000)
-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>
Link: https://lore.kernel.org/r/aJnvuv334M7TljoB@kspp
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
drivers/platform/chrome/cros_ec.c

index fd58781..b173036 100644 (file)
@@ -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));