[libvirt] [PATCH v2 17/20] network: Use @maxnames instead of @nnames

John Ferlan posted 20 patches 7 years, 9 months ago
[libvirt] [PATCH v2 17/20] network: Use @maxnames instead of @nnames
Posted by John Ferlan 7 years, 9 months ago
To be consistent with the API definition, use the @maxnames instead
of @nnames when describing/comparing against the maximum names to
be provided for the *ConnectList[Defined]Networks APIs.

Signed-off-by: John Ferlan <jferlan@redhat.com>
---
 src/conf/virnetworkobj.c    | 10 +++++-----
 src/conf/virnetworkobj.h    |  2 +-
 src/network/bridge_driver.c |  8 ++++----
 src/test/test_driver.c      |  8 ++++----
 4 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c
index 43fc2cf..d288dd0 100644
--- a/src/conf/virnetworkobj.c
+++ b/src/conf/virnetworkobj.c
@@ -1438,7 +1438,7 @@ struct virNetworkObjListGetHelperData {
     virConnectPtr conn;
     virNetworkObjListFilter filter;
     char **names;
-    int nnames;
+    int maxnames;
     bool active;
     int got;
     bool error;
@@ -1455,8 +1455,8 @@ virNetworkObjListGetHelper(void *payload,
     if (data->error)
         return 0;
 
-    if (data->nnames >= 0 &&
-        data->got == data->nnames)
+    if (data->maxnames >= 0 &&
+        data->got == data->maxnames)
         return 0;
 
     virObjectLock(obj);
@@ -1485,14 +1485,14 @@ int
 virNetworkObjListGetNames(virNetworkObjListPtr nets,
                           bool active,
                           char **names,
-                          int nnames,
+                          int maxnames,
                           virNetworkObjListFilter filter,
                           virConnectPtr conn)
 {
     int ret = -1;
 
     struct virNetworkObjListGetHelperData data = {
-        conn, filter, names, nnames, active, 0, false};
+        conn, filter, names, maxnames, active, 0, false};
 
     virObjectLock(nets);
     virHashForEach(nets->objs, virNetworkObjListGetHelper, &data);
diff --git a/src/conf/virnetworkobj.h b/src/conf/virnetworkobj.h
index 96f9eff..f7ed387 100644
--- a/src/conf/virnetworkobj.h
+++ b/src/conf/virnetworkobj.h
@@ -235,7 +235,7 @@ int
 virNetworkObjListGetNames(virNetworkObjListPtr nets,
                           bool active,
                           char **names,
-                          int nnames,
+                          int maxnames,
                           virNetworkObjListFilter filter,
                           virConnectPtr conn);
 
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 2433e4f..d2d983d 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -2945,7 +2945,7 @@ networkConnectNumOfNetworks(virConnectPtr conn)
 static int
 networkConnectListNetworks(virConnectPtr conn,
                            char **const names,
-                           int nnames)
+                           int maxnames)
 {
     virNetworkDriverStatePtr driver = networkGetDriver();
     int got = 0;
@@ -2954,7 +2954,7 @@ networkConnectListNetworks(virConnectPtr conn,
         return -1;
 
     got = virNetworkObjListGetNames(driver->networks,
-                                    true, names, nnames,
+                                    true, names, maxnames,
                                     virConnectListNetworksCheckACL,
                                     conn);
 
@@ -2983,7 +2983,7 @@ networkConnectNumOfDefinedNetworks(virConnectPtr conn)
 static int
 networkConnectListDefinedNetworks(virConnectPtr conn,
                                   char **const names,
-                                  int nnames)
+                                  int maxnames)
 {
     virNetworkDriverStatePtr driver = networkGetDriver();
     int got = 0;
@@ -2992,7 +2992,7 @@ networkConnectListDefinedNetworks(virConnectPtr conn,
         return -1;
 
     got = virNetworkObjListGetNames(driver->networks,
-                                    false, names, nnames,
+                                    false, names, maxnames,
                                     virConnectListDefinedNetworksCheckACL,
                                     conn);
     return got;
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index e306f1e..4b8699b 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -3299,13 +3299,13 @@ testConnectNumOfNetworks(virConnectPtr conn)
 static int
 testConnectListNetworks(virConnectPtr conn,
                         char **const names,
-                        int nnames)
+                        int maxnames)
 {
     testDriverPtr privconn = conn->privateData;
     int n;
 
     n = virNetworkObjListGetNames(privconn->networks,
-                                  true, names, nnames, NULL, conn);
+                                  true, names, maxnames, NULL, conn);
     return n;
 }
 
@@ -3325,13 +3325,13 @@ testConnectNumOfDefinedNetworks(virConnectPtr conn)
 static int
 testConnectListDefinedNetworks(virConnectPtr conn,
                                char **const names,
-                               int nnames)
+                               int maxnames)
 {
     testDriverPtr privconn = conn->privateData;
     int n;
 
     n = virNetworkObjListGetNames(privconn->networks,
-                                  false, names, nnames, NULL, conn);
+                                  false, names, maxnames, NULL, conn);
     return n;
 }
 
