|
|
a41c76 |
From e3824886db80dba4e524aa737abb3188373076a6 Mon Sep 17 00:00:00 2001
|
|
|
a41c76 |
Message-Id: <e3824886db80dba4e524aa737abb3188373076a6@dist-git>
|
|
|
a41c76 |
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
|
|
|
a41c76 |
Date: Fri, 13 Mar 2020 13:08:03 +0100
|
|
|
a41c76 |
Subject: [PATCH] virbuftest: use g_autofree
|
|
|
a41c76 |
MIME-Version: 1.0
|
|
|
a41c76 |
Content-Type: text/plain; charset=UTF-8
|
|
|
a41c76 |
Content-Transfer-Encoding: 8bit
|
|
|
a41c76 |
|
|
|
a41c76 |
Signed-off-by: Ján Tomko <jtomko@redhat.com>
|
|
|
a41c76 |
Reviewed-by: Erik Skultety <eskultet@redhat.com>
|
|
|
a41c76 |
(cherry picked from commit b0138d55f72ae64c2bf1abb4ab8cc7eea217ca04)
|
|
|
a41c76 |
|
|
|
a41c76 |
Prerequisite for: https://bugzilla.redhat.com/show_bug.cgi?id=1808499
|
|
|
a41c76 |
|
|
|
a41c76 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
a41c76 |
Message-Id: <e2251697da65f2cd0566647d3270117744ff0b21.1584101247.git.mprivozn@redhat.com>
|
|
|
a41c76 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
a41c76 |
---
|
|
|
a41c76 |
tests/virbuftest.c | 21 +++++++--------------
|
|
|
a41c76 |
1 file changed, 7 insertions(+), 14 deletions(-)
|
|
|
a41c76 |
|
|
|
a41c76 |
diff --git a/tests/virbuftest.c b/tests/virbuftest.c
|
|
|
a41c76 |
index f8eadea25a..2b241424ad 100644
|
|
|
a41c76 |
--- a/tests/virbuftest.c
|
|
|
a41c76 |
+++ b/tests/virbuftest.c
|
|
|
a41c76 |
@@ -15,7 +15,7 @@ static int testBufAutoIndent(const void *data G_GNUC_UNUSED)
|
|
|
a41c76 |
virBufferPtr buf = &bufinit;
|
|
|
a41c76 |
const char expected[] =
|
|
|
a41c76 |
" 1\n 2\n 3\n 4\n 5\n 6\n 7\n &\n 8\n 9\n 10\n ' 11'\n";
|
|
|
a41c76 |
- char *result = NULL;
|
|
|
a41c76 |
+ g_autofree char *result = NULL;
|
|
|
a41c76 |
int ret = 0;
|
|
|
a41c76 |
|
|
|
a41c76 |
if (virBufferGetIndent(buf) != 0 ||
|
|
|
a41c76 |
@@ -85,7 +85,6 @@ static int testBufAutoIndent(const void *data G_GNUC_UNUSED)
|
|
|
a41c76 |
virTestDifference(stderr, expected, result);
|
|
|
a41c76 |
ret = -1;
|
|
|
a41c76 |
}
|
|
|
a41c76 |
- VIR_FREE(result);
|
|
|
a41c76 |
return ret;
|
|
|
a41c76 |
}
|
|
|
a41c76 |
|
|
|
a41c76 |
@@ -93,7 +92,7 @@ static int testBufTrim(const void *data G_GNUC_UNUSED)
|
|
|
a41c76 |
{
|
|
|
a41c76 |
virBuffer bufinit = VIR_BUFFER_INITIALIZER;
|
|
|
a41c76 |
virBufferPtr buf = NULL;
|
|
|
a41c76 |
- char *result = NULL;
|
|
|
a41c76 |
+ g_autofree char *result = NULL;
|
|
|
a41c76 |
const char *expected = "a,b";
|
|
|
a41c76 |
int ret = -1;
|
|
|
a41c76 |
|
|
|
a41c76 |
@@ -123,7 +122,6 @@ static int testBufTrim(const void *data G_GNUC_UNUSED)
|
|
|
a41c76 |
|
|
|
a41c76 |
cleanup:
|
|
|
a41c76 |
virBufferFreeAndReset(buf);
|
|
|
a41c76 |
- VIR_FREE(result);
|
|
|
a41c76 |
return ret;
|
|
|
a41c76 |
}
|
|
|
a41c76 |
|
|
|
a41c76 |
@@ -133,7 +131,7 @@ static int testBufAddBuffer(const void *data G_GNUC_UNUSED)
|
|
|
a41c76 |
virBuffer buf2 = VIR_BUFFER_INITIALIZER;
|
|
|
a41c76 |
virBuffer buf3 = VIR_BUFFER_INITIALIZER;
|
|
|
a41c76 |
int ret = -1;
|
|
|
a41c76 |
- char *result = NULL;
|
|
|
a41c76 |
+ g_autofree char *result = NULL;
|
|
|
a41c76 |
const char *expected = \
|
|
|
a41c76 |
" A long time ago, in a galaxy far,\n" \
|
|
|
a41c76 |
" far away...\n" \
|
|
|
a41c76 |
@@ -234,7 +232,6 @@ static int testBufAddBuffer(const void *data G_GNUC_UNUSED)
|
|
|
a41c76 |
cleanup:
|
|
|
a41c76 |
virBufferFreeAndReset(&buf1);
|
|
|
a41c76 |
virBufferFreeAndReset(&buf2);
|
|
|
a41c76 |
- VIR_FREE(result);
|
|
|
a41c76 |
return ret;
|
|
|
a41c76 |
}
|
|
|
a41c76 |
|
|
|
a41c76 |
@@ -248,7 +245,7 @@ testBufAddStr(const void *opaque)
|
|
|
a41c76 |
{
|
|
|
a41c76 |
const struct testBufAddStrData *data = opaque;
|
|
|
a41c76 |
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
|
a41c76 |
- char *actual;
|
|
|
a41c76 |
+ g_autofree char *actual = NULL;
|
|
|
a41c76 |
int ret = -1;
|
|
|
a41c76 |
|
|
|
a41c76 |
virBufferAddLit(&buf, "<c>\n");
|
|
|
a41c76 |
@@ -271,7 +268,6 @@ testBufAddStr(const void *opaque)
|
|
|
a41c76 |
ret = 0;
|
|
|
a41c76 |
|
|
|
a41c76 |
cleanup:
|
|
|
a41c76 |
- VIR_FREE(actual);
|
|
|
a41c76 |
return ret;
|
|
|
a41c76 |
}
|
|
|
a41c76 |
|
|
|
a41c76 |
@@ -281,7 +277,7 @@ testBufEscapeStr(const void *opaque)
|
|
|
a41c76 |
{
|
|
|
a41c76 |
const struct testBufAddStrData *data = opaque;
|
|
|
a41c76 |
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
|
a41c76 |
- char *actual;
|
|
|
a41c76 |
+ g_autofree char *actual = NULL;
|
|
|
a41c76 |
int ret = -1;
|
|
|
a41c76 |
|
|
|
a41c76 |
virBufferAddLit(&buf, "<c>\n");
|
|
|
a41c76 |
@@ -304,7 +300,6 @@ testBufEscapeStr(const void *opaque)
|
|
|
a41c76 |
ret = 0;
|
|
|
a41c76 |
|
|
|
a41c76 |
cleanup:
|
|
|
a41c76 |
- VIR_FREE(actual);
|
|
|
a41c76 |
return ret;
|
|
|
a41c76 |
}
|
|
|
a41c76 |
|
|
|
a41c76 |
@@ -314,7 +309,7 @@ testBufEscapeRegex(const void *opaque)
|
|
|
a41c76 |
{
|
|
|
a41c76 |
const struct testBufAddStrData *data = opaque;
|
|
|
a41c76 |
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
|
a41c76 |
- char *actual;
|
|
|
a41c76 |
+ g_autofree char *actual = NULL;
|
|
|
a41c76 |
int ret = -1;
|
|
|
a41c76 |
|
|
|
a41c76 |
virBufferEscapeRegex(&buf, "%s", data->data);
|
|
|
a41c76 |
@@ -333,7 +328,6 @@ testBufEscapeRegex(const void *opaque)
|
|
|
a41c76 |
ret = 0;
|
|
|
a41c76 |
|
|
|
a41c76 |
cleanup:
|
|
|
a41c76 |
- VIR_FREE(actual);
|
|
|
a41c76 |
return ret;
|
|
|
a41c76 |
}
|
|
|
a41c76 |
|
|
|
a41c76 |
@@ -342,7 +336,7 @@ static int
|
|
|
a41c76 |
testBufSetIndent(const void *opaque G_GNUC_UNUSED)
|
|
|
a41c76 |
{
|
|
|
a41c76 |
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
|
a41c76 |
- char *actual;
|
|
|
a41c76 |
+ g_autofree char *actual = NULL;
|
|
|
a41c76 |
int ret = -1;
|
|
|
a41c76 |
|
|
|
a41c76 |
virBufferSetIndent(&buf, 11);
|
|
|
a41c76 |
@@ -361,7 +355,6 @@ testBufSetIndent(const void *opaque G_GNUC_UNUSED)
|
|
|
a41c76 |
ret = 0;
|
|
|
a41c76 |
|
|
|
a41c76 |
cleanup:
|
|
|
a41c76 |
- VIR_FREE(actual);
|
|
|
a41c76 |
return ret;
|
|
|
a41c76 |
}
|
|
|
a41c76 |
|
|
|
a41c76 |
--
|
|
|
a41c76 |
2.25.1
|
|
|
a41c76 |
|