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

[libvirt] [PATCH v1 09/37] Adapt to VIR_ALLOC and virAsprintf in src/hyperv/*



---
 src/hyperv/hyperv_driver.c | 21 ++++++---------------
 src/hyperv/hyperv_util.c   |  4 +---
 src/hyperv/hyperv_wmi.c    |  8 ++------
 3 files changed, 9 insertions(+), 24 deletions(-)

diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index dd8d018..389a151 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -117,10 +117,8 @@ hypervConnectOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags
     }
 
     /* Allocate per-connection private data */
-    if (VIR_ALLOC(priv) < 0) {
-        virReportOOMError();
+    if (VIR_ALLOC(priv) < 0)
         goto cleanup;
-    }
 
     if (hypervParseUri(&priv->parsedUri, conn->uri) < 0) {
         goto cleanup;
@@ -802,10 +800,8 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
 
     /* Flags checked by virDomainDefFormat */
 
-    if (VIR_ALLOC(def) < 0) {
-        virReportOOMError();
+    if (VIR_ALLOC(def) < 0)
         goto cleanup;
-    }
 
     virUUIDFormat(domain->uuid, uuid_string);
 
@@ -1255,9 +1251,8 @@ hypervConnectListAllDomains(virConnectPtr conn,
          !MATCH(VIR_CONNECT_LIST_DOMAINS_NO_AUTOSTART)) ||
         (MATCH(VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT) &&
          !MATCH(VIR_CONNECT_LIST_DOMAINS_NO_SNAPSHOT))) {
-        if (domains &&
-            VIR_ALLOC_N(*domains, 1) < 0)
-            goto no_memory;
+        if (domains && VIR_ALLOC_N(*domains, 1) < 0)
+            goto cleanup;
 
         ret = 0;
         goto cleanup;
@@ -1287,7 +1282,7 @@ hypervConnectListAllDomains(virConnectPtr conn,
 
     if (domains) {
         if (VIR_ALLOC_N(doms, 1) < 0)
-            goto no_memory;
+            goto cleanup;
         ndoms = 1;
     }
 
@@ -1326,7 +1321,7 @@ hypervConnectListAllDomains(virConnectPtr conn,
         }
 
         if (VIR_RESIZE_N(doms, ndoms, count, 2) < 0)
-            goto no_memory;
+            goto cleanup;
 
         domain = NULL;
 
@@ -1354,10 +1349,6 @@ cleanup:
     hypervFreeObject(priv, (hypervObject *)computerSystemList);
 
     return ret;
-
-no_memory:
-    virReportOOMError();
-    goto cleanup;
 }
 #undef MATCH
 
diff --git a/src/hyperv/hyperv_util.c b/src/hyperv/hyperv_util.c
index b7c2a17..53c0530 100644
--- a/src/hyperv/hyperv_util.c
+++ b/src/hyperv/hyperv_util.c
@@ -46,10 +46,8 @@ hypervParseUri(hypervParsedUri **parsedUri, virURIPtr uri)
         return -1;
     }
 
-    if (VIR_ALLOC(*parsedUri) < 0) {
-        virReportOOMError();
+    if (VIR_ALLOC(*parsedUri) < 0)
         return -1;
-    }
 
     for (i = 0; i < uri->paramsCount; i++) {
         virURIParamPtr queryParam = &uri->params[i];
diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c
index 65fc83d..39eed0c 100644
--- a/src/hyperv/hyperv_wmi.c
+++ b/src/hyperv/hyperv_wmi.c
@@ -210,10 +210,8 @@ hypervEnumAndPull(hypervPrivate *priv, virBufferPtr query, const char *root,
             goto cleanup;
         }
 
-        if (VIR_ALLOC(object) < 0) {
-            virReportOOMError();
+        if (VIR_ALLOC(object) < 0)
             goto cleanup;
-        }
 
         object->serializerInfo = serializerInfo;
         object->data = data;
@@ -414,10 +412,8 @@ hypervInvokeMsvmComputerSystemRequestStateChange(virDomainPtr domain,
 
     if (virAsprintf(&selector, "Name=%s&CreationClassName=Msvm_ComputerSystem",
                     uuid_string) < 0 ||
-        virAsprintf(&properties, "RequestedState=%d", requestedState) < 0) {
-        virReportOOMError();
+        virAsprintf(&properties, "RequestedState=%d", requestedState) < 0)
         goto cleanup;
-    }
 
     options = wsmc_options_init();
 
-- 
1.8.1.5


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