To allow later removal of 'virStringListAdd' add an arbitrary upper
limit on the number of args we care about and don't store more than
that until necessary later.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
tests/virfirewalltest.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/tests/virfirewalltest.c b/tests/virfirewalltest.c
index e14a34d7d2..8bd73311fd 100644
--- a/tests/virfirewalltest.c
+++ b/tests/virfirewalltest.c
@@ -102,6 +102,7 @@ VIR_MOCK_WRAP_RET_ARGS(g_dbus_connection_call_sync,
} else if (STREQ(bus_name, VIR_FIREWALL_FIREWALLD_SERVICE) &&
STREQ(method_name, "passthrough")) {
g_autoptr(GVariantIter) iter = NULL;
+ static const size_t maxargs = 5;
g_auto(GStrv) args = NULL;
size_t nargs = 0;
char *type = NULL;
@@ -111,7 +112,7 @@ VIR_MOCK_WRAP_RET_ARGS(g_dbus_connection_call_sync,
g_variant_get(params, "(&sas)", &type, &iter);
- nargs = g_variant_iter_n_children(iter);
+ args = g_new0(char *, maxargs);
if (fwBuf) {
if (STREQ(type, "ipv4"))
@@ -130,7 +131,9 @@ VIR_MOCK_WRAP_RET_ARGS(g_dbus_connection_call_sync,
doError = true;
}
- virStringListAdd(&args, item);
+ if (nargs < maxargs)
+ args[nargs] = g_strdup(item);
+ nargs++;
if (fwBuf) {
virBufferAddLit(fwBuf, " ");
--
2.29.2