The positive branch can just return and the huge negative part does not need to
be indented an extra level. Best viewed with `-w`.
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
src/esx/esx_driver.c | 144 +++++++++++++++++++++----------------------
1 file changed, 72 insertions(+), 72 deletions(-)
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index a17bf58a5124..51c26e29c65e 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -143,100 +143,100 @@ esxParseVMXFileName(const char *fileName, void *opaque)
if (!strchr(fileName, '/') && !strchr(fileName, '\\')) {
/* Plain file name, use same directory as for the .vmx file */
- result = g_strdup_printf("%s/%s",
data->datastorePathWithoutFileName,
- fileName);
- } else {
- if (esxVI_String_AppendValueToList(&propertyNameList,
- "summary.name") < 0 ||
- esxVI_LookupDatastoreList(data->ctx, propertyNameList,
- &datastoreList) < 0) {
- return NULL;
- }
+ return g_strdup_printf("%s/%s", data->datastorePathWithoutFileName,
+ fileName);
+ }
- /* Search for datastore by mount path */
- for (datastore = datastoreList; datastore;
- datastore = datastore->_next) {
- esxVI_DatastoreHostMount_Free(&hostMount);
- datastoreName = NULL;
-
- if (esxVI_LookupDatastoreHostMount(data->ctx, datastore->obj,
- &hostMount,
- esxVI_Occurrence_RequiredItem) < 0 ||
- esxVI_GetStringValue(datastore, "summary.name",
&datastoreName,
- esxVI_Occurrence_RequiredItem) < 0) {
- goto cleanup;
- }
+ if (esxVI_String_AppendValueToList(&propertyNameList,
+ "summary.name") < 0 ||
+ esxVI_LookupDatastoreList(data->ctx, propertyNameList,
+ &datastoreList) < 0) {
+ return NULL;
+ }
- tmp = (char *)STRSKIP(fileName, hostMount->mountInfo->path);
+ /* Search for datastore by mount path */
+ for (datastore = datastoreList; datastore;
+ datastore = datastore->_next) {
+ esxVI_DatastoreHostMount_Free(&hostMount);
+ datastoreName = NULL;
- if (!tmp)
- continue;
+ if (esxVI_LookupDatastoreHostMount(data->ctx, datastore->obj,
+ &hostMount,
+ esxVI_Occurrence_RequiredItem) < 0 ||
+ esxVI_GetStringValue(datastore, "summary.name",
&datastoreName,
+ esxVI_Occurrence_RequiredItem) < 0) {
+ goto cleanup;
+ }
- /* Found a match. Strip leading separators */
- while (*tmp == '/' || *tmp == '\\')
- ++tmp;
+ tmp = (char *)STRSKIP(fileName, hostMount->mountInfo->path);
- strippedFileName = g_strdup(tmp);
+ if (!tmp)
+ continue;
- tmp = strippedFileName;
+ /* Found a match. Strip leading separators */
+ while (*tmp == '/' || *tmp == '\\')
+ ++tmp;
- /* Convert \ to / */
- while (*tmp != '\0') {
- if (*tmp == '\\')
- *tmp = '/';
+ strippedFileName = g_strdup(tmp);
- ++tmp;
- }
+ tmp = strippedFileName;
- result = g_strdup_printf("[%s] %s", datastoreName,
strippedFileName);
+ /* Convert \ to / */
+ while (*tmp != '\0') {
+ if (*tmp == '\\')
+ *tmp = '/';
- break;
+ ++tmp;
}
- /* Fallback to direct datastore name match */
- if (!result && STRPREFIX(fileName, "/vmfs/volumes/")) {
- copyOfFileName = g_strdup(fileName);
-
- /* Expected format: '/vmfs/volumes/<datastore>/<path>'
*/
- if (!(tmp = STRSKIP(copyOfFileName, "/vmfs/volumes/")) ||
- !(datastoreName = strtok_r(tmp, "/", &saveptr)) ||
- !(directoryAndFileName = strtok_r(NULL, "", &saveptr))) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("File name '%s' doesn't have expected
format "
-
"'/vmfs/volumes/<datastore>/<path>'"), fileName);
- goto cleanup;
- }
-
- esxVI_ObjectContent_Free(&datastoreList);
+ result = g_strdup_printf("[%s] %s", datastoreName, strippedFileName);
- if (esxVI_LookupDatastoreByName(data->ctx, datastoreName,
- NULL, &datastoreList,
- esxVI_Occurrence_OptionalItem) < 0) {
- goto cleanup;
- }
+ break;
+ }
- if (!datastoreList) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("File name '%s' refers to non-existing
datastore '%s'"),
- fileName, datastoreName);
- goto cleanup;
- }
+ /* Fallback to direct datastore name match */
+ if (!result && STRPREFIX(fileName, "/vmfs/volumes/")) {
+ copyOfFileName = g_strdup(fileName);
- result = g_strdup_printf("[%s] %s", datastoreName,
- directoryAndFileName);
+ /* Expected format: '/vmfs/volumes/<datastore>/<path>' */
+ if (!(tmp = STRSKIP(copyOfFileName, "/vmfs/volumes/")) ||
+ !(datastoreName = strtok_r(tmp, "/", &saveptr)) ||
+ !(directoryAndFileName = strtok_r(NULL, "", &saveptr))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("File name '%s' doesn't have expected
format "
+
"'/vmfs/volumes/<datastore>/<path>'"), fileName);
+ goto cleanup;
}
- /* 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 */
- result = g_strdup(fileName);
+ esxVI_ObjectContent_Free(&datastoreList);
+
+ if (esxVI_LookupDatastoreByName(data->ctx, datastoreName,
+ NULL, &datastoreList,
+ esxVI_Occurrence_OptionalItem) < 0) {
+ goto cleanup;
}
- if (!result) {
+ if (!datastoreList) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Could not handle file name '%s'"),
fileName);
+ _("File name '%s' refers to non-existing
datastore '%s'"),
+ fileName, datastoreName);
goto cleanup;
}
+
+ result = g_strdup_printf("[%s] %s", datastoreName,
+ directoryAndFileName);
+ }
+
+ /* 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 */
+ result = g_strdup(fileName);
+ }
+
+ if (!result) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Could not handle file name '%s'"),
fileName);
+ goto cleanup;
}
cleanup:
--
2.29.2