libvirt/SOURCES/libvirt-virbuftest-use-g_autofree.patch
2021-09-10 11:58:15 +00:00

149 lines
4.1 KiB
Diff

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