Re: [virtio-dev] Re: [PATCH v19 3/7] xbitmap: add more operations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]
  Powered by Linux