Skip to content

Commit f8cdcc9

Browse files
GustavoARSilvaWim Van Sebroeck
authored andcommitted
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 <[email protected]> Reviewed-by: Tzung-Bi Shih <[email protected]> Reviewed-by: Kees Cook <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/r/Z-WG6_uhWsy_FCq3@kspp Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Wim Van Sebroeck <[email protected]>
1 parent 325f510 commit f8cdcc9

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

drivers/watchdog/cros_ec_wdt.c

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,22 @@ static int cros_ec_wdt_send_cmd(struct cros_ec_device *cros_ec,
2525
union cros_ec_wdt_data *arg)
2626
{
2727
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-
};
42-
43-
ret = cros_ec_cmd_xfer_status(cros_ec, &buf.msg);
28+
DEFINE_RAW_FLEX(struct cros_ec_command, msg, data,
29+
sizeof(union cros_ec_wdt_data));
30+
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);
4440
if (ret < 0)
4541
return ret;
4642

47-
arg->resp = buf.data.resp;
43+
arg->resp = *(struct ec_response_hang_detect *)msg->data;
4844

4945
return 0;
5046
}

0 commit comments

Comments
 (0)