[PATCH v1] virBitmapNextClearBit: Correct virBitmapNextClearBit function header comment

Aaron M. Brown posted 1 patch 1 month, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20250722175949.91137-1-aaronmbr@linux.ibm.com
src/util/virbitmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH v1] virBitmapNextClearBit: Correct virBitmapNextClearBit function header comment
Posted by Aaron M. Brown 1 month, 2 weeks ago
This patch corrects the header comment for virBitmapNextClearBIt.
Currently, the header comment reads:

`@pos can be -1 to search for the first set bit.`

However, this statement is false.

We can prove this by referencing the virbitmaptest functions, i.e
virbitmaptest.c:223, in which i = 0

if (virBitmapNextClearBIt(bitmap, -1) != 0)
    return -1

Because this is a zero set, this case would fail if the header statement was true as is.

Signed-off-by: Aaron M. Brown <aaronmbr@linux.ibm.com>
---
 src/util/virbitmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
index 8a3f33c806..1a3e75671c 100644
--- a/src/util/virbitmap.c
+++ b/src/util/virbitmap.c
@@ -948,7 +948,7 @@ virBitmapLastSetBit(virBitmap *bitmap)
  * @pos: the position after which to search for a clear bit
  *
  * Search for the first clear bit after position @pos in bitmap @bitmap.
- * @pos can be -1 to search for the first set bit. Position starts
+ * @pos can be -1 to search for the first clear bit. Position starts
  * at 0.
  *
  * Returns the position of the found bit, or -1 if no bit found.
-- 
2.39.5 (Apple Git-154)
Re: [PATCH v1] virBitmapNextClearBit: Correct virBitmapNextClearBit function header comment
Posted by Michal Prívozník via Devel 1 month, 2 weeks ago
On 7/22/25 19:59, Aaron M. Brown wrote:
> This patch corrects the header comment for virBitmapNextClearBIt.
> Currently, the header comment reads:
> 
> `@pos can be -1 to search for the first set bit.`
> 
> However, this statement is false.
> 
> We can prove this by referencing the virbitmaptest functions, i.e
> virbitmaptest.c:223, in which i = 0
> 
> if (virBitmapNextClearBIt(bitmap, -1) != 0)
>     return -1
> 
> Because this is a zero set, this case would fail if the header statement was true as is.

Long story short, the function searches a clear bit. I suspect a copy
paste error.

> 
> Signed-off-by: Aaron M. Brown <aaronmbr@linux.ibm.com>
> ---
>  src/util/virbitmap.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
> index 8a3f33c806..1a3e75671c 100644
> --- a/src/util/virbitmap.c
> +++ b/src/util/virbitmap.c
> @@ -948,7 +948,7 @@ virBitmapLastSetBit(virBitmap *bitmap)
>   * @pos: the position after which to search for a clear bit
>   *
>   * Search for the first clear bit after position @pos in bitmap @bitmap.
> - * @pos can be -1 to search for the first set bit. Position starts
> + * @pos can be -1 to search for the first clear bit. Position starts
>   * at 0.
>   *
>   * Returns the position of the found bit, or -1 if no bit found.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>

and merged. Congratulations on your first libvirt contribution!

Michal
Re: [PATCH v1] virBitmapNextClearBit: Correct virBitmapNextClearBit function header comment
Posted by Aaron Brown 1 month, 2 weeks ago
> and merged. Congratulations on your first libvirt contribution!

Thank you Michal ! Glad to help :-)