[PATCH 23/55] hyperv: use g_autoptr for Win32_ComputerSystemProduct in hypervLookupHostSystemBiosUuid

Matt Coleman mcoleman at datto.com
Thu Jan 21 18:51:03 UTC 2021


Signed-off-by: Matt Coleman <matt at datto.com>
---
 src/hyperv/hyperv_driver.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index ef3ae54f7d..3c4ef5f33f 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -237,25 +237,20 @@ hypervParseVersionString(const char *str, unsigned int *major,
 static int
 hypervLookupHostSystemBiosUuid(hypervPrivate *priv, unsigned char *uuid)
 {
-    Win32_ComputerSystemProduct *computerSystem = NULL;
+    g_autoptr(Win32_ComputerSystemProduct) computerSystem = NULL;
     g_auto(virBuffer) query = { g_string_new(WIN32_COMPUTERSYSTEMPRODUCT_WQL_SELECT), 0 };
-    int result = -1;
 
     if (hypervGetWmiClass(Win32_ComputerSystemProduct, &computerSystem) < 0)
-        goto cleanup;
+        return -1;
 
     if (virUUIDParse(computerSystem->data->UUID, uuid) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Could not parse UUID from string '%s'"),
                        computerSystem->data->UUID);
-        goto cleanup;
+        return -1;
     }
-    result = 0;
 
- cleanup:
-    hypervFreeObject((hypervObject *)computerSystem);
-
-    return result;
+    return 0;
 }
 
 
-- 
2.30.0





More information about the libvir-list mailing list