summaryrefslogtreecommitdiff
path: root/tests/virnetdevbandwidthtest.c
diff options
context:
space:
mode:
authorPeter Krempa <pkrempa@redhat.com>2021-04-01 17:54:09 +0200
committerPeter Krempa <pkrempa@redhat.com>2021-04-12 15:55:10 +0200
commit0dffca8f9561b8266b82bbc8c7c7ab4622a9b719 (patch)
tree87e60b442299d8d874b10af498675c308b2da28b /tests/virnetdevbandwidthtest.c
parent070cc66d1655271d0e3ad3ac5a3aad7c546d3f1f (diff)
downloadlibvirt-0dffca8f9561b8266b82bbc8c7c7ab4622a9b719.tar.gz
virCommandSetDryRun: Rework resetting of the dry run data
While virCommandSetDryRun is used in tests only, there were some cases when error paths would not call the function with NULL arguments to reset the dry run infrastructure. Introduce virCommandDryRunToken type which must be allocated via virCommandDryRunTokenNew and passed to virCommandSetDryRun. This way we can use automatic variable cleaning to trigger the cleanup of virCommandSetDryRun parameters and also the use of the token variable ensures that all callers of virCommandSetDryRun clean up after themselves and also that the token isn't left unused in the code. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
Diffstat (limited to 'tests/virnetdevbandwidthtest.c')
-rw-r--r--tests/virnetdevbandwidthtest.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/virnetdevbandwidthtest.c b/tests/virnetdevbandwidthtest.c
index 6f3cab27be..52742dff05 100644
--- a/tests/virnetdevbandwidthtest.c
+++ b/tests/virnetdevbandwidthtest.c
@@ -72,13 +72,14 @@ testVirNetDevBandwidthSet(const void *data)
g_autoptr(virNetDevBandwidth) band = NULL;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
char *actual_cmd = NULL;
+ g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
PARSE(info->band, band);
if (!iface)
iface = "eth0";
- virCommandSetDryRun(&buf, NULL, NULL);
+ virCommandSetDryRun(dryRunToken, &buf, NULL, NULL);
if (virNetDevBandwidthSet(iface, band, info->hierarchical_class, true) < 0)
goto cleanup;
@@ -97,7 +98,6 @@ testVirNetDevBandwidthSet(const void *data)
ret = 0;
cleanup:
- virCommandSetDryRun(NULL, NULL, NULL);
VIR_FREE(actual_cmd);
return ret;
}