[PATCH 10/13] virQEMUCapsProcessStringFlags: Don't require 'nvalues'

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

 



All callers pass in NULL-terminated string lists. Remove the 'nvalues'
argument and fix all callers.

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

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 18a682f2a6..576fb6429b 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -1779,16 +1779,17 @@ static void
 virQEMUCapsProcessStringFlags(virQEMUCaps *qemuCaps,
                               size_t nflags,
                               struct virQEMUCapsStringFlags *flags,
-                              size_t nvalues,
-                              char *const*values)
+                              char **values)
 {
-    size_t i, j;
+    size_t i;
+    char **value;
+
     for (i = 0; i < nflags; i++) {
         if (virQEMUCapsGet(qemuCaps, flags[i].flag))
             continue;

-        for (j = 0; j < nvalues; j++) {
-            if (STREQ(values[j], flags[i].value)) {
+        for (value = values; *value; value++) {
+            if (STREQ(*value, flags[i].value)) {
                 virQEMUCapsSet(qemuCaps, flags[i].flag);
                 break;
             }
@@ -2565,15 +2566,14 @@ virQEMUCapsProbeQMPCommands(virQEMUCaps *qemuCaps,
                             qemuMonitor *mon)
 {
     g_auto(GStrv) commands = NULL;
-    int ncommands;

-    if ((ncommands = qemuMonitorGetCommands(mon, &commands)) < 0)
+    if (qemuMonitorGetCommands(mon, &commands) < 0)
         return -1;

     virQEMUCapsProcessStringFlags(qemuCaps,
                                   G_N_ELEMENTS(virQEMUCapsCommands),
                                   virQEMUCapsCommands,
-                                  ncommands, commands);
+                                  commands);

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

-    if ((nvalues = qemuMonitorGetObjectTypes(mon, &values)) < 0)
+    if (qemuMonitorGetObjectTypes(mon, &values) < 0)
         return -1;
     virQEMUCapsProcessStringFlags(qemuCaps,
                                   G_N_ELEMENTS(virQEMUCapsObjectTypes),
                                   virQEMUCapsObjectTypes,
-                                  nvalues, values);
+                                  values);

     return 0;
 }
@@ -2645,19 +2644,18 @@ virQEMUCapsProbeQMPObjectProperties(virQEMUCaps *qemuCaps,
     for (i = 0; i < G_N_ELEMENTS(virQEMUCapsObjectProps); i++) {
         virQEMUCapsObjectTypeProps *props = virQEMUCapsObjectProps + i;
         g_auto(GStrv) values = NULL;
-        int nvalues;

         if (props->capsCondition >= 0 &&
             !virQEMUCapsGet(qemuCaps, props->capsCondition))
             continue;

-        if ((nvalues = qemuMonitorGetObjectProps(mon, props->type, &values)) < 0)
+        if (qemuMonitorGetObjectProps(mon, props->type, &values) < 0)
             return -1;

         virQEMUCapsProcessStringFlags(qemuCaps,
                                       props->nprops,
                                       props->props,
-                                      nvalues, values);
+                                      values);
     }

     return 0;
@@ -2871,7 +2869,6 @@ virQEMUCapsProbeQMPMachineProps(virQEMUCaps *qemuCaps,
         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)) {
@@ -2882,13 +2879,13 @@ virQEMUCapsProbeQMPMachineProps(virQEMUCaps *qemuCaps,
          * followed by the -machine suffix */
         type = g_strdup_printf("%s-machine", canon);

-        if ((nvalues = qemuMonitorGetObjectProps(mon, type, &values)) < 0)
+        if (qemuMonitorGetObjectProps(mon, type, &values) < 0)
             return -1;

         virQEMUCapsProcessStringFlags(qemuCaps,
                                       props.nprops,
                                       props.props,
-                                      nvalues, values);
+                                      values);
     }

     return 0;
@@ -3306,15 +3303,14 @@ virQEMUCapsProbeQMPMigrationCapabilities(virQEMUCaps *qemuCaps,
                                          qemuMonitor *mon)
 {
     g_auto(GStrv) caps = NULL;
-    int ncaps;

-    if ((ncaps = qemuMonitorGetMigrationCapabilities(mon, &caps)) < 0)
+    if (qemuMonitorGetMigrationCapabilities(mon, &caps) < 0)
         return -1;

     virQEMUCapsProcessStringFlags(qemuCaps,
                                   G_N_ELEMENTS(virQEMUCapsMigration),
                                   virQEMUCapsMigration,
-                                  ncaps, caps);
+                                  caps);

     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