summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2022-03-20 12:54:33 +0300
committerIvan Maidanski <ivmai@mail.ru>2022-03-20 12:54:33 +0300
commit07f21cb35eeb58600bee377c5ce5cafc34391851 (patch)
tree6448eac1921fc8ba19e8b08b2844350a1b658be4 /tests
parentede3066b89bdfa3a44bbecf106842fa50b2a4bc3 (diff)
downloadbdwgc-07f21cb35eeb58600bee377c5ce5cafc34391851.tar.gz
Eliminate 'operation on seed may be undefined' gcc warning in disclaim.c
(fix of commit 2b10620b1) * tests/disclaim.c (test): Declare j local variable; set j to rand()%POP_SIZE; pass pop[j] to pair_new() as the first argument instead of pop[rand()%POP_SIZE].
Diffstat (limited to 'tests')
-rw-r--r--tests/disclaim.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/tests/disclaim.c b/tests/disclaim.c
index cd777381..94a75f72 100644
--- a/tests/disclaim.c
+++ b/tests/disclaim.c
@@ -198,6 +198,8 @@ void *test(void *data)
memset(pop, 0, sizeof(pop));
for (i = 0; i < MUTATE_CNT; ++i) {
int t = rand() % POP_SIZE;
+ int j;
+
switch (rand() % (i > GROW_LIMIT? 5 : 3)) {
case 0: case 3:
if (pop[t])
@@ -208,8 +210,8 @@ void *test(void *data)
pop[t] = pop[t]->cdr;
break;
case 2:
- pop[t] = pair_new(pop[rand() % POP_SIZE],
- pop[rand() % POP_SIZE]);
+ j = rand() % POP_SIZE;
+ pop[t] = pair_new(pop[j], pop[rand() % POP_SIZE]);
break;
}
if (rand() % 8 == 1)