* [PATCH][next] carl9170: Avoid -Wflex-array-member-not-at-end warning
@ 2025-11-19 7:33 Gustavo A. R. Silva
2025-11-20 19:35 ` Christian Lamparter
0 siblings, 1 reply; 2+ messages in thread
From: Gustavo A. R. Silva @ 2025-11-19 7:33 UTC (permalink / raw)
To: Christian Lamparter
Cc: linux-wireless, linux-kernel, Gustavo A. R. Silva,
linux-hardening
-Wflex-array-member-not-at-end was introduced in GCC-14, and we are
getting ready to enable it, globally.
Move the conflicting declaration (which happens to be in a union, so
we're moving the entire union) to the end of the corresponding
structure. Notice that `struct carl9170_rsp` is a flexible structure,
this is a structure that contains a flexible-array member.
With these changes fix the following warning:
drivers/net/wireless/ath/carl9170/carl9170.h:382:9: 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>
---
drivers/net/wireless/ath/carl9170/carl9170.h | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/net/wireless/ath/carl9170/carl9170.h b/drivers/net/wireless/ath/carl9170/carl9170.h
index ba29b4aebe9f..b13685e22a0d 100644
--- a/drivers/net/wireless/ath/carl9170/carl9170.h
+++ b/drivers/net/wireless/ath/carl9170/carl9170.h
@@ -375,11 +375,6 @@ struct ar9170 {
u8 *readbuf;
spinlock_t cmd_lock;
struct completion cmd_wait;
- union {
- __le32 cmd_buf[PAYLOAD_MAX + 1];
- struct carl9170_cmd cmd;
- struct carl9170_rsp rsp;
- };
/* statistics */
unsigned int tx_dropped;
@@ -463,6 +458,13 @@ struct ar9170 {
unsigned int cache_idx;
} rng;
#endif /* CONFIG_CARL9170_HWRNG */
+
+ /* Must be last as it ends in a flexible-array member. */
+ union {
+ __le32 cmd_buf[PAYLOAD_MAX + 1];
+ struct carl9170_cmd cmd;
+ struct carl9170_rsp rsp;
+ };
};
enum carl9170_ps_off_override_reasons {
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH][next] carl9170: Avoid -Wflex-array-member-not-at-end warning
2025-11-19 7:33 [PATCH][next] carl9170: Avoid -Wflex-array-member-not-at-end warning Gustavo A. R. Silva
@ 2025-11-20 19:35 ` Christian Lamparter
0 siblings, 0 replies; 2+ messages in thread
From: Christian Lamparter @ 2025-11-20 19:35 UTC (permalink / raw)
To: Gustavo A. R. Silva, Christian Lamparter
Cc: linux-wireless, linux-kernel, linux-hardening
On 11/19/25 8:33 AM, Gustavo A. R. Silva wrote:
> -Wflex-array-member-not-at-end was introduced in GCC-14, and we are
> getting ready to enable it, globally.
>
> Move the conflicting declaration (which happens to be in a union, so
> we're moving the entire union) to the end of the corresponding
> structure. Notice that `struct carl9170_rsp` is a flexible structure,
> this is a structure that contains a flexible-array member.
>
> With these changes fix the following warning:
>
> drivers/net/wireless/ath/carl9170/carl9170.h:382:9: 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>
Sure, if this truly fixes the warning.
Acked-by: Christian Lamparter <chunkeey@gmail.com>
> ---
> drivers/net/wireless/ath/carl9170/carl9170.h | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/carl9170/carl9170.h b/drivers/net/wireless/ath/carl9170/carl9170.h
> index ba29b4aebe9f..b13685e22a0d 100644
> --- a/drivers/net/wireless/ath/carl9170/carl9170.h
> +++ b/drivers/net/wireless/ath/carl9170/carl9170.h
> @@ -375,11 +375,6 @@ struct ar9170 {
> u8 *readbuf;
> spinlock_t cmd_lock;
> struct completion cmd_wait;
> - union {
> - __le32 cmd_buf[PAYLOAD_MAX + 1];
> - struct carl9170_cmd cmd;
> - struct carl9170_rsp rsp;
> - };
>
> /* statistics */
> unsigned int tx_dropped;
> @@ -463,6 +458,13 @@ struct ar9170 {
> unsigned int cache_idx;
> } rng;
> #endif /* CONFIG_CARL9170_HWRNG */
> +
> + /* Must be last as it ends in a flexible-array member. */
> + union {
> + __le32 cmd_buf[PAYLOAD_MAX + 1];
> + struct carl9170_cmd cmd;
> + struct carl9170_rsp rsp;
> + };
> };
>
> enum carl9170_ps_off_override_reasons {
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-11-20 19:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-19 7:33 [PATCH][next] carl9170: Avoid -Wflex-array-member-not-at-end warning Gustavo A. R. Silva
2025-11-20 19:35 ` Christian Lamparter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).