diff --git a/src/hyperv/hyperv_device_monitor.c b/src/hyperv/hyperv_device_monitor.c index 23411cd206..c24c384d82 100644 --- a/src/hyperv/hyperv_device_monitor.c +++ b/src/hyperv/hyperv_device_monitor.c @@ -40,9 +40,8 @@ hypervNodeDeviceOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - if (conn->driver->no != VIR_DRV_HYPERV) { + if (conn->driver->no != VIR_DRV_HYPERV) return VIR_DRV_OPEN_DECLINED; - } return VIR_DRV_OPEN_SUCCESS; } diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 5ffcb85d48..ece943ef28 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -49,9 +49,8 @@ VIR_LOG_INIT("hyperv.hyperv_driver"); static void hypervFreePrivate(hypervPrivate **priv) { - if (priv == NULL || *priv == NULL) { + if (priv == NULL || *priv == NULL) return; - } if ((*priv)->client != NULL) { /* FIXME: This leaks memory due to bugs in openwsman <= 2.2.6 */ @@ -78,17 +77,15 @@ hypervConnectOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); /* Decline if the URI is NULL or the scheme is NULL */ - if (conn->uri == NULL || conn->uri->scheme == NULL) { + if (conn->uri == NULL || conn->uri->scheme == NULL) return VIR_DRV_OPEN_DECLINED; - } /* Decline if the scheme is not hyperv */ plus = strchr(conn->uri->scheme, '+'); if (plus == NULL) { - if (STRCASENEQ(conn->uri->scheme, "hyperv")) { + if (STRCASENEQ(conn->uri->scheme, "hyperv")) return VIR_DRV_OPEN_DECLINED; - } } else { if (plus - conn->uri->scheme != 6 || STRCASENEQLEN(conn->uri->scheme, "hyperv", 6)) { @@ -119,9 +116,8 @@ hypervConnectOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags if (VIR_ALLOC(priv) < 0) goto cleanup; - if (hypervParseUri(&priv->parsedUri, conn->uri) < 0) { + if (hypervParseUri(&priv->parsedUri, conn->uri) < 0) goto cleanup; - } /* Set the port dependent on the transport protocol if no port is * specified. This allows us to rely on the port parameter being @@ -182,9 +178,8 @@ hypervConnectOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags virBufferAddLit(&query, "where "); virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_PHYSICAL); - if (hypervGetMsvmComputerSystemList(priv, &query, &computerSystem) < 0) { + if (hypervGetMsvmComputerSystemList(priv, &query, &computerSystem) < 0) goto cleanup; - } if (computerSystem == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -239,9 +234,8 @@ hypervConnectGetHostname(virConnectPtr conn) virBufferAddLit(&query, WIN32_COMPUTERSYSTEM_WQL_SELECT); - if (hypervGetWin32ComputerSystemList(priv, &query, &computerSystem) < 0) { + if (hypervGetWin32ComputerSystemList(priv, &query, &computerSystem) < 0) goto cleanup; - } if (computerSystem == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -276,9 +270,8 @@ hypervNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info) virBufferAddLit(&query, WIN32_COMPUTERSYSTEM_WQL_SELECT); /* Get Win32_ComputerSystem */ - if (hypervGetWin32ComputerSystemList(priv, &query, &computerSystem) < 0) { + if (hypervGetWin32ComputerSystemList(priv, &query, &computerSystem) < 0) goto cleanup; - } if (computerSystem == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -295,9 +288,8 @@ hypervNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info) "ResultClass = Win32_Processor", computerSystem->data->Name); - if (hypervGetWin32ProcessorList(priv, &query, &processorList) < 0) { + if (hypervGetWin32ProcessorList(priv, &query, &processorList) < 0) goto cleanup; - } if (processorList == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -368,9 +360,8 @@ hypervConnectListDomains(virConnectPtr conn, int *ids, int maxids) Msvm_ComputerSystem *computerSystem = NULL; int count = 0; - if (maxids == 0) { + if (maxids == 0) return 0; - } virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_SELECT); virBufferAddLit(&query, "where "); @@ -387,9 +378,8 @@ hypervConnectListDomains(virConnectPtr conn, int *ids, int maxids) computerSystem = computerSystem->next) { ids[count++] = computerSystem->data->ProcessID; - if (count >= maxids) { + if (count >= maxids) break; - } } success = true; @@ -451,9 +441,8 @@ hypervDomainLookupByID(virConnectPtr conn, int id) virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_VIRTUAL); virBufferAsprintf(&query, "and ProcessID = %d", id); - if (hypervGetMsvmComputerSystemList(priv, &query, &computerSystem) < 0) { + if (hypervGetMsvmComputerSystemList(priv, &query, &computerSystem) < 0) goto cleanup; - } if (computerSystem == NULL) { virReportError(VIR_ERR_NO_DOMAIN, _("No domain with ID %d"), id); @@ -486,9 +475,8 @@ hypervDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid) virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_VIRTUAL); virBufferAsprintf(&query, "and Name = \"%s\"", uuid_string); - if (hypervGetMsvmComputerSystemList(priv, &query, &computerSystem) < 0) { + if (hypervGetMsvmComputerSystemList(priv, &query, &computerSystem) < 0) goto cleanup; - } if (computerSystem == NULL) { virReportError(VIR_ERR_NO_DOMAIN, @@ -519,9 +507,8 @@ hypervDomainLookupByName(virConnectPtr conn, const char *name) virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_VIRTUAL); virBufferAsprintf(&query, "and ElementName = \"%s\"", name); - if (hypervGetMsvmComputerSystemList(priv, &query, &computerSystem) < 0) { + if (hypervGetMsvmComputerSystemList(priv, &query, &computerSystem) < 0) goto cleanup; - } if (computerSystem == NULL) { virReportError(VIR_ERR_NO_DOMAIN, @@ -546,9 +533,8 @@ hypervDomainSuspend(virDomainPtr domain) hypervPrivate *priv = domain->conn->privateData; Msvm_ComputerSystem *computerSystem = NULL; - if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) { + if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) goto cleanup; - } if (computerSystem->data->EnabledState != MSVM_COMPUTERSYSTEM_ENABLEDSTATE_ENABLED) { @@ -575,9 +561,8 @@ hypervDomainResume(virDomainPtr domain) hypervPrivate *priv = domain->conn->privateData; Msvm_ComputerSystem *computerSystem = NULL; - if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) { + if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) goto cleanup; - } if (computerSystem->data->EnabledState != MSVM_COMPUTERSYSTEM_ENABLEDSTATE_PAUSED) { @@ -607,9 +592,8 @@ hypervDomainDestroyFlags(virDomainPtr domain, unsigned int flags) virCheckFlags(0, -1); - if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) { + if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) goto cleanup; - } if (!hypervIsMsvmComputerSystemActive(computerSystem, &in_transition) || in_transition) { @@ -665,9 +649,8 @@ hypervDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) virUUIDFormat(domain->uuid, uuid_string); /* Get Msvm_ComputerSystem */ - if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) { + if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) goto cleanup; - } /* Get Msvm_VirtualSystemSettingData */ virBufferAsprintf(&query, @@ -764,15 +747,13 @@ hypervDomainGetState(virDomainPtr domain, int *state, int *reason, virCheckFlags(0, -1); - if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) { + if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) goto cleanup; - } *state = hypervMsvmComputerSystemEnabledStateToDomainState(computerSystem); - if (reason != NULL) { + if (reason != NULL) *reason = 0; - } result = 0; @@ -805,9 +786,8 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags) virUUIDFormat(domain->uuid, uuid_string); /* Get Msvm_ComputerSystem */ - if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) { + if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) goto cleanup; - } /* Get Msvm_VirtualSystemSettingData */ virBufferAsprintf(&query, @@ -932,9 +912,8 @@ hypervConnectListDefinedDomains(virConnectPtr conn, char **const names, int maxn int count = 0; size_t i; - if (maxnames == 0) { + if (maxnames == 0) return 0; - } virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_SELECT); virBufferAddLit(&query, "where "); @@ -954,18 +933,16 @@ hypervConnectListDefinedDomains(virConnectPtr conn, char **const names, int maxn ++count; - if (count >= maxnames) { + if (count >= maxnames) break; - } } success = true; cleanup: if (!success) { - for (i = 0; i < count; ++i) { + for (i = 0; i < count; ++i) VIR_FREE(names[i]); - } count = -1; } @@ -1022,9 +999,8 @@ hypervDomainCreateWithFlags(virDomainPtr domain, unsigned int flags) virCheckFlags(0, -1); - if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) { + if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) goto cleanup; - } if (hypervIsMsvmComputerSystemActive(computerSystem, NULL)) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", @@ -1103,9 +1079,8 @@ hypervDomainIsActive(virDomainPtr domain) hypervPrivate *priv = domain->conn->privateData; Msvm_ComputerSystem *computerSystem = NULL; - if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) { + if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) goto cleanup; - } result = hypervIsMsvmComputerSystemActive(computerSystem, NULL) ? 1 : 0; @@ -1144,9 +1119,8 @@ hypervDomainManagedSave(virDomainPtr domain, unsigned int flags) virCheckFlags(0, -1); - if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) { + if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) goto cleanup; - } if (!hypervIsMsvmComputerSystemActive(computerSystem, &in_transition) || in_transition) { @@ -1175,9 +1149,8 @@ hypervDomainHasManagedSaveImage(virDomainPtr domain, unsigned int flags) virCheckFlags(0, -1); - if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) { + if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) goto cleanup; - } result = computerSystem->data->EnabledState == MSVM_COMPUTERSYSTEM_ENABLEDSTATE_SUSPENDED ? 1 : 0; @@ -1199,9 +1172,8 @@ hypervDomainManagedSaveRemove(virDomainPtr domain, unsigned int flags) virCheckFlags(0, -1); - if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) { + if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) goto cleanup; - } if (computerSystem->data->EnabledState != MSVM_COMPUTERSYSTEM_ENABLEDSTATE_SUSPENDED) { @@ -1338,9 +1310,8 @@ hypervConnectListAllDomains(virConnectPtr conn, cleanup: if (doms) { - for (i = 0; i < count; ++i) { + for (i = 0; i < count; ++i) virDomainFree(doms[i]); - } VIR_FREE(doms); } diff --git a/src/hyperv/hyperv_interface_driver.c b/src/hyperv/hyperv_interface_driver.c index 9b9e4e605e..6529e3705f 100644 --- a/src/hyperv/hyperv_interface_driver.c +++ b/src/hyperv/hyperv_interface_driver.c @@ -40,9 +40,8 @@ hypervInterfaceOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - if (conn->driver->no != VIR_DRV_HYPERV) { + if (conn->driver->no != VIR_DRV_HYPERV) return VIR_DRV_OPEN_DECLINED; - } return VIR_DRV_OPEN_SUCCESS; } diff --git a/src/hyperv/hyperv_network_driver.c b/src/hyperv/hyperv_network_driver.c index ab2daad65b..93f37183c3 100644 --- a/src/hyperv/hyperv_network_driver.c +++ b/src/hyperv/hyperv_network_driver.c @@ -40,9 +40,8 @@ hypervNetworkOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - if (conn->driver->no != VIR_DRV_HYPERV) { + if (conn->driver->no != VIR_DRV_HYPERV) return VIR_DRV_OPEN_DECLINED; - } return VIR_DRV_OPEN_SUCCESS; } diff --git a/src/hyperv/hyperv_nwfilter_driver.c b/src/hyperv/hyperv_nwfilter_driver.c index 6165bf7f89..fc6ae19745 100644 --- a/src/hyperv/hyperv_nwfilter_driver.c +++ b/src/hyperv/hyperv_nwfilter_driver.c @@ -40,9 +40,8 @@ hypervNWFilterOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - if (conn->driver->no != VIR_DRV_HYPERV) { + if (conn->driver->no != VIR_DRV_HYPERV) return VIR_DRV_OPEN_DECLINED; - } return VIR_DRV_OPEN_SUCCESS; } diff --git a/src/hyperv/hyperv_secret_driver.c b/src/hyperv/hyperv_secret_driver.c index 65587f03bc..31cf915128 100644 --- a/src/hyperv/hyperv_secret_driver.c +++ b/src/hyperv/hyperv_secret_driver.c @@ -40,9 +40,8 @@ hypervSecretOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - if (conn->driver->no != VIR_DRV_HYPERV) { + if (conn->driver->no != VIR_DRV_HYPERV) return VIR_DRV_OPEN_DECLINED; - } return VIR_DRV_OPEN_SUCCESS; } diff --git a/src/hyperv/hyperv_storage_driver.c b/src/hyperv/hyperv_storage_driver.c index e3d4170a82..8fa1343d21 100644 --- a/src/hyperv/hyperv_storage_driver.c +++ b/src/hyperv/hyperv_storage_driver.c @@ -40,9 +40,8 @@ hypervStorageOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - if (conn->driver->no != VIR_DRV_HYPERV) { + if (conn->driver->no != VIR_DRV_HYPERV) return VIR_DRV_OPEN_DECLINED; - } return VIR_DRV_OPEN_SUCCESS; } diff --git a/src/hyperv/hyperv_util.c b/src/hyperv/hyperv_util.c index ebf9eacf13..73b32694a1 100644 --- a/src/hyperv/hyperv_util.c +++ b/src/hyperv/hyperv_util.c @@ -78,9 +78,8 @@ hypervParseUri(hypervParsedUri **parsedUri, virURIPtr uri) result = 0; cleanup: - if (result < 0) { + if (result < 0) hypervFreeParsedUri(parsedUri); - } return result; } @@ -90,9 +89,8 @@ hypervParseUri(hypervParsedUri **parsedUri, virURIPtr uri) void hypervFreeParsedUri(hypervParsedUri **parsedUri) { - if (parsedUri == NULL || *parsedUri == NULL) { + if (parsedUri == NULL || *parsedUri == NULL) return; - } VIR_FREE((*parsedUri)->transport); diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c index 3027601c5a..13acd095a4 100644 --- a/src/hyperv/hyperv_wmi.c +++ b/src/hyperv/hyperv_wmi.c @@ -157,9 +157,8 @@ hypervEnumAndPull(hypervPrivate *priv, virBufferPtr query, const char *root, response = wsmc_action_enumerate(priv->client, root, options, filter); - if (hyperyVerifyResponse(priv->client, response, "enumeration") < 0) { + if (hyperyVerifyResponse(priv->client, response, "enumeration") < 0) goto cleanup; - } enumContext = wsmc_get_enum_context(response); @@ -170,9 +169,8 @@ hypervEnumAndPull(hypervPrivate *priv, virBufferPtr query, const char *root, response = wsmc_action_pull(priv->client, resourceUri, options, filter, enumContext); - if (hyperyVerifyResponse(priv->client, response, "pull") < 0) { + if (hyperyVerifyResponse(priv->client, response, "pull") < 0) goto cleanup; - } node = ws_xml_get_soap_body(response); @@ -198,9 +196,8 @@ hypervEnumAndPull(hypervPrivate *priv, virBufferPtr query, const char *root, goto cleanup; } - if (ws_xml_get_child(node, 0, resourceUri, className) == NULL) { + if (ws_xml_get_child(node, 0, resourceUri, className) == NULL) break; - } data = ws_deserialize(serializerContext, node, serializerInfo, className, resourceUri, NULL, 0, 0); @@ -240,13 +237,11 @@ hypervEnumAndPull(hypervPrivate *priv, virBufferPtr query, const char *root, result = 0; cleanup: - if (options != NULL) { + if (options != NULL) wsmc_options_destroy(options); - } - if (filter != NULL) { + if (filter != NULL) filter_destroy(filter); - } if (data != NULL) { #if WS_SERIALIZER_FREE_MEM_WORKS @@ -275,9 +270,8 @@ hypervFreeObject(hypervPrivate *priv ATTRIBUTE_UNUSED, hypervObject *object) WsSerializerContextH serializerContext; #endif - if (object == NULL) { + if (object == NULL) return; - } #if WS_SERIALIZER_FREE_MEM_WORKS serializerContext = wsmc_get_serialization_context(priv->client); @@ -431,9 +425,8 @@ hypervInvokeMsvmComputerSystemRequestStateChange(virDomainPtr domain, response = wsmc_action_invoke(priv->client, MSVM_COMPUTERSYSTEM_RESOURCE_URI, options, "RequestStateChange", NULL); - if (hyperyVerifyResponse(priv->client, response, "invocation") < 0) { + if (hyperyVerifyResponse(priv->client, response, "invocation") < 0) goto cleanup; - } /* Check return value */ returnValue = ws_xml_get_xpath_value(response, (char *)"/s:Envelope/s:Body/p:RequestStateChange_OUTPUT/p:ReturnValue"); @@ -468,9 +461,8 @@ hypervInvokeMsvmComputerSystemRequestStateChange(virDomainPtr domain, virBufferAddLit(&query, MSVM_CONCRETEJOB_WQL_SELECT); virBufferAsprintf(&query, "where InstanceID = \"%s\"", instanceID); - if (hypervGetMsvmConcreteJobList(priv, &query, &concreteJob) < 0) { + if (hypervGetMsvmConcreteJobList(priv, &query, &concreteJob) < 0) goto cleanup; - } if (concreteJob == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -521,9 +513,8 @@ hypervInvokeMsvmComputerSystemRequestStateChange(virDomainPtr domain, result = 0; cleanup: - if (options != NULL) { + if (options != NULL) wsmc_options_destroy(options); - } ws_xml_destroy_doc(response); VIR_FREE(selector); @@ -576,9 +567,8 @@ bool hypervIsMsvmComputerSystemActive(Msvm_ComputerSystem *computerSystem, bool *in_transition) { - if (in_transition != NULL) { + if (in_transition != NULL) *in_transition = false; - } switch (computerSystem->data->EnabledState) { case MSVM_COMPUTERSYSTEM_ENABLEDSTATE_UNKNOWN: @@ -602,9 +592,8 @@ hypervIsMsvmComputerSystemActive(Msvm_ComputerSystem *computerSystem, case MSVM_COMPUTERSYSTEM_ENABLEDSTATE_STOPPING: case MSVM_COMPUTERSYSTEM_ENABLEDSTATE_PAUSING: case MSVM_COMPUTERSYSTEM_ENABLEDSTATE_RESUMING: - if (in_transition != NULL) { + if (in_transition != NULL) *in_transition = true; - } return true; @@ -634,9 +623,8 @@ hypervMsvmComputerSystemToDomain(virConnectPtr conn, *domain = virGetDomain(conn, computerSystem->data->ElementName, uuid); - if (*domain == NULL) { + if (*domain == NULL) return -1; - } if (hypervIsMsvmComputerSystemActive(computerSystem, NULL)) { (*domain)->id = computerSystem->data->ProcessID; @@ -667,9 +655,8 @@ hypervMsvmComputerSystemFromDomain(virDomainPtr domain, virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_VIRTUAL); virBufferAsprintf(&query, "and Name = \"%s\"", uuid_string); - if (hypervGetMsvmComputerSystemList(priv, &query, computerSystem) < 0) { + if (hypervGetMsvmComputerSystemList(priv, &query, computerSystem) < 0) return -1; - } if (*computerSystem == NULL) { virReportError(VIR_ERR_NO_DOMAIN,