Some test rely too much on declaring variables in the middle
of the function. Use the macro to locally suppress the warning
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
tests/domaincapstest.c | 2 ++
tests/virnetsockettest.c | 2 ++
tests/virnettlscontexttest.c | 3 +++
tests/virnettlssessiontest.c | 3 +++
tests/virstoragetest.c | 2 ++
tests/virstringtest.c | 4 ++++
tests/viruritest.c | 2 ++
7 files changed, 18 insertions(+)
diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c
index c3a9f4ef91..1c3acdcd25 100644
--- a/tests/domaincapstest.c
+++ b/tests/domaincapstest.c
@@ -287,6 +287,7 @@ doTestQemuInternal(const char *version,
capsName = g_strdup_printf("caps_%s", version);
emulator = g_strdup_printf("/usr/bin/qemu-system-%s", arch);
+ VIR_WARNINGS_NO_DECLARATION_AFTER_STATEMENT
struct testData data = {
.name = name,
.emulator = emulator,
@@ -297,6 +298,7 @@ doTestQemuInternal(const char *version,
.capsName = capsName,
.capsOpaque = opaque,
};
+ VIR_WARNINGS_RESET
if (virTestRun(name, test_virDomainCapsFormat, &data) < 0)
return -1;
diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c
index 96c582216c..7d2ad36aae 100644
--- a/tests/virnetsockettest.c
+++ b/tests/virnetsockettest.c
@@ -572,6 +572,7 @@ mymain(void)
if (virTestRun("Socket External Command /dev/does-not-exist",
testSocketCommandFail, NULL) < 0)
ret = -1;
+ VIR_WARNINGS_NO_DECLARATION_AFTER_STATEMENT
struct testSSHData sshData1 = {
.nodename = "somehost",
.path = "/tmp/socket",
@@ -675,6 +676,7 @@ mymain(void)
"fi;"
"'''\\''/tmp/fo
o/nc'\\'''' $ARG -U /tmp/socket'\n",
};
+ VIR_WARNINGS_RESET
if (virTestRun("SSH test 7", testSocketSSH, &sshData7) < 0)
ret = -1;
diff --git a/tests/virnettlscontexttest.c b/tests/virnettlscontexttest.c
index 6d970d0ea8..9860e0ec3e 100644
--- a/tests/virnettlscontexttest.c
+++ b/tests/virnettlscontexttest.c
@@ -136,6 +136,7 @@ mymain(void)
}; \
testTLSGenerateCert(&varname, cavarname.crt)
+ VIR_WARNINGS_NO_DECLARATION_AFTER_STATEMENT
# define TLS_ROOT_REQ(varname, \
co, cn, an1, an2, ia1, ia2, bce, bcc, bci, \
kue, kuc, kuv, kpe, kpc, kpo1, kpo2, so, eo) \
@@ -563,6 +564,8 @@ mymain(void)
certchain,
G_N_ELEMENTS(certchain));
+ VIR_WARNINGS_RESET
+
DO_CTX_TEST(true, "cacertchain-ctx.pem", servercertlevel3areq.filename,
false);
DO_CTX_TEST(false, "cacertchain-ctx.pem", clientcertlevel2breq.filename,
false);
diff --git a/tests/virnettlssessiontest.c b/tests/virnettlssessiontest.c
index 6807581d70..ebb90ad5a2 100644
--- a/tests/virnettlssessiontest.c
+++ b/tests/virnettlssessiontest.c
@@ -277,6 +277,7 @@ mymain(void)
ret = -1; \
} while (0)
+ VIR_WARNINGS_NO_DECLARATION_AFTER_STATEMENT
# define TLS_CERT_REQ(varname, cavarname, \
co, cn, an1, an2, ia1, ia2, bce, bcc, bci, \
kue, kuc, kuv, kpe, kpc, kpo1, kpo2, so, eo) \
@@ -460,6 +461,8 @@ mymain(void)
DO_SESS_TEST("cacertchain-sess.pem", servercertlevel3areq.filename,
clientcertlevel2breq.filename,
false, false, "libvirt.org", NULL);
+ VIR_WARNINGS_RESET
+
testTLSDiscardCert(&clientcertreq);
testTLSDiscardCert(&clientcertaltreq);
diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
index 98f47f0e41..179ae5e5e7 100644
--- a/tests/virstoragetest.c
+++ b/tests/virstoragetest.c
@@ -682,6 +682,7 @@ mymain(void)
/* Missing file */
TEST_ONE_CHAIN("bogus", VIR_STORAGE_FILE_RAW, EXP_FAIL);
+ VIR_WARNINGS_NO_DECLARATION_AFTER_STATEMENT
/* Raw image, whether with right format or no specified format */
testFileData raw = {
.path = absraw,
@@ -963,6 +964,7 @@ mymain(void)
};
TEST_CHAIN(absqcow2, VIR_STORAGE_FILE_QCOW2, (&qcow2, &rbd2), EXP_PASS);
+ VIR_WARNINGS_RESET
/* Rewrite wrap and qcow2 back to 3-deep chain, absolute backing */
virCommandFree(cmd);
diff --git a/tests/virstringtest.c b/tests/virstringtest.c
index 8b8d2acced..704686ac10 100644
--- a/tests/virstringtest.c
+++ b/tests/virstringtest.c
@@ -691,6 +691,7 @@ mymain(void)
ret = -1; \
} while (0)
+ VIR_WARNINGS_NO_DECLARATION_AFTER_STATEMENT
const char *tokens1[] = { NULL };
TEST_SPLIT("", " ", 0, tokens1);
@@ -714,6 +715,7 @@ mymain(void)
const char *tokens8[] = { "gluster", "rdma", NULL };
TEST_SPLIT("gluster+rdma", "+", 2, tokens8);
+ VIR_WARNINGS_RESET
if (virTestRun("virStringSortCompare", testStringSortCompare, NULL) <
0)
ret = -1;
@@ -741,6 +743,7 @@ mymain(void)
/* None matching */
TEST_SEARCH("foo", "(bar)", 10, 0, NULL, false);
+ VIR_WARNINGS_NO_DECLARATION_AFTER_STATEMENT
/* Full match */
const char *matches1[] = { "foo" };
TEST_SEARCH("foo", "(foo)", 10, 1, matches1, false);
@@ -752,6 +755,7 @@ mymain(void)
/* Multi matches, limited returns */
const char *matches3[] = { "foo", "bar" };
TEST_SEARCH("1foo2bar3eek", "([a-z]+)", 2, 2, matches3, false);
+ VIR_WARNINGS_RESET
#define TEST_MATCH(s, r, m) \
do { \
diff --git a/tests/viruritest.c b/tests/viruritest.c
index 0edf3e5522..587498bc2b 100644
--- a/tests/viruritest.c
+++ b/tests/viruritest.c
@@ -166,6 +166,7 @@ mymain(void)
*query_out ? "test://example.com/?" query_out : NULL, \
"test", "example.com", 0, "/", query_in,
NULL, NULL, params)
+ VIR_WARNINGS_NO_DECLARATION_AFTER_STATEMENT
virURIParam params[] = {
{ (char*)"name", (char*)"value", false },
{ NULL, NULL, false },
@@ -216,6 +217,7 @@ mymain(void)
{ (char*)"foo", (char*)"one", false },
{ NULL, NULL, false },
};
+ VIR_WARNINGS_RESET
TEST_PARAMS("foo=one&bar=two", "", params1);
TEST_PARAMS("foo=one&foo=two", "", params2);
--
2.26.2