l2: coverity complains dead codes 90/37390/3
authorSteven Luong <sluong@cisco.com>
Thu, 13 Oct 2022 00:08:12 +0000 (17:08 -0700)
committerNeale Ranns <neale@graphiant.com>
Thu, 13 Oct 2022 23:58:41 +0000 (23:58 +0000)
commit662c59a80a886f9a6741eb95229ee2aca2e06fad
tree71894e464a32a445862d8c218f4df5fba14d8bac
parent10e5b4a016061f2d9485ff309d1239abb012aae0
l2: coverity complains dead codes

Coverity complains dead codes in 2 places due to a recent commit as
pointed out in Fixes. The dead codes are
      if (seed < L2_BD_ID_MAX % 2)
        is_seed_low = 1;
and
      if (is_seed_low)
        seed += (2 * (i % 2) - 1) * i;

seed can never be less than (L2_BD_ID_MAX % 2).
Consequently, is_seed_low is always 0.

There is also other problem. The inner loop is iterating only once.

The fix is to greatly simplify the code to generate a random bd_id.

Type: fix
Fixes: Ieb6919f958f437fc603d5e1f48cab01de780951d

Signed-off-by: Steven Luong <sluong@cisco.com>
Change-Id: I318773b9a59950920e051548ef14e36054ebd5e6
src/vnet/l2/l2_bd.c