[PATCH 24/55] hyperv: use g_autoptr for Msvm_ResourceAllocationSettingData in hypervDomainAttachPhysicalDisk

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Matt Coleman <matt@xxxxxxxxx>
---
 src/hyperv/hyperv_driver.c | 26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index 3c4ef5f33f..07e8d376e0 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -533,14 +533,13 @@ hypervDomainAttachPhysicalDisk(virDomainPtr domain,
                                Msvm_ResourceAllocationSettingData *controller,
                                const char *hostname)
 {
-    int result = -1;
     hypervPrivate *priv = domain->conn->privateData;
     g_autofree char *hostResource = NULL;
     g_autofree char *controller__PATH = NULL;
     g_auto(GStrv) matches = NULL;
     ssize_t found = 0;
     g_auto(virBuffer) query = VIR_BUFFER_INITIALIZER;
-    Msvm_ResourceAllocationSettingData *diskdefault = NULL;
+    g_autoptr(Msvm_ResourceAllocationSettingData) diskdefault = NULL;
     g_autofree char *controllerInstanceIdEscaped = NULL;
     g_autoptr(GHashTable) diskResource = NULL;
     g_autofree char *addressString = g_strdup_printf("%u", disk->info.addr.drive.unit);
@@ -584,7 +583,7 @@ hypervDomainAttachPhysicalDisk(virDomainPtr domain,
     if (found < 1) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("Could not get Msvm_DiskDrive default InstanceID"));
-        goto cleanup;
+        return -1;
     }
 
     hostResource = g_strdup_printf("\\\\%s\\Root\\Virtualization\\V2:"
@@ -604,35 +603,30 @@ hypervDomainAttachPhysicalDisk(virDomainPtr domain,
                                        "Msvm_ResourceAllocationSettingData.InstanceID=\"%s\"",
                                        hostname, controllerInstanceIdEscaped);
     if (!controller__PATH)
-        goto cleanup;
+        return -1;
 
     if (hypervSetEmbeddedProperty(diskResource, "Parent", controller__PATH) < 0)
-        goto cleanup;
+        return -1;
 
     if (hypervSetEmbeddedProperty(diskResource, "AddressOnParent", addressString) < 0)
-        goto cleanup;
+        return -1;
 
     if (hypervSetEmbeddedProperty(diskResource, "ResourceType", resourceType) < 0)
-        goto cleanup;
+        return -1;
 
     if (hypervSetEmbeddedProperty(diskResource, "ResourceSubType",
                                   "Microsoft:Hyper-V:Physical Disk Drive") < 0)
-        goto cleanup;
+        return -1;
 
     if (hypervSetEmbeddedProperty(diskResource, "HostResource", hostResource) < 0)
-        goto cleanup;
+        return -1;
 
     if (hypervMsvmVSMSAddResourceSettings(domain, &diskResource,
                                           Msvm_ResourceAllocationSettingData_WmiInfo,
                                           NULL) < 0)
-        goto cleanup;
-
-    result = 0;
-
- cleanup:
-    hypervFreeObject((hypervObject *)diskdefault);
+        return -1;
 
-    return result;
+    return 0;
 }
 
 
-- 
2.30.0





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux