aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2020-10-03 17:53:39 +0000
committerWerner Koch <[email protected]>2020-10-03 17:54:00 +0000
commit25e2d717f44682f83c483ceba6ba81bad7fc3e97 (patch)
treec694a4847ba31fc49d9f81f1ffa4684f39d36245 /tests
parentgpgsm: Fix leaked fd. (diff)
downloadgpgme-25e2d717f44682f83c483ceba6ba81bad7fc3e97.tar.gz
gpgme-25e2d717f44682f83c483ceba6ba81bad7fc3e97.zip
tests: Fix gcc incompatibility
* tests/json/t-json.c: Remove var definitions inside a for statement. -- This useful C99 feature seems to work only in recent gcc versions. We can't use it; see gnupg/doc/HACKING. GnuPG-bug-id: 5088
Diffstat (limited to 'tests')
-rw-r--r--tests/json/t-json.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/tests/json/t-json.c b/tests/json/t-json.c
index e1fb6c1e..160132b2 100644
--- a/tests/json/t-json.c
+++ b/tests/json/t-json.c
@@ -209,6 +209,8 @@ get_file (const char *fname)
int
test_contains (cjson_t needle, cjson_t hay)
{
+ cjson_t it;
+
if (verbose == 2)
fprintf (stderr, "%s: -------checking-------- "
"\n%s\n -------against-------- \n%s\n",
@@ -261,7 +263,9 @@ test_contains (cjson_t needle, cjson_t hay)
if (test_contains (needle->child, hay->child))
{
int found = 0;
- for (cjson_t hit = hay->child; hit; hit = hit->next)
+ cjson_t hit;
+
+ for (hit = hay->child; hit; hit = hit->next)
{
found |= !test_contains (needle->child, hit);
if (found)
@@ -282,13 +286,16 @@ test_contains (cjson_t needle, cjson_t hay)
}
/* Walk elements of an array */
- for (cjson_t it = needle->next; it; it = it->next)
+ for (it = needle->next; it; it = it->next)
{
int found = 0;
+ cjson_t hit;
+
if (!it->string && it->child)
{
/* Try out all other anonymous children on the same level */
- cjson_t hit = hay;
+ hit = hay;
+
/* Return to the beginning */
while (hit->prev)
{
@@ -310,7 +317,7 @@ test_contains (cjson_t needle, cjson_t hay)
}
/* Try the children in the haystack */
- for (cjson_t hit = hay; hit; hit = hit->next)
+ for (hit = hay; hit; hit = hit->next)
{
if (hit->string && it->string &&
!strcmp (hit->string, it->string))
@@ -463,6 +470,7 @@ main (int argc, char *argv[])
{
const char *gpgme_json = getenv ("gpgme_json");
int last_argc = -1;
+ const char **test;
if (argc)
{ argc--; argv++; }
@@ -488,7 +496,7 @@ main (int argc, char *argv[])
init_gpgme (GPGME_PROTOCOL_SPAWN);
- for (const char **test = tests; *test; test++)
+ for (test = tests; *test; test++)
{
if (run_test (*test, gpgme_json))
{