[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <36DC826EE102DC1F+20250910055636.GA1832711@nic-Precision-5820-Tower>
Date: Wed, 10 Sep 2025 13:56:36 +0800
From: Yibo Dong <dong100@...se.com>
To: Jakub Kicinski <kuba@...nel.org>
Cc: "Anwar, Md Danish" <a0501179@...com>, andrew+netdev@...n.ch,
davem@...emloft.net, edumazet@...gle.com, pabeni@...hat.com,
horms@...nel.org, corbet@....net, gur.stavi@...wei.com,
maddy@...ux.ibm.com, mpe@...erman.id.au, danishanwar@...com,
lee@...ger.us, gongfan1@...wei.com, lorenzo@...nel.org,
geert+renesas@...der.be, Parthiban.Veerasooran@...rochip.com,
lukas.bulwahn@...hat.com, alexanderduyck@...com,
richardcochran@...il.com, kees@...nel.org, gustavoars@...nel.org,
rdunlap@...radead.org, vadim.fedorenko@...ux.dev,
netdev@...r.kernel.org, linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-hardening@...r.kernel.org
Subject: Re: [PATCH net-next v11 3/5] net: rnpgbe: Add basic mbx ops support
On Tue, Sep 09, 2025 at 01:55:54PM -0700, Jakub Kicinski wrote:
> On Tue, 9 Sep 2025 19:52:21 +0530 Anwar, Md Danish wrote:
> > > + for (i = 0; i < size_in_words; i++)
> > > + msg[i] = mbx_data_rd32(mbx, MUCSE_MBX_FWPF_SHM + 4 * i);
> >
> > The array indexing calculation should use multiplication by sizeof(u32)
> > instead of hardcoded 4.
>
> Not sure this is really necessary, I'd expect C programmers to intuit
> that 4 is the number of bytes in u32 here. sizeof(u32) is going to
> overflow 80 char line limit and cause more harm than good.
>
I found similar code in other drivers, ixgbe, it like this:
#define IXGBE_READ_REG_ARRAY(a, reg, offset) \
ixgbe_read_reg((a), (reg) + ((offset) << 2))
for (i = 0; i < size; i++)
msg[i] = IXGBE_READ_REG_ARRAY(hw, IXGBE_PFMBMEM(vf_number), i);
Maybe I should follow that style?
Thanks for your feedback.
Powered by blists - more mailing lists