Re: [ibsim patch 15/23] sim_mad.c: Fix a CONSTANT_EXPRESSION_RESULT for switch_lookup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 1/2/2019 8:13 AM, Honggang Li wrote:
> Issue was detected by Coverity.
> 
> "(outport = node->sw->fdb[lid]) < 0" is always false regardless of
> the values of its operands, because node->sw->fdb[lid] is uint8_t.
> 
> Signed-off-by: Honggang Li <honli@xxxxxxxxxx>
> ---
>  ibsim/sim_mad.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/ibsim/sim_mad.c b/ibsim/sim_mad.c
> index b6e24881fb9e..5ef1d0a6dbeb 100644
> --- a/ibsim/sim_mad.c
> +++ b/ibsim/sim_mad.c
> @@ -1579,12 +1579,11 @@ static int switch_lookup(Node * node, int lid)
>  	if (!node->sw)
>  		return -1;
>  
> -	if (lid > node->sw->linearFDBtop || (outport = node->sw->fdb[lid]) < 0) {
> +	if (lid > node->sw->linearFDBtop) {

Same comment as patch 11/23.

This is not the proper fix. I think that the check should be == 0xff
rather than < 0 or eliminated as in this patch since fdb is initialized
to 0xff (no port for LID).

-- Hal

>  		IBWARN("sw guid %" PRIx64 ": bad lid %u", node->nodeguid, lid);
>  		return -1;
>  	}
> -
> -	return outport;
> +	return outport = node->sw->fdb[lid];
>  }
>  
>  static int port_get_remote(Port * port, Node ** remotenode, Port ** remoteport)
> 



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux