]> xenbits.xensource.com Git - libvirt.git/commitdiff
hyperv: use g_autoptr for Win32_ComputerSystemProduct in hypervLookupHostSystemBiosUuid
authorMatt Coleman <mcoleman@datto.com>
Thu, 21 Jan 2021 18:51:03 +0000 (13:51 -0500)
committerLaine Stump <laine@redhat.com>
Fri, 22 Jan 2021 19:04:26 +0000 (14:04 -0500)
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Laine Stump <laine@redhat.com>
src/hyperv/hyperv_driver.c

index ef3ae54f7df163334f8f17270024f5911aec0bd8..3c4ef5f33fffe3f39d05fa455eb02bd2fb0c95c8 100644 (file)
@@ -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;
 }