vppinfra: fix bitmap can't get correct next clear index 08/34808/3
authorjiangxiaoming <jiangxiaoming@outlook.com>
Thu, 30 Dec 2021 08:52:38 +0000 (08:52 +0000)
committerDamjan Marion <dmarion@me.com>
Sat, 1 Jan 2022 20:38:50 +0000 (20:38 +0000)
when bitmap vec len is 1 and all the bits has been
occupied, clib_bitmap_next_clear(ai, 63) will
return result:65 which should be 64. It will lead to
missing iteration for pool_foreach.

Type: fix
Signed-off-by: jiangxiaoming <jiangxiaoming@outlook.com>
Change-Id: Iadac7e6f6b4da357943c4c9d50bf22353c4a8408

src/vppinfra/bitmap.h

index 3c95bfb..d9bdd0f 100644 (file)
@@ -742,8 +742,7 @@ clib_bitmap_next_clear (uword * ai, uword i)
            return log2_first_set (t) + i0 * BITS (ai[0]);
        }
 
-      /* no clear bit left in bitmap, return bit just beyond bitmap */
-      return (i0 * BITS (ai[0])) + 1;
+      return i0 * BITS (ai[0]);
     }
   return i;
 }