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