[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d66db3f6-4c6f-4dc3-ae4f-3502d9b81c79@iscas.ac.cn>
Date: Wed, 22 Oct 2025 16:10:13 +0800
From: Vivian Wang <wangruikang@...as.ac.cn>
To: "Gustavo A. R. Silva" <gustavoars@...nel.org>,
Andrew Lunn <andrew+netdev@...n.ch>, "David S. Miller"
<davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Yixun Lan <dlan@...too.org>
Cc: netdev@...r.kernel.org, linux-riscv@...ts.infradead.org,
spacemit@...ts.linux.dev, linux-kernel@...r.kernel.org,
linux-hardening@...r.kernel.org
Subject: Re: [PATCH][next] net: spacemit: Avoid -Wflex-array-member-not-at-end
warnings
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@...nel.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@...as.ac.cn>
Powered by blists - more mailing lists