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

[libvirt] [PATCH] esx: Replace almost all esxVI_String_DeepCopyValue vith VIR_STRDUP



---
 src/esx/esx_driver.c                |    8 ++++----
 src/esx/esx_network_driver.c        |    6 ++----
 src/esx/esx_storage_backend_iscsi.c |    2 +-
 src/esx/esx_storage_backend_vmfs.c  |    4 ++--
 src/esx/esx_util.c                  |   11 ++++-------
 src/esx/esx_vi.c                    |   24 +++++++++++-------------
 src/esx/esx_vi_types.c              |    4 ++--
 7 files changed, 26 insertions(+), 33 deletions(-)

diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 85640ce..b55ef45 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -183,7 +183,7 @@ esxParseVMXFileName(const char *fileName, void *opaque)
                 ++tmp;
             }
 
-            if (esxVI_String_DeepCopyValue(&strippedFileName, tmp) < 0) {
+            if (VIR_STRDUP(strippedFileName, tmp) < 0) {
                 goto cleanup;
             }
 
@@ -209,7 +209,7 @@ esxParseVMXFileName(const char *fileName, void *opaque)
 
         /* Fallback to direct datastore name match */
         if (result == NULL && STRPREFIX(fileName, "/vmfs/volumes/")) {
-            if (esxVI_String_DeepCopyValue(&copyOfFileName, fileName) < 0) {
+            if (VIR_STRDUP(copyOfFileName, fileName) < 0) {
                 goto cleanup;
             }
 
@@ -248,7 +248,7 @@ esxParseVMXFileName(const char *fileName, void *opaque)
         /* If it's an absolute path outside of a datastore just use it as is */
         if (result == NULL && *fileName == '/') {
             /* FIXME: need to deal with Windows paths here too */
-            if (esxVI_String_DeepCopyValue(&result, fileName) < 0) {
+            if (VIR_STRDUP(result, fileName) < 0) {
                 goto cleanup;
             }
         }
@@ -353,7 +353,7 @@ esxFormatVMXFileName(const char *fileName, void *opaque)
         result = virBufferContentAndReset(&buffer);
     } else if (*fileName == '/') {
         /* FIXME: need to deal with Windows paths here too */
-        if (esxVI_String_DeepCopyValue(&result, fileName) < 0) {
+        if (VIR_STRDUP(result, fileName) < 0) {
             goto cleanup;
         }
     } else {
diff --git a/src/esx/esx_network_driver.c b/src/esx/esx_network_driver.c
index a4842da..9aacffc 100644
--- a/src/esx/esx_network_driver.c
+++ b/src/esx/esx_network_driver.c
@@ -478,10 +478,8 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
         if (esxVI_HostPortGroupSpec_Alloc(&hostPortGroupSpec) < 0 ||
             esxVI_HostNetworkPolicy_Alloc(&hostPortGroupSpec->policy) < 0 ||
             esxVI_Int_Alloc(&hostPortGroupSpec->vlanId) < 0 ||
-            esxVI_String_DeepCopyValue(&hostPortGroupSpec->name,
-                                       def->portGroups[i].name) < 0 ||
-            esxVI_String_DeepCopyValue(&hostPortGroupSpec->vswitchName,
-                                       def->name) < 0) {
+            VIR_STRDUP(hostPortGroupSpec->name, def->portGroups[i].name) < 0 ||
+            VIR_STRDUP(hostPortGroupSpec->vswitchName, def->name) < 0) {
             goto cleanup;
         }
 
diff --git a/src/esx/esx_storage_backend_iscsi.c b/src/esx/esx_storage_backend_iscsi.c
index d91d7b0..6e1095e 100644
--- a/src/esx/esx_storage_backend_iscsi.c
+++ b/src/esx/esx_storage_backend_iscsi.c
@@ -672,7 +672,7 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume,
 
     virUUIDFormat(md5, uuid_string);
 
-    if (esxVI_String_DeepCopyValue(&def.key, uuid_string) < 0) {
+    if (VIR_STRDUP(def.key, uuid_string) < 0) {
         goto cleanup;
     }
 
diff --git a/src/esx/esx_storage_backend_vmfs.c b/src/esx/esx_storage_backend_vmfs.c
index 3b4d73a..2966109 100644
--- a/src/esx/esx_storage_backend_vmfs.c
+++ b/src/esx/esx_storage_backend_vmfs.c
@@ -1031,7 +1031,7 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
             }
         } else {
             /* Fall back to the path as key */
-            if (esxVI_String_DeepCopyValue(&key, datastorePath) < 0) {
+            if (VIR_STRDUP(key, datastorePath) < 0) {
                 goto cleanup;
             }
         }
@@ -1233,7 +1233,7 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
             }
         } else {
             /* Fall back to the path as key */
-            if (esxVI_String_DeepCopyValue(&key, datastorePath) < 0) {
+            if (VIR_STRDUP(key, datastorePath) < 0) {
                 goto cleanup;
             }
         }
diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c
index 001dd99..a4b931d 100644
--- a/src/esx/esx_util.c
+++ b/src/esx/esx_util.c
@@ -237,7 +237,7 @@ esxUtil_ParseDatastorePath(const char *datastorePath, char **datastoreName,
         return -1;
     }
 
-    if (esxVI_String_DeepCopyValue(&copyOfDatastorePath, datastorePath) < 0) {
+    if (VIR_STRDUP(copyOfDatastorePath, datastorePath) < 0) {
         goto cleanup;
     }
 
@@ -251,8 +251,7 @@ esxUtil_ParseDatastorePath(const char *datastorePath, char **datastoreName,
     }
 
     if (datastoreName != NULL &&
-        esxVI_String_DeepCopyValue(datastoreName,
-                                   preliminaryDatastoreName) < 0) {
+        VIR_STRDUP(*datastoreName, preliminaryDatastoreName) < 0) {
         goto cleanup;
     }
 
@@ -266,8 +265,7 @@ esxUtil_ParseDatastorePath(const char *datastorePath, char **datastoreName,
     }
 
     if (directoryAndFileName != NULL &&
-        esxVI_String_DeepCopyValue(directoryAndFileName,
-                                   preliminaryDirectoryAndFileName) < 0) {
+        VIR_STRDUP(*directoryAndFileName, preliminaryDirectoryAndFileName) < 0) {
         goto cleanup;
     }
 
@@ -279,8 +277,7 @@ esxUtil_ParseDatastorePath(const char *datastorePath, char **datastoreName,
             *tmp = '\0';
         }
 
-        if (esxVI_String_DeepCopyValue(directoryName,
-                                       preliminaryDirectoryAndFileName) < 0) {
+        if (VIR_STRDUP(*directoryName, preliminaryDirectoryAndFileName) < 0) {
             goto cleanup;
         }
     }
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index d0df13d..8dc2592 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -801,10 +801,10 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url,
 
     if (esxVI_CURL_Alloc(&ctx->curl) < 0 ||
         esxVI_CURL_Connect(ctx->curl, parsedUri) < 0 ||
-        esxVI_String_DeepCopyValue(&ctx->url, url) < 0 ||
-        esxVI_String_DeepCopyValue(&ctx->ipAddress, ipAddress) < 0 ||
-        esxVI_String_DeepCopyValue(&ctx->username, username) < 0 ||
-        esxVI_String_DeepCopyValue(&ctx->password, password) < 0) {
+        VIR_STRDUP(ctx->url, url) < 0 ||
+        VIR_STRDUP(ctx->ipAddress, ipAddress) < 0 ||
+        VIR_STRDUP(ctx->username, username) < 0 ||
+        VIR_STRDUP(ctx->password, password) < 0) {
         return -1;
     }
 
@@ -1779,9 +1779,9 @@ esxVI_BuildSelectSet(esxVI_SelectionSpec **selectSet,
     }
 
     if (esxVI_TraversalSpec_Alloc(&traversalSpec) < 0 ||
-        esxVI_String_DeepCopyValue(&traversalSpec->name, name) < 0 ||
-        esxVI_String_DeepCopyValue(&traversalSpec->type, type) < 0 ||
-        esxVI_String_DeepCopyValue(&traversalSpec->path, path) < 0) {
+        VIR_STRDUP(traversalSpec->name, name) < 0 ||
+        VIR_STRDUP(traversalSpec->type, type) < 0 ||
+        VIR_STRDUP(traversalSpec->path, path) < 0) {
         goto failure;
     }
 
@@ -1792,8 +1792,7 @@ esxVI_BuildSelectSet(esxVI_SelectionSpec **selectSet,
 
         while (currentSelectSetName != NULL && *currentSelectSetName != '\0') {
             if (esxVI_SelectionSpec_Alloc(&selectionSpec) < 0 ||
-                esxVI_String_DeepCopyValue(&selectionSpec->name,
-                                           currentSelectSetName) < 0 ||
+                VIR_STRDUP(selectionSpec->name, currentSelectSetName) < 0 ||
                 esxVI_SelectionSpec_AppendToList(&traversalSpec->selectSet,
                                                  selectionSpec) < 0) {
                 goto failure;
@@ -3486,7 +3485,7 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ctx,
             goto cleanup;
         }
 
-        if (esxVI_String_DeepCopyValue(&fileName, directoryAndFileName) < 0) {
+        if (VIR_STRDUP(fileName, directoryAndFileName) < 0) {
             goto cleanup;
         }
     } else {
@@ -3506,8 +3505,7 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ctx,
             goto cleanup;
         }
 
-        if (esxVI_String_DeepCopyValue(&fileName,
-                                       directoryAndFileName + length + 1) < 0) {
+        if (VIR_STRDUP(fileName, directoryAndFileName + length + 1) < 0) {
             goto cleanup;
         }
     }
@@ -3803,7 +3801,7 @@ esxVI_LookupStorageVolumeKeyByDatastorePath(esxVI_Context *ctx,
 
     if (*key == NULL) {
         /* Other files don't have a UUID, fall back to the path as key */
-        if (esxVI_String_DeepCopyValue(key, datastorePath) < 0) {
+        if (VIR_STRDUP(*key, datastorePath) < 0) {
             goto cleanup;
         }
     }
diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c
index 4b2b397..1a26556 100644
--- a/src/esx/esx_vi_types.c
+++ b/src/esx/esx_vi_types.c
@@ -963,8 +963,8 @@ esxVI_AnyType_DeepCopy(esxVI_AnyType **dest, esxVI_AnyType *src)
 
     (*dest)->type = src->type;
 
-    if (esxVI_String_DeepCopyValue(&(*dest)->other, src->other) < 0 ||
-        esxVI_String_DeepCopyValue(&(*dest)->value, src->value) < 0) {
+    if (VIR_STRDUP((*dest)->other, src->other) < 0 ||
+        VIR_STRDUP((*dest)->value, src->value) < 0) {
         goto failure;
     }
 
-- 
1.7.9.5


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