Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

watchdog: cros-ec: 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 `DEFINE_RAW_FLEX()` helper for on-stack definitions of
a flexible structure where the size of the flexible-array member
is known at compile-time, and refactor the rest of the code,
accordingly.

So, with these changes, fix the following warning:

drivers/watchdog/cros_ec_wdt.c:29:40: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Reviewed-by: Kees Cook <kees@kernel.org>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/Z-WG6_uhWsy_FCq3@kspp
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>

authored by

Gustavo A. R. Silva and committed by
Wim Van Sebroeck
f8cdcc98 325f510f

+12 -16
+12 -16
drivers/watchdog/cros_ec_wdt.c
··· 25 25 union cros_ec_wdt_data *arg) 26 26 { 27 27 int ret; 28 - struct { 29 - struct cros_ec_command msg; 30 - union cros_ec_wdt_data data; 31 - } __packed buf = { 32 - .msg = { 33 - .version = 0, 34 - .command = EC_CMD_HANG_DETECT, 35 - .insize = (arg->req.command == EC_HANG_DETECT_CMD_GET_STATUS) ? 36 - sizeof(struct ec_response_hang_detect) : 37 - 0, 38 - .outsize = sizeof(struct ec_params_hang_detect), 39 - }, 40 - .data.req = arg->req 41 - }; 28 + DEFINE_RAW_FLEX(struct cros_ec_command, msg, data, 29 + sizeof(union cros_ec_wdt_data)); 42 30 43 - ret = cros_ec_cmd_xfer_status(cros_ec, &buf.msg); 31 + msg->version = 0; 32 + msg->command = EC_CMD_HANG_DETECT; 33 + msg->insize = (arg->req.command == EC_HANG_DETECT_CMD_GET_STATUS) ? 34 + sizeof(struct ec_response_hang_detect) : 35 + 0; 36 + msg->outsize = sizeof(struct ec_params_hang_detect); 37 + *(struct ec_params_hang_detect *)msg->data = arg->req; 38 + 39 + ret = cros_ec_cmd_xfer_status(cros_ec, msg); 44 40 if (ret < 0) 45 41 return ret; 46 42 47 - arg->resp = buf.data.resp; 43 + arg->resp = *(struct ec_response_hang_detect *)msg->data; 48 44 49 45 return 0; 50 46 }