qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2] bitmap: fix BITMAP_LAST_WORD_MASK


From: Wei Wang
Subject: Re: [Qemu-devel] [PATCH v2] bitmap: fix BITMAP_LAST_WORD_MASK
Date: Wed, 08 Aug 2018 09:34:39 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0

On 08/07/2018 05:53 PM, Dr. David Alan Gilbert wrote:
* Wei Wang (address@hidden) wrote:
On 08/07/2018 03:39 PM, Peter Xu wrote:
On Tue, Jul 31, 2018 at 06:01:18PM +0800, Wei Wang wrote:
When "nbits = 0", which means no bits to mask, this macro is expected to
return 0, instead of 0xffffffff. This patch changes the macro to return
0 when there is no bit needs to be masked.

Signed-off-by: Wei Wang <address@hidden>
CC: Juan Quintela <address@hidden>
CC: Dr. David Alan Gilbert <address@hidden>
CC: Peter Xu <address@hidden>
Reviewed-by: Peter Xu <address@hidden>

Is there any existing path that can trigger this nbits==0?
Not sure about other bitmap APIs which call this macro. But it happens in
the patches we are working on, which use bitmap_count_one.
It would be good to have the macro itself handle this corner case, so that
callers won't need to worry about that.
Given that I see you're having a similar discussion on the kernel list
we should see how that pans out before making qemu changes.

OK.
The situation is a little different in Linux, because all the callers there have already taken the responsibilities to avoid the "nbits=0" corner case, that's also the reason that they want to stick with the old way. Here in QEMU, most callers (e.g. bitmap_count_one, bitmap_fill, bitmap_intersects) haven't checked that, so fixing the macro itself might be a better choice here.

Best,
Wei



reply via email to

[Prev in Thread] Current Thread [Next in Thread]