lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <aBEmk6ixfrQ2XpTw@kspp>
Date: Tue, 29 Apr 2025 13:20:51 -0600
From: "Gustavo A. R. Silva" <gustavoars@...nel.org>
To: Thomas Weißschuh <linux@...ssschuh.net>,
	Benson Leung <bleung@...omium.org>,
	Guenter Roeck <groeck@...omium.org>,
	Sebastian Reichel <sre@...nel.org>
Cc: chrome-platform@...ts.linux.dev, linux-pm@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	"Gustavo A. R. Silva" <gustavoars@...nel.org>,
	linux-hardening@...r.kernel.org
Subject: [PATCH][next] power: supply: cros_charge-control: 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 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 warning:

drivers/power/supply/cros_charge-control.c:57: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@...nel.org>
---
 drivers/power/supply/cros_charge-control.c | 26 +++++++++-------------
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/drivers/power/supply/cros_charge-control.c b/drivers/power/supply/cros_charge-control.c
index 02d5bdbe2e8d..e33bc4c55bcc 100644
--- a/drivers/power/supply/cros_charge-control.c
+++ b/drivers/power/supply/cros_charge-control.c
@@ -53,23 +53,17 @@ static int cros_chctl_send_charge_control_cmd(struct cros_ec_device *cros_ec,
 		[3] = sizeof(struct ec_params_charge_control),
 	};
 
-	struct {
-		struct cros_ec_command msg;
-		union {
-			struct ec_params_charge_control req;
-			struct ec_response_charge_control resp;
-		} __packed data;
-	} __packed buf = {
-		.msg = {
-			.command = EC_CMD_CHARGE_CONTROL,
-			.version = cmd_version,
-			.insize  = 0,
-			.outsize = outsizes[cmd_version],
-		},
-		.data.req = *req,
-	};
+	DEFINE_RAW_FLEX(struct cros_ec_command, msg, data,
+			MAX(sizeof(struct ec_params_charge_control),
+			    sizeof(struct ec_response_charge_control)));
+
+	msg->command = EC_CMD_CHARGE_CONTROL;
+	msg->version = cmd_version;
+	msg->insize  = 0;
+	msg->outsize = outsizes[cmd_version];
+	*(struct ec_params_charge_control *)msg->data = *req;
 
-	return cros_ec_cmd_xfer_status(cros_ec, &buf.msg);
+	return cros_ec_cmd_xfer_status(cros_ec, msg);
 }
 
 static int cros_chctl_configure_ec(struct cros_chctl_priv *priv)
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