[Libvirt-cim] [PATCH] Add virNetworkFree() to _netpool_for_network()

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Thu Apr 17 00:51:49 UTC 2008


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1208393449 25200
# Node ID e5f5f60842199395981f163b127bd587ade960d6
# Parent  7c49e519c188c83b2c53866101eb64900fb41fd2
Add virNetworkFree() to _netpool_for_network().

Also, fix up the spots where an error is returned.  The style here doesn't match the rest of the file.

Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>

diff -r 7c49e519c188 -r e5f5f6084219 src/Virt_DevicePool.c
--- a/src/Virt_DevicePool.c	Wed Apr 16 16:55:52 2008 -0700
+++ b/src/Virt_DevicePool.c	Wed Apr 16 17:50:49 2008 -0700
@@ -652,6 +652,7 @@
                                        const char *refcn,
                                        const CMPIBroker *broker)
 {
+        CMPIStatus s = {CMPI_RC_OK, NULL};
         char *str = NULL;
         char *bridge = NULL;
         uint16_t type = CIM_RES_TYPE_NET;
@@ -661,12 +662,10 @@
         CU_DEBUG("Looking up network `%s'", netname);
         network = virNetworkLookupByName(conn, netname);
         if (network == NULL) {
-                CMPIStatus s;
-
                 cu_statusf(broker, &s,
                            CMPI_RC_ERR_FAILED,
                            "No such NetworkPool: %s", netname);
-                return s;
+                goto out;
         }
 
         inst = get_typed_instance(broker,
@@ -674,26 +673,32 @@
                                   "NetworkPool",
                                   ns);
         if (inst == NULL) {
-                CMPIStatus s;
-
                 CU_DEBUG("Unable to get instance: %s:%s_NetworkPool",
                          ns, refcn);
                 cu_statusf(broker, &s,
                            CMPI_RC_ERR_FAILED,
                            "Error getting pool instance");
-                return s;
+                goto out;
         }
 
-        if (asprintf(&str, "NetworkPool/%s", netname) == -1)
-                return (CMPIStatus){CMPI_RC_ERR_FAILED, NULL};
+        if (asprintf(&str, "NetworkPool/%s", netname) == -1) {
+                cu_statusf(broker, &s,
+                           CMPI_RC_ERR_FAILED,
+                           "");
+                goto out;
+        }
 
         CMSetProperty(inst, "InstanceID",
                       (CMPIValue *)str, CMPI_chars);
         free(str);
 
         bridge = virNetworkGetBridgeName(network);
-        if (asprintf(&str, "Bridge: %s", bridge) == -1)
-                return (CMPIStatus){CMPI_RC_ERR_FAILED, NULL};
+        if (asprintf(&str, "Bridge: %s", bridge) == -1) {
+                cu_statusf(broker, &s,
+                           CMPI_RC_ERR_FAILED,
+                           "");
+                goto out;
+        }
 
         CMSetProperty(inst, "Caption",
                       (CMPIValue *)str, CMPI_chars);
@@ -706,7 +711,10 @@
 
         inst_list_add(list, inst);
 
-        return (CMPIStatus){CMPI_RC_OK, NULL};
+ out:
+        virNetworkFree(network);
+
+        return s;
 }
 
 static CMPIStatus netpool_instance(virConnectPtr conn,




More information about the Libvirt-cim mailing list