aboutsummaryrefslogtreecommitdiff
path: root/posix
diff options
context:
space:
mode:
Diffstat (limited to 'posix')
-rw-r--r--posix/tst-rfc3484-2.c17
-rw-r--r--posix/tst-rfc3484-3.c8
-rw-r--r--posix/tst-rfc3484.c8
3 files changed, 19 insertions, 14 deletions
diff --git a/posix/tst-rfc3484-2.c b/posix/tst-rfc3484-2.c
index d29f072..56c0277 100644
--- a/posix/tst-rfc3484-2.c
+++ b/posix/tst-rfc3484-2.c
@@ -100,31 +100,32 @@ do_test (void)
struct sort_result results[2];
+ size_t order[2];
results[0].dest_addr = &ai1;
results[0].got_source_addr = true;
results[0].source_addr_len = sizeof (so1);
results[0].source_addr_flags = 0;
- results[0].service_order = 0;
results[0].prefixlen = 16;
results[0].index = 0;
memcpy (&results[0].source_addr, &so1, sizeof (so1));
+ order[0] = 0;
results[1].dest_addr = &ai2;
results[1].got_source_addr = true;
results[1].source_addr_len = sizeof (so2);
results[1].source_addr_flags = 0;
- results[1].service_order = 1;
results[1].prefixlen = 16;
results[1].index = 0;
memcpy (&results[1].source_addr, &so2, sizeof (so2));
+ order[1] = 1;
struct sort_result_combo combo = { .results = results, .nresults = 2 };
- qsort_r (results, 2, sizeof (results[0]), rfc3484_sort, &combo);
+ qsort_r (order, 2, sizeof (order[0]), rfc3484_sort, &combo);
int result = 0;
- if (results[0].dest_addr->ai_family == AF_INET6)
+ if (results[order[0]].dest_addr->ai_family == AF_INET6)
{
puts ("wrong order in first test");
result |= 1;
@@ -136,24 +137,24 @@ do_test (void)
results[1].got_source_addr = true;
results[1].source_addr_len = sizeof (so1);
results[1].source_addr_flags = 0;
- results[1].service_order = 1;
results[1].prefixlen = 16;
results[1].index = 0;
memcpy (&results[1].source_addr, &so1, sizeof (so1));
+ order[1] = 1;
results[0].dest_addr = &ai2;
results[0].got_source_addr = true;
results[0].source_addr_len = sizeof (so2);
results[0].source_addr_flags = 0;
- results[0].service_order = 0;
results[0].prefixlen = 16;
results[0].index = 0;
memcpy (&results[0].source_addr, &so2, sizeof (so2));
+ order[0] = 0;
- qsort_r (results, 2, sizeof (results[0]), rfc3484_sort, &combo);
+ qsort_r (order, 2, sizeof (order[0]), rfc3484_sort, &combo);
- if (results[0].dest_addr->ai_family == AF_INET6)
+ if (results[order[0]].dest_addr->ai_family == AF_INET6)
{
puts ("wrong order in second test");
result |= 1;
diff --git a/posix/tst-rfc3484-3.c b/posix/tst-rfc3484-3.c
index 4aede81..616722e 100644
--- a/posix/tst-rfc3484-3.c
+++ b/posix/tst-rfc3484-3.c
@@ -66,6 +66,7 @@ struct sockaddr_in addrs[] =
#define naddrs (sizeof (addrs) / sizeof (addrs[0]))
static struct addrinfo ais[naddrs];
static struct sort_result results[naddrs];
+static size_t order[naddrs];
static const int expected[naddrs] =
{
@@ -111,18 +112,19 @@ do_test (void)
memcpy(&results[i].source_addr, &so, sizeof (so));
results[i].source_addr_len = sizeof (so);
results[i].source_addr_flags = 0;
- results[i].service_order = i;
results[i].prefixlen = 8;
results[i].index = 0;
+
+ order[i] = i;
}
struct sort_result_combo combo = { .results = results, .nresults = naddrs };
- qsort_r (results, naddrs, sizeof (results[0]), rfc3484_sort, &combo);
+ qsort_r (order, naddrs, sizeof (order[0]), rfc3484_sort, &combo);
int result = 0;
for (int i = 0; i < naddrs; ++i)
{
- struct in_addr addr = ((struct sockaddr_in *) (results[i].dest_addr->ai_addr))->sin_addr;
+ struct in_addr addr = ((struct sockaddr_in *) (results[order[i]].dest_addr->ai_addr))->sin_addr;
int here = memcmp (&addr, &addrs[expected[i]].sin_addr,
sizeof (struct in_addr));
diff --git a/posix/tst-rfc3484.c b/posix/tst-rfc3484.c
index fe06255..4df5b29 100644
--- a/posix/tst-rfc3484.c
+++ b/posix/tst-rfc3484.c
@@ -64,6 +64,7 @@ struct sockaddr_in addrs[] =
#define naddrs (sizeof (addrs) / sizeof (addrs[0]))
static struct addrinfo ais[naddrs];
static struct sort_result results[naddrs];
+static size_t order[naddrs];
static int expected[naddrs] =
{
@@ -100,18 +101,19 @@ do_test (void)
memcpy(&results[i].source_addr, &so, sizeof (so));
results[i].source_addr_len = sizeof (so);
results[i].source_addr_flags = 0;
- results[i].service_order = i;
results[i].prefixlen = 8;
results[i].index = 0;
+
+ order[i] = i;
}
struct sort_result_combo combo = { .results = results, .nresults = naddrs };
- qsort_r (results, naddrs, sizeof (results[0]), rfc3484_sort, &combo);
+ qsort_r (order, naddrs, sizeof (order[0]), rfc3484_sort, &combo);
int result = 0;
for (int i = 0; i < naddrs; ++i)
{
- struct in_addr addr = ((struct sockaddr_in *) (results[i].dest_addr->ai_addr))->sin_addr;
+ struct in_addr addr = ((struct sockaddr_in *) (results[order[i]].dest_addr->ai_addr))->sin_addr;
int here = memcmp (&addr, &addrs[expected[i]].sin_addr,
sizeof (struct in_addr));