-- 
2.9.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 17/20] network: Use @maxnames instead of @nnames
Posted by Michal Privoznik 7 years, 9 months ago
On 07/26/2017 05:05 PM, John Ferlan wrote:
> To be consistent with the API definition, use the @maxnames instead
> of @nnames when describing/comparing against the maximum names to
> be provided for the *ConnectList[Defined]Networks APIs.
> 
> Signed-off-by: John Ferlan <jferlan@redhat.com>
> ---
>  src/conf/virnetworkobj.c    | 10 +++++-----
>  src/conf/virnetworkobj.h    |  2 +-
>  src/network/bridge_driver.c |  8 ++++----
>  src/test/test_driver.c      |  8 ++++----
>  4 files changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c
> index 43fc2cf..d288dd0 100644
> --- a/src/conf/virnetworkobj.c
> +++ b/src/conf/virnetworkobj.c
> @@ -1438,7 +1438,7 @@ struct virNetworkObjListGetHelperData {
>      virConnectPtr conn;
>      virNetworkObjListFilter filter;
>      char **names;
> -    int nnames;
> +    int maxnames;
>      bool active;
>      int got;
>      bool error;

Correct. @nnames may suggest there's @nnames items in @names array.
However, there's @got items! Very confusing.

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 17/20] network: Use @maxnames instead of @nnames
Posted by John Ferlan 7 years, 9 months ago

On 08/15/2017 11:32 AM, Michal Privoznik wrote:
> On 07/26/2017 05:05 PM, John Ferlan wrote:
>> To be consistent with the API definition, use the @maxnames instead
>> of @nnames when describing/comparing against the maximum names to
>> be provided for the *ConnectList[Defined]Networks APIs.
>>
>> Signed-off-by: John Ferlan <jferlan@redhat.com>
>> ---
>>  src/conf/virnetworkobj.c    | 10 +++++-----
>>  src/conf/virnetworkobj.h    |  2 +-
>>  src/network/bridge_driver.c |  8 ++++----
>>  src/test/test_driver.c      |  8 ++++----
>>  4 files changed, 14 insertions(+), 14 deletions(-)
>>
>> diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c
>> index 43fc2cf..d288dd0 100644
>> --- a/src/conf/virnetworkobj.c
>> +++ b/src/conf/virnetworkobj.c
>> @@ -1438,7 +1438,7 @@ struct virNetworkObjListGetHelperData {
>>      virConnectPtr conn;
>>      virNetworkObjListFilter filter;
>>      char **names;
>> -    int nnames;
>> +    int maxnames;
>>      bool active;
>>      int got;
>>      bool error;
> 
> Correct. @nnames may suggest there's @nnames items in @names array.
> However, there's @got items! Very confusing.

True, changing @got to @nnames fixes that though...  and of course
moving it closer to char **names;... and yet another reason why all this
has been "confusing" thus far...  Would you like to see that patch or is
there enough trust that I know how to do that safely ;-).

I probably wrote this with future code in mind where all those values
are clearer anyway.

John

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 17/20] network: Use @maxnames instead of @nnames
Posted by Michal Privoznik 7 years, 9 months ago
On 08/15/2017 10:50 PM, John Ferlan wrote:
> 
> 
> On 08/15/2017 11:32 AM, Michal Privoznik wrote:
>> On 07/26/2017 05:05 PM, John Ferlan wrote:
>>> To be consistent with the API definition, use the @maxnames instead
>>> of @nnames when describing/comparing against the maximum names to
>>> be provided for the *ConnectList[Defined]Networks APIs.
>>>
>>> Signed-off-by: John Ferlan <jferlan@redhat.com>
>>> ---
>>>  src/conf/virnetworkobj.c    | 10 +++++-----
>>>  src/conf/virnetworkobj.h    |  2 +-
>>>  src/network/bridge_driver.c |  8 ++++----
>>>  src/test/test_driver.c      |  8 ++++----
>>>  4 files changed, 14 insertions(+), 14 deletions(-)
>>>
>>> diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c
>>> index 43fc2cf..d288dd0 100644
>>> --- a/src/conf/virnetworkobj.c
>>> +++ b/src/conf/virnetworkobj.c
>>> @@ -1438,7 +1438,7 @@ struct virNetworkObjListGetHelperData {
>>>      virConnectPtr conn;
>>>      virNetworkObjListFilter filter;
>>>      char **names;
>>> -    int nnames;
>>> +    int maxnames;
>>>      bool active;
>>>      int got;
>>>      bool error;
>>
>> Correct. @nnames may suggest there's @nnames items in @names array.
>> However, there's @got items! Very confusing.
> 
> True, changing @got to @nnames fixes that though...  and of course
> moving it closer to char **names;... and yet another reason why all this
> has been "confusing" thus far...  Would you like to see that patch or is
> there enough trust that I know how to do that safely ;-).

That is a next step. After you merge this one. Therefore I suggest you
merge this one and send a separate patch that renames @got to nnames.

Michal

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