* [PATCH net-next] bnx2x: remove redundant NULL-pointer check
@ 2024-07-12 18:54 Nikita Kiryushin
2024-07-13 18:29 ` Simon Horman
0 siblings, 1 reply; 5+ messages in thread
From: Nikita Kiryushin @ 2024-07-12 18:54 UTC (permalink / raw)
To: Sudarsana Kalluru
Cc: Nikita Kiryushin, Manish Chopra, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, netdev, linux-kernel, lvc-project
bnx2x_get_vf_config() contains NULL-pointer checks for
mac_obj and vlan_obj.
The fields checked are assigned to (after macro expansions):
mac_obj = &((vf)->vfqs[0].mac_obj);
vlan_obj = &((vf)->vfqs[0].vlan_obj);
It is impossible to get NULL for those (and (vf)->vfqs was
checked earlier in bnx2x_vf_op_prep).
Remove superfluous NULL-pointer check and associated
unreachable code to improve readability.
Signed-off-by: Nikita Kiryushin <kiryushin@ancud.ru>
---
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
index 77d4cb4ad782..3415bbe722a8 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
@@ -2619,10 +2619,6 @@ int bnx2x_get_vf_config(struct net_device *dev, int vfidx,
mac_obj = &bnx2x_leading_vfq(vf, mac_obj);
vlan_obj = &bnx2x_leading_vfq(vf, vlan_obj);
- if (!mac_obj || !vlan_obj) {
- BNX2X_ERR("VF partially initialized\n");
- return -EINVAL;
- }
ivi->vf = vfidx;
ivi->qos = 0;
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] bnx2x: remove redundant NULL-pointer check
2024-07-12 18:54 [PATCH net-next] bnx2x: remove redundant NULL-pointer check Nikita Kiryushin
@ 2024-07-13 18:29 ` Simon Horman
2024-07-15 13:52 ` Nikita Kiryushin
0 siblings, 1 reply; 5+ messages in thread
From: Simon Horman @ 2024-07-13 18:29 UTC (permalink / raw)
To: Nikita Kiryushin
Cc: Sudarsana Kalluru, Manish Chopra, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, netdev, linux-kernel, lvc-project
On Fri, Jul 12, 2024 at 09:54:31PM +0300, Nikita Kiryushin wrote:
> bnx2x_get_vf_config() contains NULL-pointer checks for
> mac_obj and vlan_obj.
>
> The fields checked are assigned to (after macro expansions):
>
> mac_obj = &((vf)->vfqs[0].mac_obj);
> vlan_obj = &((vf)->vfqs[0].vlan_obj);
>
> It is impossible to get NULL for those
Hi Nikita,
I agree with the above.
> (and (vf)->vfqs was
> checked earlier in bnx2x_vf_op_prep).
But, FWIIW, I don't think the test on the two lines above is relevant.
bnx2x_vf_op_prep does, conditionally, check that (vf)->vfqs is not NULL.
But if (vf)->vfqs was null in the code you are updating
(and I'm not saying it can be, just if it was),
then neither mac_obj nor vlan_obj would be NULL due to the
layout of struct bnx2x_vf_queue.
> Remove superfluous NULL-pointer check and associated
> unreachable code to improve readability.
I also agree with this.
> Signed-off-by: Nikita Kiryushin <kiryushin@ancud.ru>
...
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] bnx2x: remove redundant NULL-pointer check
2024-07-13 18:29 ` Simon Horman
@ 2024-07-15 13:52 ` Nikita Kiryushin
2024-07-15 18:10 ` Simon Horman
0 siblings, 1 reply; 5+ messages in thread
From: Nikita Kiryushin @ 2024-07-15 13:52 UTC (permalink / raw)
To: Simon Horman
Cc: Sudarsana Kalluru, Manish Chopra, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, netdev, linux-kernel, lvc-project
I agree, I guess I was meaning to state, that bnx2x_vf_op_prep()
already contains all the needed checks
On 7/13/24 21:29, Simon Horman wrote:
> But, FWIIW, I don't think the test on the two lines above is relevant.
>
> bnx2x_vf_op_prep does, conditionally, check that (vf)->vfqs is not NULL.
> But if (vf)->vfqs was null in the code you are updating
> (and I'm not saying it can be, just if it was),
> then neither mac_obj nor vlan_obj would be NULL due to the
> layout of struct bnx2x_vf_queue.
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] bnx2x: remove redundant NULL-pointer check
2024-07-15 13:52 ` Nikita Kiryushin
@ 2024-07-15 18:10 ` Simon Horman
2024-07-16 19:23 ` Nikita Kiryushin
0 siblings, 1 reply; 5+ messages in thread
From: Simon Horman @ 2024-07-15 18:10 UTC (permalink / raw)
To: Nikita Kiryushin
Cc: Sudarsana Kalluru, Manish Chopra, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, netdev, linux-kernel, lvc-project
On Mon, Jul 15, 2024 at 04:52:40PM +0300, Nikita Kiryushin wrote:
> I agree, I guess I was meaning to state, that bnx2x_vf_op_prep()
> already contains all the needed checks
Thanks, I agree with that.
Though if it would me I'd just drop the reference
to bnx2x_vf_op_prep entirely.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next] bnx2x: remove redundant NULL-pointer check
2024-07-15 18:10 ` Simon Horman
@ 2024-07-16 19:23 ` Nikita Kiryushin
0 siblings, 0 replies; 5+ messages in thread
From: Nikita Kiryushin @ 2024-07-16 19:23 UTC (permalink / raw)
To: Simon Horman
Cc: Sudarsana Kalluru, Manish Chopra, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, netdev, linux-kernel, lvc-project
On 7/15/24 21:10, Simon Horman wrote:
> Though if it would me I'd just drop the reference
> to bnx2x_vf_op_prep entirely.
>
Thank you for the feedback! I guess I will do so in second version
when net-next open next time
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-07-16 19:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-12 18:54 [PATCH net-next] bnx2x: remove redundant NULL-pointer check Nikita Kiryushin
2024-07-13 18:29 ` Simon Horman
2024-07-15 13:52 ` Nikita Kiryushin
2024-07-15 18:10 ` Simon Horman
2024-07-16 19:23 ` Nikita Kiryushin
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).