On Thu, Mar 05, 2015 at 12:05:16 +0100, Michal Privoznik wrote:
So far, this is pure code replacement. But once we introduce
reference counting to virNetworkObj this will be more handy as
there'll be only one function to change: virNetworkObjEndAPI().
For this patch this isn't entirely true, as ...
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/parallels/parallels_network.c | 29 ++++++++++++-----------------
1 file changed, 12 insertions(+), 17 deletions(-)
diff --git a/src/parallels/parallels_network.c b/src/parallels/parallels_network.c
index 86038bf..1bcd2d3 100644
--- a/src/parallels/parallels_network.c
+++ b/src/parallels/parallels_network.c
@@ -230,7 +230,6 @@ parallelsLoadNetwork(parallelsConnPtr privconn, virJSONValuePtr
jobj)
goto cleanup;
net->active = 1;
net->autostart = 1;
- virObjectUnlock(net);
... this ...
return net;
cleanup:
@@ -241,7 +240,7 @@ parallelsLoadNetwork(parallelsConnPtr privconn, virJSONValuePtr
jobj)
static virNetworkObjPtr
parallelsAddRoutedNetwork(parallelsConnPtr privconn)
{
- virNetworkObjPtr net;
+ virNetworkObjPtr net = NULL;
virNetworkDefPtr def;
if (VIR_ALLOC(def) < 0)
@@ -265,7 +264,6 @@ parallelsAddRoutedNetwork(parallelsConnPtr privconn)
}
net->active = 1;
net->autostart = 1;
- virObjectUnlock(net);
return net;
@@ -277,7 +275,7 @@ parallelsAddRoutedNetwork(parallelsConnPtr privconn)
static int parallelsLoadNetworks(parallelsConnPtr privconn)
{
virJSONValuePtr jobj, jobj2;
- virNetworkObjPtr net;
+ virNetworkObjPtr net = NULL;
int ret = -1;
int count;
size_t i;
@@ -305,16 +303,19 @@ static int parallelsLoadNetworks(parallelsConnPtr privconn)
net = parallelsLoadNetwork(privconn, jobj2);
if (!net)
goto cleanup;
+ else
+ virNetworkObjEndAPI(&net);
... and this are semantic changes.
}
- if (!parallelsAddRoutedNetwork(privconn))
+ if (!(net = parallelsAddRoutedNetwork(privconn)))
goto cleanup;
ret = 0;
cleanup:
virJSONValueFree(jobj);
+ virNetworkObjEndAPI(&net);
return ret;
}
They make sense though. ACK.
Peter