[PATCH 09/13] qemu: capabilities: Use g_auto(GStrv) instead of virStringListFreeCount

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

 



All the capability getters which return a string list do in fact return
a NULL-terminated list so we can use g_auto(GStrv) to free it.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_capabilities.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 436fe40f65..18a682f2a6 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2564,7 +2564,7 @@ static int
 virQEMUCapsProbeQMPCommands(virQEMUCaps *qemuCaps,
                             qemuMonitor *mon)
 {
-    char **commands = NULL;
+    g_auto(GStrv) commands = NULL;
     int ncommands;

     if ((ncommands = qemuMonitorGetCommands(mon, &commands)) < 0)
@@ -2574,7 +2574,6 @@ virQEMUCapsProbeQMPCommands(virQEMUCaps *qemuCaps,
                                   G_N_ELEMENTS(virQEMUCapsCommands),
                                   virQEMUCapsCommands,
                                   ncommands, commands);
-    virStringListFreeCount(commands, ncommands);

     return 0;
 }
@@ -2584,8 +2583,8 @@ static int
 virQEMUCapsProbeQMPObjectTypes(virQEMUCaps *qemuCaps,
                                qemuMonitor *mon)
 {
+    g_auto(GStrv) values = NULL;
     int nvalues;
-    char **values;

     if ((nvalues = qemuMonitorGetObjectTypes(mon, &values)) < 0)
         return -1;
@@ -2593,7 +2592,6 @@ virQEMUCapsProbeQMPObjectTypes(virQEMUCaps *qemuCaps,
                                   G_N_ELEMENTS(virQEMUCapsObjectTypes),
                                   virQEMUCapsObjectTypes,
                                   nvalues, values);
-    virStringListFreeCount(values, nvalues);

     return 0;
 }
@@ -2863,8 +2861,6 @@ virQEMUCapsProbeQMPMachineProps(virQEMUCaps *qemuCaps,
                                 virDomainVirtType virtType,
                                 qemuMonitor *mon)
 {
-    char **values;
-    int nvalues;
     size_t i;

     if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QOM_LIST_PROPERTIES))
@@ -2874,6 +2870,8 @@ virQEMUCapsProbeQMPMachineProps(virQEMUCaps *qemuCaps,
         virQEMUCapsObjectTypeProps props = virQEMUCapsMachineProps[i];
         const char *canon = virQEMUCapsGetCanonicalMachine(qemuCaps, virtType, props.type);
         g_autofree char *type = NULL;
+        g_auto(GStrv) values = NULL;
+        int nvalues;

         if (STRNEQ(canon, "none") &&
             !virQEMUCapsIsMachineSupported(qemuCaps, virtType, canon)) {
@@ -2891,8 +2889,6 @@ virQEMUCapsProbeQMPMachineProps(virQEMUCaps *qemuCaps,
                                       props.nprops,
                                       props.props,
                                       nvalues, values);
-
-        virStringListFreeCount(values, nvalues);
     }

     return 0;
@@ -3309,7 +3305,7 @@ static int
 virQEMUCapsProbeQMPMigrationCapabilities(virQEMUCaps *qemuCaps,
                                          qemuMonitor *mon)
 {
-    char **caps = NULL;
+    g_auto(GStrv) caps = NULL;
     int ncaps;

     if ((ncaps = qemuMonitorGetMigrationCapabilities(mon, &caps)) < 0)
@@ -3319,7 +3315,6 @@ virQEMUCapsProbeQMPMigrationCapabilities(virQEMUCaps *qemuCaps,
                                   G_N_ELEMENTS(virQEMUCapsMigration),
                                   virQEMUCapsMigration,
                                   ncaps, caps);
-    virStringListFreeCount(caps, ncaps);

     return 0;
 }
-- 
2.31.1




[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