Re: [PATCH v1 17/31] test_driver: Adapt to new virNetworkObjList accessors

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

 



On Thu, Feb 26, 2015 at 15:17:26 +0100, Michal Privoznik wrote:
> Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
> ---
>  src/test/test_driver.c | 64 ++++++++++----------------------------------------
>  1 file changed, 12 insertions(+), 52 deletions(-)
> 
> diff --git a/src/test/test_driver.c b/src/test/test_driver.c
> index ecb7bcd..0a68283 100644
> --- a/src/test/test_driver.c
> +++ b/src/test/test_driver.c
> @@ -3543,16 +3543,11 @@ static virNetworkPtr testNetworkLookupByName(virConnectPtr conn,
>  static int testConnectNumOfNetworks(virConnectPtr conn)
>  {
>      testConnPtr privconn = conn->privateData;
> -    int numActive = 0;
> -    size_t i;
> +    int numActive;
>  
>      testDriverLock(privconn);
> -    for (i = 0; i < privconn->networks->count; i++) {
> -        virNetworkObjLock(privconn->networks->objs[i]);
> -        if (virNetworkObjIsActive(privconn->networks->objs[i]))
> -            numActive++;
> -        virNetworkObjUnlock(privconn->networks->objs[i]);
> -    }
> +    numActive = virNetworkObjListNumOfNetworks(privconn->networks,
> +                                               true, NULL, conn);
>      testDriverUnlock(privconn);
>  
>      return numActive;
> @@ -3560,44 +3555,24 @@ static int testConnectNumOfNetworks(virConnectPtr conn)
>  
>  static int testConnectListNetworks(virConnectPtr conn, char **const names, int nnames) {
>      testConnPtr privconn = conn->privateData;
> -    int n = 0;
> -    size_t i;
> +    int n;
>  
>      testDriverLock(privconn);
> -    memset(names, 0, sizeof(*names)*nnames);

The list will be no longer set to NULL pointers.

> -    for (i = 0; i < privconn->networks->count && n < nnames; i++) {
> -        virNetworkObjLock(privconn->networks->objs[i]);
> -        if (virNetworkObjIsActive(privconn->networks->objs[i]) &&
> -            VIR_STRDUP(names[n++], privconn->networks->objs[i]->def->name) < 0) {
> -            virNetworkObjUnlock(privconn->networks->objs[i]);
> -            goto error;
> -        }
> -        virNetworkObjUnlock(privconn->networks->objs[i]);
> -    }
> +    n = virNetworkObjListGetNames(privconn->networks,
> +                                  true, names, nnames, NULL, conn);
>      testDriverUnlock(privconn);
>  
>      return n;
> -
> - error:
> -    for (n = 0; n < nnames; n++)
> -        VIR_FREE(names[n]);
> -    testDriverUnlock(privconn);
> -    return -1;
>  }
>  
>  static int testConnectNumOfDefinedNetworks(virConnectPtr conn)
>  {
>      testConnPtr privconn = conn->privateData;
> -    int numInactive = 0;
> -    size_t i;
> +    int numInactive;
>  
>      testDriverLock(privconn);
> -    for (i = 0; i < privconn->networks->count; i++) {
> -        virNetworkObjLock(privconn->networks->objs[i]);
> -        if (!virNetworkObjIsActive(privconn->networks->objs[i]))
> -            numInactive++;
> -        virNetworkObjUnlock(privconn->networks->objs[i]);
> -    }
> +    numInactive = virNetworkObjListNumOfNetworks(privconn->networks,
> +                                                 false, NULL, conn);
>      testDriverUnlock(privconn);
>  
>      return numInactive;
> @@ -3605,29 +3580,14 @@ static int testConnectNumOfDefinedNetworks(virConnectPtr conn)
>  
>  static int testConnectListDefinedNetworks(virConnectPtr conn, char **const names, int nnames) {
>      testConnPtr privconn = conn->privateData;
> -    int n = 0;
> -    size_t i;
> +    int n;
>  
>      testDriverLock(privconn);
> -    memset(names, 0, sizeof(*names)*nnames);

Here too

> -    for (i = 0; i < privconn->networks->count && n < nnames; i++) {
> -        virNetworkObjLock(privconn->networks->objs[i]);
> -        if (!virNetworkObjIsActive(privconn->networks->objs[i]) &&
> -            VIR_STRDUP(names[n++], privconn->networks->objs[i]->def->name) < 0) {
> -            virNetworkObjUnlock(privconn->networks->objs[i]);
> -            goto error;
> -        }
> -        virNetworkObjUnlock(privconn->networks->objs[i]);
> -    }
> +    n = virNetworkObjListGetNames(privconn->networks,
> +                                  false, names, nnames, NULL, conn);
>      testDriverUnlock(privconn);
>  
>      return n;
> -
> - error:
> -    for (n = 0; n < nnames; n++)
> -        VIR_FREE(names[n]);
> -    testDriverUnlock(privconn);
> -    return -1;
>  }
>  
>  static int

But I don't think that should be a problem.

ACK

Peter

Attachment: signature.asc
Description: 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]