From: Matt Coleman Date: Thu, 21 Jan 2021 18:50:59 +0000 (-0500) Subject: hyperv: use g_autoptr for Msvm_ComputerSystem in hypervDomainDestroyFlags X-Git-Tag: v7.1.0-rc1~482 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=85fbc6c85d2c887f9021c39b319776b0b007d572;p=thirdparty%2Flibvirt.git hyperv: use g_autoptr for Msvm_ComputerSystem in hypervDomainDestroyFlags Signed-off-by: Matt Coleman Reviewed-by: Laine Stump --- diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index fcb764c0f7..7da4c216b1 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -1818,29 +1818,23 @@ hypervDomainReset(virDomainPtr domain, unsigned int flags) static int hypervDomainDestroyFlags(virDomainPtr domain, unsigned int flags) { - int result = -1; - Msvm_ComputerSystem *computerSystem = NULL; + g_autoptr(Msvm_ComputerSystem) computerSystem = NULL; bool in_transition = false; virCheckFlags(0, -1); if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) - goto cleanup; + return -1; if (!hypervIsMsvmComputerSystemActive(computerSystem, &in_transition) || in_transition) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not active or is in state transition")); - goto cleanup; + return -1; } - result = hypervInvokeMsvmComputerSystemRequestStateChange(domain, - MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_DISABLED); - - cleanup: - hypervFreeObject((hypervObject *)computerSystem); - - return result; + return hypervInvokeMsvmComputerSystemRequestStateChange(domain, + MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_DISABLED); }