Re: [PATCH 1/3] Use virBitmapNextClearBit in networkNextClassID

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

 



On 03/06/2015 10:02 AM, Ján Tomko wrote:
> Instead of finding the next clear bit by calling virBitmapGetBit
> in a loop, use the virBitmapNextClearBit helper.
> ---
>  src/network/bridge_driver.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)

ACK.

> 
> diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
> index 2a61991..b0c5c21 100644
> --- a/src/network/bridge_driver.c
> +++ b/src/network/bridge_driver.c
> @@ -4711,13 +4711,11 @@ networkCheckBandwidth(virNetworkObjPtr net,
>  static ssize_t
>  networkNextClassID(virNetworkObjPtr net)
>  {
> -    size_t ret = 0;
> -    bool is_set = false;
> +    ssize_t ret = 0;
>  
> -    while (virBitmapGetBit(net->class_id, ret, &is_set) == 0 && is_set)
> -        ret++;
> +    ret = virBitmapNextClearBit(net->class_id, -1);
>  
> -    if (is_set || virBitmapSetBit(net->class_id, ret) < 0)
> +    if (ret < 0 || virBitmapSetBit(net->class_id, ret) < 0)
>          return -1;
>  
>      return ret;
> 

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]