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>
This commit is contained in:
Gustavo A. R. Silva 2025-03-27 11:12:11 -06:00 committed by Wim Van Sebroeck
parent 325f510fcd
commit f8cdcc98c9
1 changed files with 12 additions and 16 deletions

View File

@ -25,26 +25,22 @@ static int cros_ec_wdt_send_cmd(struct cros_ec_device *cros_ec,
union cros_ec_wdt_data *arg)
{
int ret;
struct {
struct cros_ec_command msg;
union cros_ec_wdt_data data;
} __packed buf = {
.msg = {
.version = 0,
.command = EC_CMD_HANG_DETECT,
.insize = (arg->req.command == EC_HANG_DETECT_CMD_GET_STATUS) ?
sizeof(struct ec_response_hang_detect) :
0,
.outsize = sizeof(struct ec_params_hang_detect),
},
.data.req = arg->req
};
DEFINE_RAW_FLEX(struct cros_ec_command, msg, data,
sizeof(union cros_ec_wdt_data));
ret = cros_ec_cmd_xfer_status(cros_ec, &buf.msg);
msg->version = 0;
msg->command = EC_CMD_HANG_DETECT;
msg->insize = (arg->req.command == EC_HANG_DETECT_CMD_GET_STATUS) ?
sizeof(struct ec_response_hang_detect) :
0;
msg->outsize = sizeof(struct ec_params_hang_detect);
*(struct ec_params_hang_detect *)msg->data = arg->req;
ret = cros_ec_cmd_xfer_status(cros_ec, msg);
if (ret < 0)
return ret;
arg->resp = buf.data.resp;
arg->resp = *(struct ec_response_hang_detect *)msg->data;
return 0;
}