virfirewalltest: Avoid use of 'virStringListAdd'

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@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Peter Krempa 2021-02-04 22:43:40 +01:00
parent eed50d403c
commit 92ca314695

View File

@ -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, " ");