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

 



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) {
 		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)
-- 
2.15.0-rc1




[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