From: Matt Coleman Date: Thu, 21 Jan 2021 18:51:18 +0000 (-0500) Subject: hyperv: use g_autoptr for Msvm_ComputerSystem in hypervDomainManagedSave X-Git-Tag: v7.1.0-rc1~463 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=92853b90253cd807910a32b5bb594352c957ae3a;p=thirdparty%2Flibvirt.git hyperv: use g_autoptr for Msvm_ComputerSystem in hypervDomainManagedSave Signed-off-by: Matt Coleman Reviewed-by: Laine Stump --- diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index e501a88889..476c24533d 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -2807,28 +2807,22 @@ hypervDomainIsUpdated(virDomainPtr domain G_GNUC_UNUSED) static int hypervDomainManagedSave(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_OFFLINE); - - cleanup: - hypervFreeObject((hypervObject *)computerSystem); - - return result; + return hypervInvokeMsvmComputerSystemRequestStateChange(domain, MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_OFFLINE); }