Messages in this thread | | | Date | Thu, 14 Dec 2017 19:47:29 +0800 | From | Wei Wang <> | Subject | Re: [virtio-dev] Re: [PATCH v19 3/7] xbitmap: add more operations |
| |
On 12/14/2017 11:47 AM, Wei Wang wrote: > On 12/13/2017 10:16 PM, Tetsuo Handa wrote: > > >> >>> if (set) >>> ret = find_next_bit(&tmp, >>> BITS_PER_LONG, ebit); >>> else >>> ret = find_next_zero_bit(&tmp, >>> BITS_PER_LONG, >>> ebit); >>> if (ret < BITS_PER_LONG) >>> return ret - 2 + ida_start; >>> } else if (bitmap) { >>> if (set) >>> ret = find_next_bit(bitmap->bitmap, >>> IDA_BITMAP_BITS, bit); >>> else >>> ret = >>> find_next_zero_bit(bitmap->bitmap, >>> IDA_BITMAP_BITS, bit); >> "bit" may not be 0 for the first round and "bit" is always 0 afterwords. >> But where is the guaranteed that "end" is a multiple of >> IDA_BITMAP_BITS ? >> Please explain why it is correct to use IDA_BITMAP_BITS unconditionally >> for the last round. > > There missed something here, it will be: > > nbits = min(end - ida_start + 1, IDA_BITMAP_BITS - bit);
captured a bug here, should be: nbits = min(end - ida_start + 1, (unsigned long)IDA_BITMAP_BITS);
> if (set) > ret = find_next_bit(bitmap->bitmap, nbits, bit); > else > ret = find_next_zero_bit(bitmap->bitmap, > nbits, bit); > if (ret < nbits) > return ret + ida_start; > >
Best, Wei
| |