render / rpms / libvirt

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