Re: [PATCH 07/32] tests: use g_auto for all virBuffers

2020-07-08 Thread Ján Tomko

On a Sunday in 2020, Laine Stump wrote:

Signed-off-by: Laine Stump 
---
tests/commandtest.c  |  3 +--
tests/cputest.c  |  2 +-
tests/networkxml2firewalltest.c  |  3 +--
tests/nodedevmdevctltest.c   |  6 ++
tests/nwfilterebiptablestest.c   | 21 +++--
tests/nwfilterxml2firewalltest.c |  3 +--
tests/qemublocktest.c|  2 +-
tests/qemucommandutiltest.c  |  2 +-
tests/qemumigparamstest.c|  6 ++
tests/qemumonitorjsontest.c  |  9 -
tests/qemumonitortestutils.c |  2 +-
tests/testutils.c|  2 +-
tests/vboxsnapshotxmltest.c  |  3 +--
tests/virbuftest.c   | 23 ++-
tests/vircgrouptest.c|  3 +--
tests/virfirewalltest.c  | 30 ++
tests/virhostcputest.c   |  3 +--
tests/virkmodtest.c  |  4 ++--
tests/virnetdevbandwidthtest.c   |  3 +--
19 files changed, 49 insertions(+), 81 deletions(-)



Reviewed-by: Ján Tomko 

Jano


signature.asc
Description: PGP signature


[PATCH 07/32] tests: use g_auto for all virBuffers

2020-07-05 Thread Laine Stump
Signed-off-by: Laine Stump 
---
 tests/commandtest.c  |  3 +--
 tests/cputest.c  |  2 +-
 tests/networkxml2firewalltest.c  |  3 +--
 tests/nodedevmdevctltest.c   |  6 ++
 tests/nwfilterebiptablestest.c   | 21 +++--
 tests/nwfilterxml2firewalltest.c |  3 +--
 tests/qemublocktest.c|  2 +-
 tests/qemucommandutiltest.c  |  2 +-
 tests/qemumigparamstest.c|  6 ++
 tests/qemumonitorjsontest.c  |  9 -
 tests/qemumonitortestutils.c |  2 +-
 tests/testutils.c|  2 +-
 tests/vboxsnapshotxmltest.c  |  3 +--
 tests/virbuftest.c   | 23 ++-
 tests/vircgrouptest.c|  3 +--
 tests/virfirewalltest.c  | 30 ++
 tests/virhostcputest.c   |  3 +--
 tests/virkmodtest.c  |  4 ++--
 tests/virnetdevbandwidthtest.c   |  3 +--
 19 files changed, 49 insertions(+), 81 deletions(-)

diff --git a/tests/commandtest.c b/tests/commandtest.c
index d5092b7dd0..f0e60ee5fe 100644
--- a/tests/commandtest.c
+++ b/tests/commandtest.c
@@ -390,7 +390,7 @@ static int test9(const void *unused G_GNUC_UNUSED)
 {
 virCommandPtr cmd = virCommandNew(abs_builddir "/commandhelper");
 const char* const args[] = { "arg1", "arg2", NULL };
-virBuffer buf = VIR_BUFFER_INITIALIZER;
+g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 
 virCommandAddArg(cmd, "-version");
 virCommandAddArgPair(cmd, "-log", "bar.log");
@@ -402,7 +402,6 @@ static int test9(const void *unused G_GNUC_UNUSED)
 
 if (virBufferUse()) {
 printf("Buffer not transferred\n");
-virBufferFreeAndReset();
 virCommandFree(cmd);
 return -1;
 }
diff --git a/tests/cputest.c b/tests/cputest.c
index 0cf6870574..83d63bf495 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -237,7 +237,7 @@ cpuTestGuestCPU(const void *arg)
 virCPUDefPtr host = NULL;
 virCPUDefPtr cpu = NULL;
 virCPUCompareResult cmpResult;
-virBuffer buf = VIR_BUFFER_INITIALIZER;
+g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 char *result = NULL;
 
 if (!(host = cpuTestLoadXML(data->arch, data->host)) ||
diff --git a/tests/networkxml2firewalltest.c b/tests/networkxml2firewalltest.c
index 69fadd55c4..29e7d8bc38 100644
--- a/tests/networkxml2firewalltest.c
+++ b/tests/networkxml2firewalltest.c
@@ -62,7 +62,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
  const char *baseargs)
 {
 char *actualargv = NULL;
-virBuffer buf = VIR_BUFFER_INITIALIZER;
+g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 virNetworkDefPtr def = NULL;
 int ret = -1;
 char *actual;
@@ -92,7 +92,6 @@ static int testCompareXMLToArgvFiles(const char *xml,
 ret = 0;
 
  cleanup:
-virBufferFreeAndReset();
 VIR_FREE(actualargv);
 virNetworkDefFree(def);
 return ret;
diff --git a/tests/nodedevmdevctltest.c b/tests/nodedevmdevctltest.c
index f5bcf5227d..9780553a3a 100644
--- a/tests/nodedevmdevctltest.c
+++ b/tests/nodedevmdevctltest.c
@@ -54,7 +54,7 @@ testMdevctlStart(const char *virt_type,
 {
 g_autoptr(virNodeDeviceDef) def = NULL;
 virNodeDeviceObjPtr obj = NULL;
-virBuffer buf = VIR_BUFFER_INITIALIZER;
+g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 const char *actualCmdline = NULL;
 int ret = -1;
 g_autofree char *uuid = NULL;
@@ -87,7 +87,6 @@ testMdevctlStart(const char *virt_type,
 ret = 0;
 
  cleanup:
-virBufferFreeAndReset();
 virCommandSetDryRun(NULL, NULL, NULL);
 virNodeDeviceObjEndAPI();
 return ret;
@@ -114,7 +113,7 @@ static int
 testMdevctlStop(const void *data)
 {
 const char *uuid = data;
-virBuffer buf = VIR_BUFFER_INITIALIZER;
+g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 const char *actualCmdline = NULL;
 int ret = -1;
 g_autoptr(virCommand) cmd = NULL;
@@ -140,7 +139,6 @@ testMdevctlStop(const void *data)
 ret = 0;
 
  cleanup:
-virBufferFreeAndReset();
 virCommandSetDryRun(NULL, NULL, NULL);
 return ret;
 }
diff --git a/tests/nwfilterebiptablestest.c b/tests/nwfilterebiptablestest.c
index 3e6c335d4e..4d8791023c 100644
--- a/tests/nwfilterebiptablestest.c
+++ b/tests/nwfilterebiptablestest.c
@@ -68,7 +68,7 @@
 static int
 testNWFilterEBIPTablesAllTeardown(const void *opaque G_GNUC_UNUSED)
 {
-virBuffer buf = VIR_BUFFER_INITIALIZER;
+g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 const char *expected =
 VIR_NWFILTER_NEW_RULES_TEARDOWN
 "iptables -D libvirt-out -m physdev --physdev-is-bridged --physdev-out 
vnet0 -g FO-vnet0\n"
@@ -120,7 +120,6 @@ testNWFilterEBIPTablesAllTeardown(const void *opaque 
G_GNUC_UNUSED)
 ret = 0;
  cleanup:
 virCommandSetDryRun(NULL, NULL, NULL);
-virBufferFreeAndReset();
 VIR_FREE(actual);
 return ret;
 }
@@ -129,7 +128,7 @@ testNWFilterEBIPTablesAllTeardown(const void *opaque