mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
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:
parent
eed50d403c
commit
92ca314695
@ -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, " ");
|
||||
|
Loading…
Reference in New Issue
Block a user