Re: 答复: [PATCH v5 1/2] lib: bitmap: add tests for bitmap_find_next_zero_area_off()
From: Yury Norov
Date: Fri Jun 19 2026 - 10:01:17 EST
On Thu, Jun 18, 2026 at 12:44:19PM +0000, 孙毅 (Yi Sun) wrote:
>
> > > > + expect_eq_uint(1,
> > > > + !!(bitmap_find_next_zero_area_off(bmap, 192, 0, 33, 0, 0) > 192));
> > >
> > > It should be >= here.
> >
> > There would be a problem if the return value equals 192.
> > size = 192;
> > if (end > size)
> > return end;
> > So the return value must be greater than 192.
>
> I agree with the patch you suggested that returns the size, so it needs to be changed to >= here.
The valid index range is 0...(size-1), i.e. for 10-bits bitmap the
highest valid index is 9. If your implementation never returns 'size',
it doesn't mean that the test should consider 'size' as a valid index.
(I'm not even sure that your implementation never returns 'size').
> > > > +}
> > > > +
> > > > static void __init test_fill_set(void)
> > > > {
> > > > DECLARE_BITMAP(bmap, 1024);
> > > > @@ -1559,6 +1596,7 @@ static void __init selftest(void)
> > > > test_for_each_clear_bitrange_from();
> > > > test_for_each_set_clump8();
> > > > test_for_each_set_bit_wrap();
> > > > + test_bitmap_find_next_zero_area_off();
> > > > }
> > > >
> > > > KSTM_MODULE_LOADERS(test_bitmap);
> > > > --
> > > > 2.34.1