From: Matt Coleman Date: Thu, 21 Jan 2021 18:50:50 +0000 (-0500) Subject: hyperv: use g_autoptr for Msvm_ProcessorSettingData in hypervConnectGetMaxVcpus X-Git-Tag: v7.1.0-rc1~491 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=770186542f229fb7b3138493ffef54da18307ca2;p=thirdparty%2Flibvirt.git hyperv: use g_autoptr for Msvm_ProcessorSettingData in hypervConnectGetMaxVcpus Signed-off-by: Matt Coleman Reviewed-by: Laine Stump --- diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 8b59dd05f7..6375f6b011 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -1514,10 +1514,9 @@ hypervConnectGetCapabilities(virConnectPtr conn) static int hypervConnectGetMaxVcpus(virConnectPtr conn, const char *type G_GNUC_UNUSED) { - int result = -1; hypervPrivate *priv = conn->privateData; g_auto(virBuffer) query = VIR_BUFFER_INITIALIZER; - Msvm_ProcessorSettingData *processorSettingData = NULL; + g_autoptr(Msvm_ProcessorSettingData) processorSettingData = NULL; /* Get max processors definition */ virBufferAddLit(&query, @@ -1525,21 +1524,16 @@ hypervConnectGetMaxVcpus(virConnectPtr conn, const char *type G_GNUC_UNUSED) "WHERE InstanceID LIKE 'Microsoft:Definition%Maximum'"); if (hypervGetWmiClass(Msvm_ProcessorSettingData, &processorSettingData) < 0) - goto cleanup; + return -1; if (!processorSettingData) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not get maximum definition of Msvm_ProcessorSettingData for host %s"), conn->uri->server); - goto cleanup; + return -1; } - result = processorSettingData->data->VirtualQuantity; - - cleanup: - hypervFreeObject((hypervObject *)processorSettingData); - - return result; + return processorSettingData->data->VirtualQuantity; }