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

[libvirt] [PATCH v2 29/37] Adapt to VIR_STRDUP in src/vmx/*



---
 src/vmx/vmx.c | 25 +++++++------------------
 1 file changed, 7 insertions(+), 18 deletions(-)

diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index c6c2f0d..4ccb0cd 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -682,9 +682,7 @@ virVMXGetConfigString(virConfPtr conf, const char *name, char **string,
         return -1;
     }
 
-    *string = strdup(value->str);
-
-    if (*string == NULL) {
+    if (VIR_STRDUP(*string, value->str) < 0) {
         virReportOOMError();
         return -1;
     }
@@ -1526,9 +1524,7 @@ virVMXParseConfig(virVMXContext *ctx,
     def->onCrash = VIR_DOMAIN_LIFECYCLE_DESTROY;
 
     /* def:os */
-    def->os.type = strdup("hvm");
-
-    if (def->os.type == NULL) {
+    if (VIR_STRDUP(def->os.type, "hvm") < 0) {
         virReportOOMError();
         goto cleanup;
     }
@@ -2579,9 +2575,7 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
         if (STRCASEEQ(virtualDev, "vmxnet") && features == 15) {
             VIR_FREE(virtualDev);
 
-            virtualDev = strdup("vmxnet2");
-
-            if (virtualDev == NULL) {
+            if (VIR_STRDUP(virtualDev, "vmxnet2") < 0) {
                 virReportOOMError();
                 goto cleanup;
             }
@@ -2596,12 +2590,9 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
                                   true) < 0)
             goto cleanup;
 
-        if (networkName == NULL) {
-            networkName = strdup("");
-            if (networkName == NULL) {
-                virReportOOMError();
-                goto cleanup;
-            }
+        if (!networkName && VIR_STRDUP(networkName, "") < 0) {
+            virReportOOMError();
+            goto cleanup;
         }
     }
 
@@ -2797,9 +2788,7 @@ virVMXParseSerial(virVMXContext *ctx, virConfPtr conf, int port,
             goto cleanup;
         }
 
-        (*def)->source.data.tcp.host = strdup(parsedUri->server);
-
-        if ((*def)->source.data.tcp.host == NULL) {
+        if (VIR_STRDUP((*def)->source.data.tcp.host, parsedUri->server) < 0) {
             virReportOOMError();
             goto cleanup;
         }
-- 
1.8.1.5


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