提交 07ef8893 编写于 作者: J Ján Tomko

esx: use g_strdup instead of VIR_STRDUP

Replace all occurrences of
  if (VIR_STRDUP(a, b) < 0)
     /* effectively dead code */
with:
  a = g_strdup(b);
Signed-off-by: NJán Tomko <jtomko@redhat.com>
Reviewed-by: NMichal Privoznik <mprivozn@redhat.com>
上级 923ab677
......@@ -177,8 +177,7 @@ esxParseVMXFileName(const char *fileName, void *opaque)
while (*tmp == '/' || *tmp == '\\')
++tmp;
if (VIR_STRDUP(strippedFileName, tmp) < 0)
goto cleanup;
strippedFileName = g_strdup(tmp);
tmp = strippedFileName;
......@@ -199,8 +198,7 @@ esxParseVMXFileName(const char *fileName, void *opaque)
/* Fallback to direct datastore name match */
if (!result && STRPREFIX(fileName, "/vmfs/volumes/")) {
if (VIR_STRDUP(copyOfFileName, fileName) < 0)
goto cleanup;
copyOfFileName = g_strdup(fileName);
/* Expected format: '/vmfs/volumes/<datastore>/<path>' */
if (!(tmp = STRSKIP(copyOfFileName, "/vmfs/volumes/")) ||
......@@ -235,8 +233,7 @@ esxParseVMXFileName(const char *fileName, void *opaque)
/* If it's an absolute path outside of a datastore just use it as is */
if (!result && *fileName == '/') {
/* FIXME: need to deal with Windows paths here too */
if (VIR_STRDUP(result, fileName) < 0)
goto cleanup;
result = g_strdup(fileName);
}
if (!result) {
......@@ -334,8 +331,7 @@ esxFormatVMXFileName(const char *fileName, void *opaque)
result = virBufferContentAndReset(&buffer);
} else if (*fileName == '/') {
/* FIXME: need to deal with Windows paths here too */
if (VIR_STRDUP(result, fileName) < 0)
goto cleanup;
result = g_strdup(fileName);
} else {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not handle file name '%s'"), fileName);
......@@ -632,8 +628,7 @@ esxConnectToHost(esxPrivate *priv,
return -1;
if (conn->uri->user) {
if (VIR_STRDUP(username, conn->uri->user) < 0)
goto cleanup;
username = g_strdup(conn->uri->user);
} else {
if (!(username = virAuthGetUsername(conn, auth, "esx", "root",
conn->uri->server)))
......@@ -683,8 +678,7 @@ esxConnectToHost(esxPrivate *priv,
if (inMaintenanceMode == esxVI_Boolean_True)
VIR_WARN("The server is in maintenance mode");
if (VIR_STRDUP(*vCenterIPAddress, *vCenterIPAddress) < 0)
goto cleanup;
*vCenterIPAddress = g_strdup(*vCenterIPAddress);
result = 0;
......@@ -724,8 +718,7 @@ esxConnectToVCenter(esxPrivate *priv,
return -1;
if (conn->uri->user) {
if (VIR_STRDUP(username, conn->uri->user) < 0)
goto cleanup;
username = g_strdup(conn->uri->user);
} else {
if (!(username = virAuthGetUsername(conn, auth, "esx", "administrator",
hostname)))
......@@ -1169,19 +1162,13 @@ esxConnectGetHostname(virConnectPtr conn)
}
if (!domainName || strlen(domainName) < 1) {
if (VIR_STRDUP(complete, hostName) < 0)
goto cleanup;
complete = g_strdup(hostName);
} else {
if (virAsprintf(&complete, "%s.%s", hostName, domainName) < 0)
goto cleanup;
}
cleanup:
/*
* If we goto cleanup in case of an error then complete is still NULL,
* either VIR_STRDUP returned -1 or virAsprintf failed. When virAsprintf
* fails it guarantees setting complete to NULL
*/
esxVI_String_Free(&propertyNameList);
esxVI_ObjectContent_Free(&hostSystem);
......@@ -2431,8 +2418,7 @@ esxDomainScreenshot(virDomainPtr domain, virStreamPtr stream,
url = virBufferContentAndReset(&buffer);
if (VIR_STRDUP(mimeType, "image/png") < 0)
goto cleanup;
mimeType = g_strdup("image/png");
if (esxStreamOpenDownload(stream, priv, url, 0, 0) < 0) {
VIR_FREE(mimeType);
......@@ -3454,8 +3440,7 @@ esxDomainGetSchedulerType(virDomainPtr domain G_GNUC_UNUSED, int *nparams)
{
char *type;
if (VIR_STRDUP(type, "allocation") < 0)
return NULL;
type = g_strdup("allocation");
if (nparams)
*nparams = 3; /* reservation, limit, shares */
......
......@@ -66,12 +66,10 @@ esxConnectNumOfInterfaces(virConnectPtr conn)
static int
esxConnectListInterfaces(virConnectPtr conn, char **const names, int maxnames)
{
bool success = false;
esxPrivate *priv = conn->privateData;
esxVI_PhysicalNic *physicalNicList = NULL;
esxVI_PhysicalNic *physicalNic = NULL;
int count = 0;
size_t i;
if (maxnames == 0)
return 0;
......@@ -83,22 +81,11 @@ esxConnectListInterfaces(virConnectPtr conn, char **const names, int maxnames)
for (physicalNic = physicalNicList; physicalNic;
physicalNic = physicalNic->_next) {
if (VIR_STRDUP(names[count], physicalNic->device) < 0)
goto cleanup;
names[count] = g_strdup(physicalNic->device);
++count;
}
success = true;
cleanup:
if (! success) {
for (i = 0; i < count; ++i)
VIR_FREE(names[i]);
count = -1;
}
esxVI_PhysicalNic_Free(&physicalNicList);
return count;
......
......@@ -73,12 +73,10 @@ esxConnectNumOfNetworks(virConnectPtr conn)
static int
esxConnectListNetworks(virConnectPtr conn, char **const names, int maxnames)
{
bool success = false;
esxPrivate *priv = conn->privateData;
esxVI_HostVirtualSwitch *hostVirtualSwitchList = NULL;
esxVI_HostVirtualSwitch *hostVirtualSwitch = NULL;
int count = 0;
size_t i;
if (maxnames == 0)
return 0;
......@@ -91,22 +89,11 @@ esxConnectListNetworks(virConnectPtr conn, char **const names, int maxnames)
for (hostVirtualSwitch = hostVirtualSwitchList; hostVirtualSwitch;
hostVirtualSwitch = hostVirtualSwitch->_next) {
if (VIR_STRDUP(names[count], hostVirtualSwitch->name) < 0)
goto cleanup;
names[count] = g_strdup(hostVirtualSwitch->name);
++count;
}
success = true;
cleanup:
if (! success) {
for (i = 0; i < count; ++i)
VIR_FREE(names[i]);
count = -1;
}
esxVI_HostVirtualSwitch_Free(&hostVirtualSwitchList);
return count;
......@@ -447,12 +434,13 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
if (esxVI_HostPortGroupSpec_Alloc(&hostPortGroupSpec) < 0 ||
esxVI_HostNetworkPolicy_Alloc(&hostPortGroupSpec->policy) < 0 ||
esxVI_Int_Alloc(&hostPortGroupSpec->vlanId) < 0 ||
VIR_STRDUP(hostPortGroupSpec->name, def->portGroups[i].name) < 0 ||
VIR_STRDUP(hostPortGroupSpec->vswitchName, def->name) < 0) {
esxVI_Int_Alloc(&hostPortGroupSpec->vlanId) < 0) {
goto cleanup;
}
hostPortGroupSpec->name = g_strdup(def->portGroups[i].name);
hostPortGroupSpec->vswitchName = g_strdup(def->name);
hostPortGroupSpec->vlanId->value = 0;
if (def->portGroups[i].bandwidth) {
......@@ -670,8 +658,7 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags)
if (virCryptoHashBuf(VIR_CRYPTO_HASH_MD5, hostVirtualSwitch->key, def->uuid) < 0)
goto cleanup;
if (VIR_STRDUP(def->name, hostVirtualSwitch->name) < 0)
goto cleanup;
def->name = g_strdup(hostVirtualSwitch->name);
def->forward.type = VIR_NETWORK_FORWARD_NONE;
......@@ -702,9 +689,7 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags)
if (STREQ(physicalNicKey->value, physicalNic->key)) {
def->forward.ifs[def->forward.nifs].type
= VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV;
if (VIR_STRDUP(def->forward.ifs[def->forward.nifs].device.dev,
physicalNic->device) < 0)
goto cleanup;
def->forward.ifs[def->forward.nifs].device.dev = g_strdup(physicalNic->device);
++def->forward.nifs;
......@@ -766,9 +751,7 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags)
for (networkName = networkNameList; networkName;
networkName = networkName->_next) {
if (STREQ(networkName->value, hostPortGroup->spec->name)) {
if (VIR_STRDUP(def->portGroups[def->nPortGroups].name,
networkName->value) < 0)
goto cleanup;
def->portGroups[def->nPortGroups].name = g_strdup(networkName->value);
if (hostPortGroup->spec->policy) {
if (esxShapingPolicyToBandwidth
......
......@@ -127,8 +127,7 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names,
*/
for (target = hostInternetScsiHba->configuredStaticTarget;
target && count < maxnames; target = target->_next) {
if (VIR_STRDUP(names[count], target->iScsiName) < 0)
goto cleanup;
names[count] = g_strdup(target->iScsiName);
++count;
}
......@@ -406,8 +405,7 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names,
hostScsiTopologyLun && count < maxnames;
hostScsiTopologyLun = hostScsiTopologyLun->_next) {
if (STREQ(hostScsiTopologyLun->scsiLun, scsiLun->key)) {
if (VIR_STRDUP(names[count], scsiLun->deviceName) < 0)
goto cleanup;
names[count] = g_strdup(scsiLun->deviceName);
++count;
}
......@@ -705,8 +703,7 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume,
virUUIDFormat(md5, uuid_string);
if (VIR_STRDUP(def.key, uuid_string) < 0)
goto cleanup;
def.key = g_strdup(uuid_string);
/* iSCSI LUN exposes a block device */
def.type = VIR_STORAGE_VOL_BLOCK;
......
......@@ -166,8 +166,7 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names,
goto cleanup;
}
if (VIR_STRDUP(names[count], dynamicProperty->val->string) < 0)
goto cleanup;
names[count] = g_strdup(dynamicProperty->val->string);
++count;
break;
......@@ -605,8 +604,7 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names,
for (fileInfo = searchResults->file; fileInfo;
fileInfo = fileInfo->_next) {
if (length < 1) {
if (VIR_STRDUP(names[count], fileInfo->path) < 0)
goto cleanup;
names[count] = g_strdup(fileInfo->path);
} else if (virAsprintf(&names[count], "%s/%s", directoryAndFileName,
fileInfo->path) < 0) {
goto cleanup;
......@@ -774,8 +772,7 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key)
VIR_FREE(datastorePath);
if (length < 1) {
if (VIR_STRDUP(volumeName, fileInfo->path) < 0)
goto cleanup;
volumeName = g_strdup(fileInfo->path);
} else if (virAsprintf(&volumeName, "%s/%s",
directoryAndFileName,
fileInfo->path) < 0) {
......@@ -1005,8 +1002,7 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
goto cleanup;
} else {
/* Fall back to the path as key */
if (VIR_STRDUP(key, datastorePath) < 0)
goto cleanup;
key = g_strdup(datastorePath);
}
} else {
virReportError(VIR_ERR_INTERNAL_ERROR,
......@@ -1191,8 +1187,7 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
goto cleanup;
} else {
/* Fall back to the path as key */
if (VIR_STRDUP(key, datastorePath) < 0)
goto cleanup;
key = g_strdup(datastorePath);
}
} else {
virReportError(VIR_ERR_INTERNAL_ERROR,
......
......@@ -59,8 +59,7 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr uri)
if (STRCASEEQ(queryParam->name, "transport")) {
VIR_FREE((*parsedUri)->transport);
if (VIR_STRDUP((*parsedUri)->transport, queryParam->value) < 0)
goto cleanup;
(*parsedUri)->transport = g_strdup(queryParam->value);
if (STRNEQ((*parsedUri)->transport, "http") &&
STRNEQ((*parsedUri)->transport, "https")) {
......@@ -73,8 +72,7 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr uri)
} else if (STRCASEEQ(queryParam->name, "vcenter")) {
VIR_FREE((*parsedUri)->vCenter);
if (VIR_STRDUP((*parsedUri)->vCenter, queryParam->value) < 0)
goto cleanup;
(*parsedUri)->vCenter = g_strdup(queryParam->value);
} else if (STRCASEEQ(queryParam->name, "no_verify")) {
if (virStrToLong_i(queryParam->value, NULL, 10, &noVerify) < 0 ||
(noVerify != 0 && noVerify != 1)) {
......@@ -123,8 +121,7 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr uri)
tmp = queryParam->value;
}
if (VIR_STRDUP((*parsedUri)->proxy_hostname, tmp) < 0)
goto cleanup;
(*parsedUri)->proxy_hostname = g_strdup(tmp);
if ((tmp = strchr((*parsedUri)->proxy_hostname, ':'))) {
if (tmp == (*parsedUri)->proxy_hostname) {
......@@ -153,8 +150,7 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr uri)
}
}
if (VIR_STRDUP((*parsedUri)->path, uri->path) < 0)
goto cleanup;
(*parsedUri)->path = g_strdup(uri->path);
if (!(*parsedUri)->transport)
(*parsedUri)->transport = g_strdup("https");
......@@ -226,8 +222,7 @@ esxUtil_ParseDatastorePath(const char *datastorePath, char **datastoreName,
return -1;
}
if (VIR_STRDUP(copyOfDatastorePath, datastorePath) < 0)
goto cleanup;
copyOfDatastorePath = g_strdup(datastorePath);
/* Expected format: '[<datastore>] <path>' where <path> is optional */
if (!(tmp = STRSKIP(copyOfDatastorePath, "[")) || *tmp == ']' ||
......@@ -238,10 +233,8 @@ esxUtil_ParseDatastorePath(const char *datastorePath, char **datastoreName,
goto cleanup;
}
if (datastoreName &&
VIR_STRDUP(*datastoreName, preliminaryDatastoreName) < 0) {
goto cleanup;
}
if (datastoreName)
*datastoreName = g_strdup(preliminaryDatastoreName);
preliminaryDirectoryAndFileName = strtok_r(NULL, "", &saveptr);
......@@ -252,10 +245,8 @@ esxUtil_ParseDatastorePath(const char *datastorePath, char **datastoreName,
strspn(preliminaryDirectoryAndFileName, " ");
}
if (directoryAndFileName &&
VIR_STRDUP(*directoryAndFileName, preliminaryDirectoryAndFileName) < 0) {
goto cleanup;
}
if (directoryAndFileName)
*directoryAndFileName = g_strdup(preliminaryDirectoryAndFileName);
if (directoryName) {
/* Split <path> into <directory>/<file> and remove /<file> */
......@@ -264,8 +255,7 @@ esxUtil_ParseDatastorePath(const char *datastorePath, char **datastoreName,
if (tmp)
*tmp = '\0';
if (VIR_STRDUP(*directoryName, preliminaryDirectoryAndFileName) < 0)
goto cleanup;
*directoryName = g_strdup(preliminaryDirectoryAndFileName);
}
result = 0;
......@@ -447,8 +437,7 @@ esxUtil_EscapeDatastoreItem(const char *string)
char *escaped1;
char *escaped2 = NULL;
if (VIR_STRDUP(replaced, string) < 0)
return NULL;
replaced = g_strdup(string);
esxUtil_ReplaceSpecialWindowsPathChars(replaced);
......
......@@ -1012,14 +1012,15 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url,
}
if (esxVI_CURL_Alloc(&ctx->curl) < 0 ||
esxVI_CURL_Connect(ctx->curl, parsedUri) < 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) {
esxVI_CURL_Connect(ctx->curl, parsedUri) < 0) {
goto cleanup;
}
ctx->url = g_strdup(url);
ctx->ipAddress = g_strdup(ipAddress);
ctx->username = g_strdup(username);
ctx->password = g_strdup(password);
if (VIR_ALLOC(ctx->sessionLock) < 0)
goto cleanup;
......@@ -1142,8 +1143,7 @@ esxVI_Context_LookupManagedObjects(esxVI_Context *ctx)
return -1;
}
if (VIR_STRDUP(ctx->datacenterPath, ctx->datacenter->name) < 0)
return -1;
ctx->datacenterPath = g_strdup(ctx->datacenter->name);
/* Lookup (Cluster)ComputeResource */
if (esxVI_LookupComputeResource(ctx, NULL, ctx->datacenter->hostFolder,
......@@ -1158,8 +1158,7 @@ esxVI_Context_LookupManagedObjects(esxVI_Context *ctx)
return -1;
}
if (VIR_STRDUP(ctx->computeResourcePath, ctx->computeResource->name) < 0)
return -1;
ctx->computeResourcePath = g_strdup(ctx->computeResource->name);
/* Lookup HostSystem */
if (esxVI_LookupHostSystem(ctx, NULL, ctx->computeResource->_reference,
......@@ -1168,8 +1167,7 @@ esxVI_Context_LookupManagedObjects(esxVI_Context *ctx)
return -1;
}
if (VIR_STRDUP(ctx->hostSystemName, ctx->hostSystem->name) < 0)
return -1;
ctx->hostSystemName = g_strdup(ctx->hostSystem->name);
return 0;
}
......@@ -1186,8 +1184,7 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const char *path)
esxVI_ManagedObjectReference *root = NULL;
esxVI_Folder *folder = NULL;
if (VIR_STRDUP(tmp, path) < 0)
goto cleanup;
tmp = g_strdup(path);
/* Lookup Datacenter */
item = strtok_r(tmp, "/", &saveptr);
......@@ -1330,8 +1327,7 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const char *path)
goto cleanup;
}
if (VIR_STRDUP(ctx->hostSystemName, previousItem) < 0)
goto cleanup;
ctx->hostSystemName = g_strdup(previousItem);
if (esxVI_LookupHostSystem(ctx, ctx->hostSystemName,
ctx->computeResource->_reference, NULL,
......@@ -1927,25 +1923,26 @@ esxVI_BuildSelectSet(esxVI_SelectionSpec **selectSet,
return -1;
}
if (esxVI_TraversalSpec_Alloc(&traversalSpec) < 0 ||
VIR_STRDUP(traversalSpec->name, name) < 0 ||
VIR_STRDUP(traversalSpec->type, type) < 0 ||
VIR_STRDUP(traversalSpec->path, path) < 0) {
if (esxVI_TraversalSpec_Alloc(&traversalSpec) < 0)
goto failure;
}
traversalSpec->name = g_strdup(name);
traversalSpec->type = g_strdup(type);
traversalSpec->path = g_strdup(path);
traversalSpec->skip = esxVI_Boolean_False;
if (selectSetNames) {
currentSelectSetName = selectSetNames;
while (currentSelectSetName && *currentSelectSetName != '\0') {
if (esxVI_SelectionSpec_Alloc(&selectionSpec) < 0 ||
VIR_STRDUP(selectionSpec->name, currentSelectSetName) < 0 ||
esxVI_SelectionSpec_AppendToList(&traversalSpec->selectSet,
selectionSpec) < 0) {
if (esxVI_SelectionSpec_Alloc(&selectionSpec) < 0)
goto failure;
selectionSpec->name = g_strdup(currentSelectSetName);
if (esxVI_SelectionSpec_AppendToList(&traversalSpec->selectSet,
selectionSpec) < 0)
goto failure;
}
selectionSpec = NULL;
currentSelectSetName += strlen(currentSelectSetName) + 1;
......@@ -2646,8 +2643,7 @@ esxVI_GetVirtualMachineIdentity(esxVI_ObjectContent *virtualMachine,
goto failure;
}
if (VIR_STRDUP(*name, dynamicProperty->val->string) < 0)
goto failure;
*name = g_strdup(dynamicProperty->val->string);
if (virVMXUnescapeHexPercent(*name) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
......@@ -2754,8 +2750,7 @@ esxVI_GetSnapshotTreeNames(esxVI_VirtualMachineSnapshotTree *snapshotTreeList,
snapshotTree && count < nameslen;
snapshotTree = snapshotTree->_next) {
if (!(leaves && snapshotTree->childSnapshotList)) {
if (VIR_STRDUP(names[count], snapshotTree->name) < 0)
goto failure;
names[count] = g_strdup(snapshotTree->name);
count++;
}
......@@ -3597,8 +3592,7 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ctx,
datastoreName) < 0)
goto cleanup;
if (VIR_STRDUP(fileName, directoryAndFileName) < 0)
goto cleanup;
fileName = g_strdup(directoryAndFileName);
} else {
if (virAsprintf(&datastorePathWithoutFileName, "[%s] %s",
datastoreName, directoryName) < 0)
......@@ -3614,8 +3608,7 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ctx,
goto cleanup;
}
if (VIR_STRDUP(fileName, directoryAndFileName + length + 1) < 0)
goto cleanup;
fileName = g_strdup(directoryAndFileName + length + 1);
}
/* Lookup HostDatastoreBrowser */
......@@ -3910,8 +3903,7 @@ esxVI_LookupStorageVolumeKeyByDatastorePath(esxVI_Context *ctx,
if (!(*key)) {
/* Other files don't have a UUID, fall back to the path as key */
if (VIR_STRDUP(*key, datastorePath) < 0)
goto cleanup;
*key = g_strdup(datastorePath);
}
result = 0;
......@@ -4430,8 +4422,7 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx,
ESX_VI_CHECK_ARG_LIST(errorMessage);
if (VIR_STRDUP(version, "") < 0)
return -1;
version = g_strdup("");
if (esxVI_ObjectSpec_Alloc(&objectSpec) < 0)
goto cleanup;
......@@ -4503,8 +4494,7 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx,
goto cleanup;
VIR_FREE(version);
if (VIR_STRDUP(version, updateSet->version) < 0)
goto cleanup;
version = g_strdup(updateSet->version);
if (!updateSet->filterSet)
continue;
......@@ -4547,11 +4537,9 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx,
goto cleanup;
if (!taskInfo->error) {
if (VIR_STRDUP(*errorMessage, _("Unknown error")) < 0)
goto cleanup;
*errorMessage = g_strdup(_("Unknown error"));
} else if (!taskInfo->error->localizedMessage) {
if (VIR_STRDUP(*errorMessage, taskInfo->error->fault->_actualType) < 0)
goto cleanup;
*errorMessage = g_strdup(taskInfo->error->fault->_actualType);
} else {
if (virAsprintf(errorMessage, "%s - %s",
taskInfo->error->fault->_actualType,
......@@ -5032,9 +5020,8 @@ esxVI_LookupStoragePoolNameByScsiLunKey(esxVI_Context *ctx,
for (hostScsiTopologyLun = hostScsiTopologyTarget->lun;
hostScsiTopologyLun;
hostScsiTopologyLun = hostScsiTopologyLun->_next) {
if (STREQ(hostScsiTopologyLun->scsiLun, key) &&
VIR_STRDUP(*poolName, candidate->iScsiName) < 0)
goto cleanup;
if (STREQ(hostScsiTopologyLun->scsiLun, key))
*poolName = g_strdup(candidate->iScsiName);
}
/* hostScsiTopologyLun iteration done, terminate loop */
......
......@@ -951,10 +951,8 @@ esxVI_AnyType_DeepCopy(esxVI_AnyType **dest, esxVI_AnyType *src)
(*dest)->type = src->type;
if (VIR_STRDUP((*dest)->other, src->other) < 0 ||
VIR_STRDUP((*dest)->value, src->value) < 0) {
goto failure;
}
(*dest)->other = g_strdup(src->other);
(*dest)->value = g_strdup(src->value);
switch ((int)src->type) {
case esxVI_Type_Boolean:
......@@ -1153,8 +1151,7 @@ esxVI_String_AppendValueToList(esxVI_String **stringList, const char *value)
if (esxVI_String_Alloc(&string) < 0)
return -1;
if (VIR_STRDUP(string->value, value) < 0)
goto failure;
string->value = g_strdup(value);
if (esxVI_String_AppendToList(stringList, string) < 0)
goto failure;
......@@ -1275,8 +1272,10 @@ esxVI_String_DeserializeValue(xmlNodePtr node, char **value)
ESX_VI_CHECK_ARG_LIST(value);
*value = (char *)xmlNodeListGetString(node->doc, node->children, 1);
if (!*value)
*value = g_strdup("");
return *value ? 0 : VIR_STRDUP(*value, "");
return 0;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册