switching to g_autofree left many cleanup: sections empty.
Signed-off-by: Laine Stump <laine(a)redhat.com>
---
src/esx/esx_driver.c | 22 ++++++---------
src/esx/esx_storage_backend_vmfs.c | 22 +++++----------
src/esx/esx_util.c | 8 ++----
src/esx/esx_vi.c | 45 +++++++++++++-----------------
src/esx/esx_vi_types.c | 8 ++----
5 files changed, 38 insertions(+), 67 deletions(-)
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index fe98f90ea9..e49975de86 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -690,7 +690,6 @@ esxConnectToVCenter(esxPrivate *priv,
const char *hostname,
const char *hostSystemIPAddress)
{
- int result = -1;
g_autofree char *ipAddress = NULL;
g_autofree char *username = NULL;
g_autofree char *password = NULL;
@@ -711,11 +710,11 @@ esxConnectToVCenter(esxPrivate *priv,
} else {
if (!(username = virAuthGetUsername(conn, auth, "esx",
"administrator",
hostname)))
- goto cleanup;
+ return -1;
}
if (!(password = virAuthGetPassword(conn, auth, "esx", username,
hostname)))
- goto cleanup;
+ return -1;
url = g_strdup_printf("%s://%s:%d/sdk", priv->parsedUri->transport,
hostname,
conn->uri->port);
@@ -723,7 +722,7 @@ esxConnectToVCenter(esxPrivate *priv,
if (esxVI_Context_Alloc(&priv->vCenter) < 0 ||
esxVI_Context_Connect(priv->vCenter, url, ipAddress, username,
password, priv->parsedUri) < 0) {
- goto cleanup;
+ return -1;
}
if (priv->vCenter->productLine != esxVI_ProductLine_VPX) {
@@ -732,25 +731,20 @@ esxConnectToVCenter(esxPrivate *priv,
hostname,
esxVI_ProductLineToDisplayName(esxVI_ProductLine_VPX),
esxVI_ProductLineToDisplayName(priv->vCenter->productLine));
- goto cleanup;
+ return -1;
}
if (hostSystemIPAddress) {
- if (esxVI_Context_LookupManagedObjectsByHostSystemIp
- (priv->vCenter, hostSystemIPAddress) < 0) {
- goto cleanup;
- }
+ if (esxVI_Context_LookupManagedObjectsByHostSystemIp(priv->vCenter,
hostSystemIPAddress) < 0)
+ return -1;
} else {
if (esxVI_Context_LookupManagedObjectsByPath(priv->vCenter,
priv->parsedUri->path) < 0)
{
- goto cleanup;
+ return -1;
}
}
- result = 0;
-
- cleanup:
- return result;
+ return 0;
}
diff --git a/src/esx/esx_storage_backend_vmfs.c b/src/esx/esx_storage_backend_vmfs.c
index 95505d6796..cb2be59a33 100644
--- a/src/esx/esx_storage_backend_vmfs.c
+++ b/src/esx/esx_storage_backend_vmfs.c
@@ -667,7 +667,6 @@ static virStorageVolPtr
esxStorageVolLookupByName(virStoragePoolPtr pool,
const char *name)
{
- virStorageVolPtr volume = NULL;
esxPrivate *priv = pool->conn->privateData;
g_autofree char *datastorePath = NULL;
g_autofree char *key = NULL;
@@ -676,14 +675,11 @@ esxStorageVolLookupByName(virStoragePoolPtr pool,
if (esxVI_LookupStorageVolumeKeyByDatastorePath(priv->primary,
datastorePath, &key) < 0) {
- goto cleanup;
+ return NULL;
}
- volume = virGetStorageVol(pool->conn, pool->name, name, key,
- &esxStorageBackendVMFS, NULL);
-
- cleanup:
- return volume;
+ return virGetStorageVol(pool->conn, pool->name, name, key,
+ &esxStorageBackendVMFS, NULL);
}
@@ -691,7 +687,6 @@ esxStorageVolLookupByName(virStoragePoolPtr pool,
static virStorageVolPtr
esxStorageVolLookupByPath(virConnectPtr conn, const char *path)
{
- virStorageVolPtr volume = NULL;
esxPrivate *priv = conn->privateData;
g_autofree char *datastoreName = NULL;
g_autofree char *directoryAndFileName = NULL;
@@ -699,19 +694,16 @@ esxStorageVolLookupByPath(virConnectPtr conn, const char *path)
if (esxUtil_ParseDatastorePath(path, &datastoreName, NULL,
&directoryAndFileName) < 0) {
- goto cleanup;
+ return NULL;
}
if (esxVI_LookupStorageVolumeKeyByDatastorePath(priv->primary, path,
&key) < 0) {
- goto cleanup;
+ return NULL;
}
- volume = virGetStorageVol(conn, datastoreName, directoryAndFileName, key,
- &esxStorageBackendVMFS, NULL);
-
- cleanup:
- return volume;
+ return virGetStorageVol(conn, datastoreName, directoryAndFileName, key,
+ &esxStorageBackendVMFS, NULL);
}
diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c
index f1e8339fe0..ef070a4f04 100644
--- a/src/esx/esx_util.c
+++ b/src/esx/esx_util.c
@@ -429,7 +429,6 @@ esxUtil_EscapeDatastoreItem(const char *string)
{
g_autofree char *replaced = NULL;
g_autofree char *escaped1 = NULL;
- char *escaped2 = NULL;
replaced = g_strdup(string);
@@ -438,12 +437,9 @@ esxUtil_EscapeDatastoreItem(const char *string)
escaped1 = virVMXEscapeHexPercent(replaced);
if (!escaped1)
- goto cleanup;
-
- escaped2 = esxUtil_EscapeBase64(escaped1);
+ return NULL;
- cleanup:
- return escaped2;
+ return esxUtil_EscapeBase64(escaped1);
}
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 2a999f1cc1..db5035c035 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -830,7 +830,6 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url,
const char *ipAddress, const char *username,
const char *password, esxUtil_ParsedUri *parsedUri)
{
- int result = -1;
g_autofree char *escapedPassword = NULL;
if (!ctx || !url || !ipAddress || !username ||
@@ -844,12 +843,12 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url,
if (!escapedPassword) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to escape password for XML"));
- goto cleanup;
+ return -1;
}
if (esxVI_CURL_Alloc(&ctx->curl) < 0 ||
esxVI_CURL_Connect(ctx->curl, parsedUri) < 0) {
- goto cleanup;
+ return -1;
}
ctx->url = g_strdup(url);
@@ -863,18 +862,18 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url,
if (virMutexInit(ctx->sessionLock) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Could not initialize session mutex"));
- goto cleanup;
+ return -1;
}
if (esxVI_RetrieveServiceContent(ctx, &ctx->service) < 0)
- goto cleanup;
+ return -1;
if (STRNEQ(ctx->service->about->apiType, "HostAgent") &&
STRNEQ(ctx->service->about->apiType, "VirtualCenter")) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Expecting VI API type 'HostAgent' or
'VirtualCenter' "
"but found '%s'"),
ctx->service->about->apiType);
- goto cleanup;
+ return -1;
}
if (virParseVersionString(ctx->service->about->apiVersion,
@@ -882,14 +881,14 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not parse VI API version '%s'"),
ctx->service->about->apiVersion);
- goto cleanup;
+ return -1;
}
if (ctx->apiVersion < 1000000 * 2 + 1000 * 5 /* 2.5 */) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Minimum supported %s version is %s but found version
'%s'"),
"VI API", "2.5",
ctx->service->about->apiVersion);
- goto cleanup;
+ return -1;
}
if (virParseVersionString(ctx->service->about->version,
@@ -897,7 +896,7 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not parse product version '%s'"),
ctx->service->about->version);
- goto cleanup;
+ return -1;
}
if (STREQ(ctx->service->about->productLineId, "gsx")) {
@@ -906,7 +905,7 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url,
_("Minimum supported %s version is %s but found version
'%s'"),
esxVI_ProductLineToDisplayName(esxVI_ProductLine_GSX),
"2.0", ctx->service->about->version);
- goto cleanup;
+ return -1;
}
ctx->productLine = esxVI_ProductLine_GSX;
@@ -917,7 +916,7 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url,
_("Minimum supported %s version is %s but found version
'%s'"),
esxVI_ProductLineToDisplayName(esxVI_ProductLine_ESX),
"3.5", ctx->service->about->version);
- goto cleanup;
+ return -1;
}
ctx->productLine = esxVI_ProductLine_ESX;
@@ -927,7 +926,7 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url,
_("Minimum supported %s version is %s but found version
'%s'"),
esxVI_ProductLineToDisplayName(esxVI_ProductLine_VPX),
"2.5", ctx->service->about->version);
- goto cleanup;
+ return -1;
}
ctx->productLine = esxVI_ProductLine_VPX;
@@ -936,7 +935,7 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url,
_("Expecting product 'gsx' or 'esx' or
'embeddedEsx' "
"or 'vpx' but found '%s'"),
ctx->service->about->productLineId);
- goto cleanup;
+ return -1;
}
if (ctx->productLine == esxVI_ProductLine_ESX) {
@@ -957,13 +956,10 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url,
if (esxVI_Login(ctx, username, escapedPassword, NULL, &ctx->session) < 0
||
esxVI_BuildSelectSetCollection(ctx) < 0) {
- goto cleanup;
+ return -1;
}
- result = 0;
-
- cleanup:
- return result;
+ return 0;
}
int
@@ -4093,7 +4089,6 @@ esxVI_HandleVirtualMachineQuestion
esxVI_VirtualMachineQuestionInfo *questionInfo, bool autoAnswer,
bool *blocked)
{
- int result = -1;
esxVI_ElementDescription *elementDescription = NULL;
g_auto(virBuffer) buffer = VIR_BUFFER_INITIALIZER;
esxVI_ElementDescription *answerChoice = NULL;
@@ -4136,7 +4131,7 @@ esxVI_HandleVirtualMachineQuestion
questionInfo->text);
*blocked = true;
- goto cleanup;
+ return -1;
} else if (!answerChoice) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Pending question blocks virtual machine execution,
"
@@ -4145,7 +4140,7 @@ esxVI_HandleVirtualMachineQuestion
possibleAnswers);
*blocked = true;
- goto cleanup;
+ return -1;
}
VIR_INFO("Pending question blocks virtual machine execution, "
@@ -4155,7 +4150,7 @@ esxVI_HandleVirtualMachineQuestion
if (esxVI_AnswerVM(ctx, virtualMachine, questionInfo->id,
answerChoice->key) < 0) {
- goto cleanup;
+ return -1;
}
} else {
if (possibleAnswers) {
@@ -4171,13 +4166,11 @@ esxVI_HandleVirtualMachineQuestion
}
*blocked = true;
- goto cleanup;
+ return -1;
}
- result = 0;
+ return 0;
- cleanup:
- return result;
}
diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c
index 1af075813e..4dc7c30680 100644
--- a/src/esx/esx_vi_types.c
+++ b/src/esx/esx_vi_types.c
@@ -700,7 +700,6 @@ static int
esxVI_GetActualObjectType(xmlNodePtr node, esxVI_Type baseType,
esxVI_Type *actualType)
{
- int result = -1;
g_autofree char *type = NULL;
if (!actualType || *actualType != esxVI_Type_Undefined) {
@@ -724,13 +723,10 @@ esxVI_GetActualObjectType(xmlNodePtr node, esxVI_Type baseType,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unknown value '%s' for %s 'type'
property"),
type, esxVI_Type_ToString(baseType));
- goto cleanup;
+ return -1;
}
- result = 0;
-
- cleanup:
- return result;
+ return 0;
}
--
2.29.2