Skip to content

Commit 8f2689f

Browse files
GustavoARSilvaUwe Kleine-König
authored andcommitted
pwm: cros-ec: 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 new TRAILING_OVERLAP() helper to fix the following warnings: drivers/pwm/pwm-cros-ec.c:53:40: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] drivers/pwm/pwm-cros-ec.c:87: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> Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org> Link: https://lore.kernel.org/r/aJtRPZpc-Lv-C6zD@kspp Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
1 parent ebd524a commit 8f2689f

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

drivers/pwm/pwm-cros-ec.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,9 @@ static int cros_ec_pwm_set_duty(struct cros_ec_pwm_device *ec_pwm, u8 index,
4949
u16 duty)
5050
{
5151
struct cros_ec_device *ec = ec_pwm->ec;
52-
struct {
53-
struct cros_ec_command msg;
52+
TRAILING_OVERLAP(struct cros_ec_command, msg, data,
5453
struct ec_params_pwm_set_duty params;
55-
} __packed buf;
54+
) __packed buf;
5655
struct ec_params_pwm_set_duty *params = &buf.params;
5756
struct cros_ec_command *msg = &buf.msg;
5857
int ret;
@@ -83,13 +82,12 @@ static int cros_ec_pwm_set_duty(struct cros_ec_pwm_device *ec_pwm, u8 index,
8382

8483
static int cros_ec_pwm_get_duty(struct cros_ec_device *ec, bool use_pwm_type, u8 index)
8584
{
86-
struct {
87-
struct cros_ec_command msg;
85+
TRAILING_OVERLAP(struct cros_ec_command, msg, data,
8886
union {
8987
struct ec_params_pwm_get_duty params;
9088
struct ec_response_pwm_get_duty resp;
9189
};
92-
} __packed buf;
90+
) __packed buf;
9391
struct ec_params_pwm_get_duty *params = &buf.params;
9492
struct ec_response_pwm_get_duty *resp = &buf.resp;
9593
struct cros_ec_command *msg = &buf.msg;

0 commit comments

Comments
 (0)