* [PATCH net-next] octeontx2-pf: Remove unnecessary bounds check
@ 2026-01-19 16:39 Simon Horman
2026-01-19 21:17 ` Vadim Fedorenko
2026-01-21 2:40 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 4+ messages in thread
From: Simon Horman @ 2026-01-19 16:39 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: Sunil Goutham, Geetha sowjanya, Subbaraya Sundeep,
Hariprasad Kelam, Bharat Bhushan, netdev
active_fec is a 2-bit unsigned field, and thus can only have the values
0-3. So checking that it is less than 4 is unnecessary.
Simplify the code by dropping this check.
As it no longer fits well where it is, move FEC_MAX_INDEX to towards the
top of the file. And add the prefix OXT2. I believe this is more
idiomatic.
Flagged by Smatch as:
...//otx2_ethtool.c:1024 otx2_get_fecparam() warn: always true condition '(pfvf->linfo.fec < 4) => (0-3 < 4)'
No functional change intended.
Compile tested only.
Signed-off-by: Simon Horman <horms@kernel.org>
---
drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
index 8918be3ce45e9ae2e1f2fbc6396df0ab6c85bc22..a0340f3422bf90af524f682fc1fbe211d64c129c 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
@@ -66,6 +66,8 @@ static const struct otx2_stat otx2_queue_stats[] = {
{ "frames", 1 },
};
+#define OTX2_FEC_MAX_INDEX 4
+
static const unsigned int otx2_n_dev_stats = ARRAY_SIZE(otx2_dev_stats);
static const unsigned int otx2_n_drv_stats = ARRAY_SIZE(otx2_drv_stats);
static const unsigned int otx2_n_queue_stats = ARRAY_SIZE(otx2_queue_stats);
@@ -1031,15 +1033,14 @@ static int otx2_get_fecparam(struct net_device *netdev,
ETHTOOL_FEC_BASER,
ETHTOOL_FEC_RS,
ETHTOOL_FEC_BASER | ETHTOOL_FEC_RS};
-#define FEC_MAX_INDEX 4
- if (pfvf->linfo.fec < FEC_MAX_INDEX)
- fecparam->active_fec = fec[pfvf->linfo.fec];
+
+ fecparam->active_fec = fec[pfvf->linfo.fec];
rsp = otx2_get_fwdata(pfvf);
if (IS_ERR(rsp))
return PTR_ERR(rsp);
- if (rsp->fwdata.supported_fec < FEC_MAX_INDEX) {
+ if (rsp->fwdata.supported_fec < OTX2_FEC_MAX_INDEX) {
if (!rsp->fwdata.supported_fec)
fecparam->fec = ETHTOOL_FEC_NONE;
else
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] octeontx2-pf: Remove unnecessary bounds check
2026-01-19 16:39 [PATCH net-next] octeontx2-pf: Remove unnecessary bounds check Simon Horman
@ 2026-01-19 21:17 ` Vadim Fedorenko
2026-01-20 10:13 ` Hariprasad Kelam
2026-01-21 2:40 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 4+ messages in thread
From: Vadim Fedorenko @ 2026-01-19 21:17 UTC (permalink / raw)
To: Simon Horman, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
Cc: Sunil Goutham, Geetha sowjanya, Subbaraya Sundeep,
Hariprasad Kelam, Bharat Bhushan, netdev
On 19/01/2026 16:39, Simon Horman wrote:
> active_fec is a 2-bit unsigned field, and thus can only have the values
> 0-3. So checking that it is less than 4 is unnecessary.
>
> Simplify the code by dropping this check.
>
> As it no longer fits well where it is, move FEC_MAX_INDEX to towards the
> top of the file. And add the prefix OXT2. I believe this is more
> idiomatic.
>
> Flagged by Smatch as:
> ...//otx2_ethtool.c:1024 otx2_get_fecparam() warn: always true condition '(pfvf->linfo.fec < 4) => (0-3 < 4)'
>
> No functional change intended.
> Compile tested only.
>
> Signed-off-by: Simon Horman <horms@kernel.org>
> ---
> drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
> index 8918be3ce45e9ae2e1f2fbc6396df0ab6c85bc22..a0340f3422bf90af524f682fc1fbe211d64c129c 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
> @@ -66,6 +66,8 @@ static const struct otx2_stat otx2_queue_stats[] = {
> { "frames", 1 },
> };
>
> +#define OTX2_FEC_MAX_INDEX 4
> +
> static const unsigned int otx2_n_dev_stats = ARRAY_SIZE(otx2_dev_stats);
> static const unsigned int otx2_n_drv_stats = ARRAY_SIZE(otx2_drv_stats);
> static const unsigned int otx2_n_queue_stats = ARRAY_SIZE(otx2_queue_stats);
> @@ -1031,15 +1033,14 @@ static int otx2_get_fecparam(struct net_device *netdev,
> ETHTOOL_FEC_BASER,
> ETHTOOL_FEC_RS,
> ETHTOOL_FEC_BASER | ETHTOOL_FEC_RS};
> -#define FEC_MAX_INDEX 4
> - if (pfvf->linfo.fec < FEC_MAX_INDEX)
> - fecparam->active_fec = fec[pfvf->linfo.fec];
> +
> + fecparam->active_fec = fec[pfvf->linfo.fec];
>
> rsp = otx2_get_fwdata(pfvf);
> if (IS_ERR(rsp))
> return PTR_ERR(rsp);
>
> - if (rsp->fwdata.supported_fec < FEC_MAX_INDEX) {
> + if (rsp->fwdata.supported_fec < OTX2_FEC_MAX_INDEX) {
> if (!rsp->fwdata.supported_fec)
> fecparam->fec = ETHTOOL_FEC_NONE;
> else
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] octeontx2-pf: Remove unnecessary bounds check
2026-01-19 21:17 ` Vadim Fedorenko
@ 2026-01-20 10:13 ` Hariprasad Kelam
0 siblings, 0 replies; 4+ messages in thread
From: Hariprasad Kelam @ 2026-01-20 10:13 UTC (permalink / raw)
To: Vadim Fedorenko
Cc: Simon Horman, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Sunil Goutham, Geetha sowjanya,
Subbaraya Sundeep, Bharat Bhushan, netdev
On 2026-01-20 at 02:47:48, Vadim Fedorenko (vadim.fedorenko@linux.dev) wrote:
> On 19/01/2026 16:39, Simon Horman wrote:
> > active_fec is a 2-bit unsigned field, and thus can only have the values
> > 0-3. So checking that it is less than 4 is unnecessary.
> >
> > Simplify the code by dropping this check.
> >
> > As it no longer fits well where it is, move FEC_MAX_INDEX to towards the
> > top of the file. And add the prefix OXT2. I believe this is more
> > idiomatic.
> >
> > Flagged by Smatch as:
> > ...//otx2_ethtool.c:1024 otx2_get_fecparam() warn: always true condition '(pfvf->linfo.fec < 4) => (0-3 < 4)'
> >
> > No functional change intended.
> > Compile tested only.
> >
> > Signed-off-by: Simon Horman <horms@kernel.org>
> > ---
> > drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 9 +++++----
> > 1 file changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
> > index 8918be3ce45e9ae2e1f2fbc6396df0ab6c85bc22..a0340f3422bf90af524f682fc1fbe211d64c129c 100644
> > --- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
> > +++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
> > @@ -66,6 +66,8 @@ static const struct otx2_stat otx2_queue_stats[] = {
> > { "frames", 1 },
> > };
> > +#define OTX2_FEC_MAX_INDEX 4
> > +
> > static const unsigned int otx2_n_dev_stats = ARRAY_SIZE(otx2_dev_stats);
> > static const unsigned int otx2_n_drv_stats = ARRAY_SIZE(otx2_drv_stats);
> > static const unsigned int otx2_n_queue_stats = ARRAY_SIZE(otx2_queue_stats);
> > @@ -1031,15 +1033,14 @@ static int otx2_get_fecparam(struct net_device *netdev,
> > ETHTOOL_FEC_BASER,
> > ETHTOOL_FEC_RS,
> > ETHTOOL_FEC_BASER | ETHTOOL_FEC_RS};
> > -#define FEC_MAX_INDEX 4
> > - if (pfvf->linfo.fec < FEC_MAX_INDEX)
> > - fecparam->active_fec = fec[pfvf->linfo.fec];
> > +
> > + fecparam->active_fec = fec[pfvf->linfo.fec];
> > rsp = otx2_get_fwdata(pfvf);
> > if (IS_ERR(rsp))
> > return PTR_ERR(rsp);
> > - if (rsp->fwdata.supported_fec < FEC_MAX_INDEX) {
> > + if (rsp->fwdata.supported_fec < OTX2_FEC_MAX_INDEX) {
> > if (!rsp->fwdata.supported_fec)
> > fecparam->fec = ETHTOOL_FEC_NONE;
> > else
>
> Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
>
Reviewed-by: Hariprasad Kelam <hkelam@marvell.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] octeontx2-pf: Remove unnecessary bounds check
2026-01-19 16:39 [PATCH net-next] octeontx2-pf: Remove unnecessary bounds check Simon Horman
2026-01-19 21:17 ` Vadim Fedorenko
@ 2026-01-21 2:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-01-21 2:40 UTC (permalink / raw)
To: Simon Horman
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, sgoutham, gakula,
sbhatta, hkelam, bbhushan2, netdev
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Mon, 19 Jan 2026 16:39:37 +0000 you wrote:
> active_fec is a 2-bit unsigned field, and thus can only have the values
> 0-3. So checking that it is less than 4 is unnecessary.
>
> Simplify the code by dropping this check.
>
> As it no longer fits well where it is, move FEC_MAX_INDEX to towards the
> top of the file. And add the prefix OXT2. I believe this is more
> idiomatic.
>
> [...]
Here is the summary with links:
- [net-next] octeontx2-pf: Remove unnecessary bounds check
https://git.kernel.org/netdev/net-next/c/2ec113ee41b6
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:[~2026-01-21 2:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-19 16:39 [PATCH net-next] octeontx2-pf: Remove unnecessary bounds check Simon Horman
2026-01-19 21:17 ` Vadim Fedorenko
2026-01-20 10:13 ` Hariprasad Kelam
2026-01-21 2:40 ` 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