Skip to content

Commit db4ea66

Browse files
GustavoARSilvaTzung-Bi Shih
authored andcommitted
platform/chrome: cros_ec_proto: Avoid -Wflex-array-member-not-at-end warnings
-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 an on-stack definition 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 warnings: drivers/platform/chrome/cros_ec_proto.c:143:40: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] drivers/platform/chrome/cros_ec_proto.c:761: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]> Link: https://lore.kernel.org/r/Z-adX1BB30dcSJ7x@kspp Signed-off-by: Tzung-Bi Shih <[email protected]>
1 parent 8dc528b commit db4ea66

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

drivers/platform/chrome/cros_ec_proto.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,10 @@ static int cros_ec_xfer_command(struct cros_ec_device *ec_dev, struct cros_ec_co
139139

140140
static int cros_ec_wait_until_complete(struct cros_ec_device *ec_dev, uint32_t *result)
141141
{
142-
struct {
143-
struct cros_ec_command msg;
144-
struct ec_response_get_comms_status status;
145-
} __packed buf;
146-
struct cros_ec_command *msg = &buf.msg;
147-
struct ec_response_get_comms_status *status = &buf.status;
142+
DEFINE_RAW_FLEX(struct cros_ec_command, msg, data,
143+
sizeof(struct ec_response_get_comms_status));
144+
struct ec_response_get_comms_status *status =
145+
(struct ec_response_get_comms_status *)msg->data;
148146
int ret = 0, i;
149147

150148
msg->version = 0;
@@ -757,16 +755,13 @@ static int get_next_event_xfer(struct cros_ec_device *ec_dev,
757755

758756
static int get_next_event(struct cros_ec_device *ec_dev)
759757
{
760-
struct {
761-
struct cros_ec_command msg;
762-
struct ec_response_get_next_event_v3 event;
763-
} __packed buf;
764-
struct cros_ec_command *msg = &buf.msg;
765-
struct ec_response_get_next_event_v3 *event = &buf.event;
758+
DEFINE_RAW_FLEX(struct cros_ec_command, msg, data,
759+
sizeof(struct ec_response_get_next_event_v3));
760+
struct ec_response_get_next_event_v3 *event =
761+
(struct ec_response_get_next_event_v3 *)msg->data;
766762
int cmd_version = ec_dev->mkbp_event_supported - 1;
767763
u32 size;
768764

769-
memset(msg, 0, sizeof(*msg));
770765
if (ec_dev->suspended) {
771766
dev_dbg(ec_dev->dev, "Device suspended.\n");
772767
return -EHOSTDOWN;

0 commit comments

Comments
 (0)