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

From: Simon Horman <[email-masked]>
Date: Sat, 13 Jul 2024 19:29:28 +0100

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 <[email-masked]>

...