From: Matt Coleman Date: Thu, 21 Jan 2021 18:51:15 +0000 (-0500) Subject: hyperv: use g_autoptr for Msvm_VirtualSystemSettingData in hypervDomainSetAutostart X-Git-Tag: v7.1.0-rc1~466 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=230140f59c7f016a0f019dee9e9f1f63269a3eba;p=thirdparty%2Flibvirt.git hyperv: use g_autoptr for Msvm_VirtualSystemSettingData in hypervDomainSetAutostart Signed-off-by: Matt Coleman Reviewed-by: Laine Stump --- diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index c63599c09e..15770eeba8 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -2590,47 +2590,41 @@ hypervDomainGetAutostart(virDomainPtr domain, int *autostart) static int hypervDomainSetAutostart(virDomainPtr domain, int autostart) { - int result = -1; char uuid_string[VIR_UUID_STRING_BUFLEN]; hypervPrivate *priv = domain->conn->privateData; - Msvm_VirtualSystemSettingData *vssd = NULL; + g_autoptr(Msvm_VirtualSystemSettingData) vssd = NULL; g_autoptr(hypervInvokeParamsList) params = NULL; g_autoptr(GHashTable) autostartParam = NULL; virUUIDFormat(domain->uuid, uuid_string); if (hypervGetMsvmVirtualSystemSettingDataFromUUID(priv, uuid_string, &vssd) < 0) - goto cleanup; + return -1; params = hypervCreateInvokeParamsList("ModifySystemSettings", MSVM_VIRTUALSYSTEMMANAGEMENTSERVICE_SELECTOR, Msvm_VirtualSystemManagementService_WmiInfo); if (!params) - goto cleanup; + return -1; autostartParam = hypervCreateEmbeddedParam(Msvm_VirtualSystemSettingData_WmiInfo); if (hypervSetEmbeddedProperty(autostartParam, "AutomaticStartupAction", autostart ? "4" : "2") < 0) - goto cleanup; + return -1; if (hypervSetEmbeddedProperty(autostartParam, "InstanceID", vssd->data->InstanceID) < 0) - goto cleanup; + return -1; if (hypervAddEmbeddedParam(params, "SystemSettings", &autostartParam, Msvm_VirtualSystemSettingData_WmiInfo) < 0) - goto cleanup; + return -1; if (hypervInvokeMethod(priv, ¶ms, NULL) < 0) - goto cleanup; - - result = 0; - - cleanup: - hypervFreeObject((hypervObject *)vssd); + return -1; - return result; + return 0; }