diff mbox series

[net-next] bnx2x: remove redundant NULL-pointer check

Message ID 20240712185431.81805-1-kiryushin@ancud.ru (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net-next] bnx2x: remove redundant NULL-pointer check | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 817 this patch: 817
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 823 this patch: 823
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 822 this patch: 822
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 10 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-07-13--03-00 (tests: 696)

Commit Message

Nikita Kiryushin July 12, 2024, 6:54 p.m. UTC
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(-)

Comments

Simon Horman July 13, 2024, 6:29 p.m. UTC | #1
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>

...
Nikita Kiryushin July 15, 2024, 1:52 p.m. UTC | #2
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.
>
Simon Horman July 15, 2024, 6:10 p.m. UTC | #3
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.
Nikita Kiryushin July 16, 2024, 7:23 p.m. UTC | #4
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
diff mbox series

Patch

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;