* [PATCH][next] net: spacemit: Avoid -Wflex-array-member-not-at-end warnings
@ 2025-10-21 11:54 Gustavo A. R. Silva
2025-10-21 15:52 ` Simon Horman
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2025-10-21 11:54 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Yixun Lan
Cc: netdev, linux-riscv, spacemit, 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.
Use regular arrays instead of flexible-array members (they're not
really needed in this case) in a couple of unions, and fix the
following warnings:
1 drivers/net/ethernet/spacemit/k1_emac.c:122:42: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
1 drivers/net/ethernet/spacemit/k1_emac.c:122:32: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
1 drivers/net/ethernet/spacemit/k1_emac.c:121:42: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
1 drivers/net/ethernet/spacemit/k1_emac.c:121:32: 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/ethernet/spacemit/k1_emac.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/spacemit/k1_emac.h b/drivers/net/ethernet/spacemit/k1_emac.h
index 5a09e946a276..577efe66573e 100644
--- a/drivers/net/ethernet/spacemit/k1_emac.h
+++ b/drivers/net/ethernet/spacemit/k1_emac.h
@@ -363,7 +363,7 @@ struct emac_desc {
/* Keep stats in this order, index used for accessing hardware */
union emac_hw_tx_stats {
- struct {
+ struct individual_tx_stats {
u64 tx_ok_pkts;
u64 tx_total_pkts;
u64 tx_ok_bytes;
@@ -378,11 +378,11 @@ union emac_hw_tx_stats {
u64 tx_pause_pkts;
} stats;
- DECLARE_FLEX_ARRAY(u64, array);
+ u64 array[sizeof(struct individual_tx_stats) / sizeof(u64)];
};
union emac_hw_rx_stats {
- struct {
+ struct individual_rx_stats {
u64 rx_ok_pkts;
u64 rx_total_pkts;
u64 rx_crc_err_pkts;
@@ -410,7 +410,7 @@ union emac_hw_rx_stats {
u64 rx_truncate_fifo_full_pkts;
} stats;
- DECLARE_FLEX_ARRAY(u64, array);
+ u64 array[sizeof(struct individual_rx_stats) / sizeof(u64)];
};
#endif /* _K1_EMAC_H_ */
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH][next] net: spacemit: Avoid -Wflex-array-member-not-at-end warnings
2025-10-21 11:54 [PATCH][next] net: spacemit: Avoid -Wflex-array-member-not-at-end warnings Gustavo A. R. Silva
@ 2025-10-21 15:52 ` Simon Horman
2025-10-22 8:10 ` Vivian Wang
2025-10-23 3:46 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2025-10-21 15:52 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Yixun Lan, netdev, linux-riscv, spacemit,
linux-kernel, linux-hardening
On Tue, Oct 21, 2025 at 12:54:10PM +0100, 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.
>
> Use regular arrays instead of flexible-array members (they're not
> really needed in this case) in a couple of unions, and fix the
> following warnings:
>
> 1 drivers/net/ethernet/spacemit/k1_emac.c:122:42: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
> 1 drivers/net/ethernet/spacemit/k1_emac.c:122:32: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
> 1 drivers/net/ethernet/spacemit/k1_emac.c:121:42: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
> 1 drivers/net/ethernet/spacemit/k1_emac.c:121:32: 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>
Thanks,
I was able to reproduce the above build warnings.
And agree that this patch addresses them.
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][next] net: spacemit: Avoid -Wflex-array-member-not-at-end warnings
2025-10-21 11:54 [PATCH][next] net: spacemit: Avoid -Wflex-array-member-not-at-end warnings Gustavo A. R. Silva
2025-10-21 15:52 ` Simon Horman
@ 2025-10-22 8:10 ` Vivian Wang
2025-10-23 3:46 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Vivian Wang @ 2025-10-22 8:10 UTC (permalink / raw)
To: Gustavo A. R. Silva, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Yixun Lan
Cc: netdev, linux-riscv, spacemit, linux-kernel, linux-hardening
Hi Gustavo,
Thanks for the patch.
On 10/21/25 19:54, 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.
>
> Use regular arrays instead of flexible-array members (they're not
> really needed in this case) in a couple of unions, and fix the
> following warnings:
>
> 1 drivers/net/ethernet/spacemit/k1_emac.c:122:42: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
> 1 drivers/net/ethernet/spacemit/k1_emac.c:122:32: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
> 1 drivers/net/ethernet/spacemit/k1_emac.c:121:42: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
> 1 drivers/net/ethernet/spacemit/k1_emac.c:121:32: 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/ethernet/spacemit/k1_emac.h | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/spacemit/k1_emac.h b/drivers/net/ethernet/spacemit/k1_emac.h
> index 5a09e946a276..577efe66573e 100644
> --- a/drivers/net/ethernet/spacemit/k1_emac.h
> +++ b/drivers/net/ethernet/spacemit/k1_emac.h
> @@ -363,7 +363,7 @@ struct emac_desc {
> /* Keep stats in this order, index used for accessing hardware */
>
> union emac_hw_tx_stats {
> - struct {
> + struct individual_tx_stats {
> u64 tx_ok_pkts;
> u64 tx_total_pkts;
> u64 tx_ok_bytes;
> @@ -378,11 +378,11 @@ union emac_hw_tx_stats {
> u64 tx_pause_pkts;
> } stats;
>
> - DECLARE_FLEX_ARRAY(u64, array);
> + u64 array[sizeof(struct individual_tx_stats) / sizeof(u64)];
I originally wrote it as DECLARE_FLEX_ARRAY to avoid having to do the
sizeof dance, but I guess that's no good now? Oh well, I guess...
Acked-by: Vivian Wang <wangruikang@iscas.ac.cn>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH][next] net: spacemit: Avoid -Wflex-array-member-not-at-end warnings
2025-10-21 11:54 [PATCH][next] net: spacemit: Avoid -Wflex-array-member-not-at-end warnings Gustavo A. R. Silva
2025-10-21 15:52 ` Simon Horman
2025-10-22 8:10 ` Vivian Wang
@ 2025-10-23 3:46 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-10-23 3:46 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, dlan, netdev,
linux-riscv, spacemit, linux-kernel, linux-hardening
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 21 Oct 2025 12:54:10 +0100 you wrote:
> -Wflex-array-member-not-at-end was introduced in GCC-14, and we are
> getting ready to enable it, globally.
>
> Use regular arrays instead of flexible-array members (they're not
> really needed in this case) in a couple of unions, and fix the
> following warnings:
>
> [...]
Here is the summary with links:
- [next] net: spacemit: Avoid -Wflex-array-member-not-at-end warnings
https://git.kernel.org/netdev/net-next/c/10e0378f05d2
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-10-23 3:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-21 11:54 [PATCH][next] net: spacemit: Avoid -Wflex-array-member-not-at-end warnings Gustavo A. R. Silva
2025-10-21 15:52 ` Simon Horman
2025-10-22 8:10 ` Vivian Wang
2025-10-23 3:46 ` patchwork-bot+netdevbpf
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).