bond: coverity woes 91/11391/2
authorSteven <sluong@cisco.com>
Tue, 27 Mar 2018 04:52:11 +0000 (21:52 -0700)
committerDamjan Marion <dmarion.lists@gmail.com>
Tue, 27 Mar 2018 16:03:59 +0000 (16:03 +0000)
commit18c0f229cec4695cf77a0e3a9033d2ff0d1e085a
tree625838d9ef41b98d258bb2bf31ec04b58ade8dc2
parented76ee24dfe76fb9400470a4efb3871acd37cad9
bond: coverity woes

coverity complains about statements in function A

function A
{
   x % vec_len (y)
}

because vec_len (y) is a macro and may return 0 if the pointer y is null.
But coverity fails to realize the same statement vec_len (y) was already
invoked and checked in the caller of function A and punt if vec_len (y) is 0.

We can fix the coverity warning and shave off a few cpu cycles by caching
the result of vec_len (y) and pass it around to avoid calling vec_len (y)
again in multiple places.

Change-Id: I095166373abd3af3859646f860ee97c52f12fb50
Signed-off-by: Steven <sluong@cisco.com>
src/vnet/bonding/device.c
src/vnet/bonding/node.h