Blob Blame History Raw
From 401d5f108c69a01fca8843868e12d102e75e8dd2 Mon Sep 17 00:00:00 2001
Message-Id: <401d5f108c69a01fca8843868e12d102e75e8dd2@dist-git>
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
Date: Fri, 13 Mar 2020 13:08:06 +0100
Subject: [PATCH] virbuftest: use field names when initalizing test info
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Allow adding new fields without changing all the macros.

Otherwise the compiler complains that not all have been initialized:
../../tests/virbuftest.c:419:5: error: missing field 'arg' initializer [-Werror,-Wmissing-field-initializers]
    DO_TEST_ESCAPE("<td></td><td></td>",
    ^
../../tests/virbuftest.c:414:56: note: expanded from macro 'DO_TEST_ESCAPE'
        struct testBufAddStrData info = { data, expect }; \

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
(cherry picked from commit 46afdc21207d3276f0e100b6e54ca41ee5f12e99)

Prerequisite for: https://bugzilla.redhat.com/show_bug.cgi?id=1808499

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Message-Id: <b5da3d53ae4fc1a592b41230f3b838357cc57d30.1584101247.git.mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
 tests/virbuftest.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tests/virbuftest.c b/tests/virbuftest.c
index bb606c1c28..1780b62bf4 100644
--- a/tests/virbuftest.c
+++ b/tests/virbuftest.c
@@ -372,9 +372,9 @@ mymain(void)
     DO_TEST("set indent", testBufSetIndent);
     DO_TEST("autoclean", testBufferAutoclean);
 
-#define DO_TEST_ADD_STR(DATA, EXPECT) \
+#define DO_TEST_ADD_STR(_data, _expect) \
     do { \
-        struct testBufAddStrData info = { DATA, EXPECT }; \
+        struct testBufAddStrData info = { .data = _data, .expect = _expect }; \
         if (virTestRun("Buf: AddStr", testBufAddStr, &info) < 0) \
             ret = -1; \
     } while (0)
@@ -384,9 +384,9 @@ mymain(void)
     DO_TEST_ADD_STR("<a/>\n", "<c>\n  <a/>\n</c>");
     DO_TEST_ADD_STR("<b>\n  <a/>\n</b>\n", "<c>\n  <b>\n    <a/>\n  </b>\n</c>");
 
-#define DO_TEST_ESCAPE(data, expect) \
+#define DO_TEST_ESCAPE(_data, _expect) \
     do { \
-        struct testBufAddStrData info = { data, expect }; \
+        struct testBufAddStrData info = { .data = _data, .expect = _expect }; \
         if (virTestRun("Buf: EscapeStr", testBufEscapeStr, &info) < 0) \
             ret = -1; \
     } while (0)
@@ -400,9 +400,9 @@ mymain(void)
     DO_TEST_ESCAPE("\x01\x01\x02\x03\x05\x08",
                    "<c>\n  <el></el>\n</c>");
 
-#define DO_TEST_ESCAPE_REGEX(data, expect) \
+#define DO_TEST_ESCAPE_REGEX(_data, _expect) \
     do { \
-        struct testBufAddStrData info = { data, expect }; \
+        struct testBufAddStrData info = { .data = _data, .expect = _expect }; \
         if (virTestRun("Buf: EscapeRegex", testBufEscapeRegex, &info) < 0) \
             ret = -1; \
     } while (0)
-- 
2.25.1