Fix dangerous casts in tests.

Fix dangerous casts of int variables to pointers in thread join function
calls.  On LP64 systems, int and pointers are different sizes, so
writes can corrupt memory.
This commit is contained in:
Jason Evans 2013-10-20 14:07:18 -07:00
parent dda90f59e2
commit 8edaf86b67
3 changed files with 10 additions and 6 deletions

View File

@ -104,12 +104,12 @@ main(void)
je_thread_start(NULL);
je_thread_create(&thread, je_thread_start, NULL);
je_thread_join(thread, (void *)&ret);
je_thread_join(thread, NULL);
je_thread_start(NULL);
je_thread_create(&thread, je_thread_start, NULL);
je_thread_join(thread, (void *)&ret);
je_thread_join(thread, NULL);
je_thread_start(NULL);

View File

@ -72,8 +72,12 @@ main(void)
(void *)&arena_ind);
}
for (i = 0; i < NTHREADS; i++)
je_thread_join(threads[i], (void *)&ret);
for (i = 0; i < NTHREADS; i++) {
intptr_t join_ret;
je_thread_join(threads[i], (void *)&join_ret);
if (join_ret != 0)
ret = 1;
}
label_return:
malloc_printf("Test end\n");

View File

@ -77,12 +77,12 @@ main(void)
je_thread_start(NULL);
je_thread_create(&thread, je_thread_start, NULL);
je_thread_join(thread, (void *)&ret);
je_thread_join(thread, NULL);
je_thread_start(NULL);
je_thread_create(&thread, je_thread_start, NULL);
je_thread_join(thread, (void *)&ret);
je_thread_join(thread, NULL);
je_thread_start(NULL);