|
From: Cyril H. <su...@li...> - 2013-05-07 13:21:26
|
The branch, master, has been updated
via 981d33aad3b33c4625b88990fbf2fad5470d47e0 (commit)
from 00ca3f69134db1fee11bcc8ce2b67757ad012e9f (commit)
- Log -----------------------------------------------------------------
commit 981d33aad3b33c4625b88990fbf2fad5470d47e0
Author: Dave Kleikamp <dav...@or...>
Date: Mon May 6 11:47:30 2013 -0500
Fix retval parameter to pthread_join()
The retval parameter to pthread_join() is a pointer to a pointer. There
are several instances where a pointer to int is being passed instead.
This can result in a bus error on sparc64 when the pointer is not
aligned on a 64-bit boundary. Of course, it's a potential problem on
any 64-bit platform.
Also removed an unnecessary malloc & free from mmstress.c
Signed-off-by: Dave Kleikamp <dav...@or...>
-----------------------------------------------------------------------
Summary of changes:
testcases/kernel/io/ltp-aiodio/aio-stress.c | 3 +--
testcases/kernel/io/stress_cd/stress_cd.c | 9 +++++----
testcases/kernel/mem/mtest05/mmstress.c | 9 +++------
testcases/kernel/mem/mtest06/mmap1.c | 8 ++++----
testcases/kernel/mem/mtest06/mmap3.c | 9 +++++----
testcases/kernel/mem/mtest06/shmat1.c | 10 +++++-----
testcases/kernel/mem/mtest07/shm_test.c | 6 +++---
testcases/network/nfs/nfsstress/make_tree.c | 6 +++---
.../interfaces/pthread_cond_timedwait/4-1.c | 6 +++---
9 files changed, 32 insertions(+), 34 deletions(-)
diff --git a/testcases/kernel/io/ltp-aiodio/aio-stress.c b/testcases/kernel/io/ltp-aiodio/aio-stress.c
index 710ef3d..0b7148c 100644
--- a/testcases/kernel/io/ltp-aiodio/aio-stress.c
+++ b/testcases/kernel/io/ltp-aiodio/aio-stress.c
@@ -1233,7 +1233,6 @@ typedef void *(*start_routine) (void *);
int run_workers(struct thread_info *t, int num_threads)
{
int ret;
- int thread_ret;
int i;
for (i = 0; i < num_threads; i++) {
@@ -1246,7 +1245,7 @@ int run_workers(struct thread_info *t, int num_threads)
}
}
for (i = 0; i < num_threads; i++) {
- ret = pthread_join(t[i].tid, (void *)&thread_ret);
+ ret = pthread_join(t[i].tid, NULL);
if (ret) {
perror("pthread_join");
exit(1);
diff --git a/testcases/kernel/io/stress_cd/stress_cd.c b/testcases/kernel/io/stress_cd/stress_cd.c
index 1048b62..3e1e697 100644
--- a/testcases/kernel/io/stress_cd/stress_cd.c
+++ b/testcases/kernel/io/stress_cd/stress_cd.c
@@ -143,15 +143,16 @@ int main(int argc, char **argv)
sys_error("pthread_attr_destroy failed", __LINE__);
for (i = 0; i < num_threads; i++) {
- int exit_value;
+ void *exit_value;
printf("\tThread [main]: waiting for thread: %d\n", i + 1);
/*if (pthread_join ((pthread_t*) array [i], (void **) &exit_value)) */
- if (pthread_join((pthread_t) array[i], (void **)&exit_value))
+ if (pthread_join(array[i], &exit_value))
sys_error("pthread_join failed", __LINE__);
if (debug)
- printf("\tThread [%d]: return %d\n", i + 1, exit_value);
- rc += exit_value;
+ printf("\tThread [%d]: return %ld\n", i + 1,
+ (long)exit_value);
+ rc += (long)exit_value;
}
free(array);
free(arg);
diff --git a/testcases/kernel/mem/mtest05/mmstress.c b/testcases/kernel/mem/mtest05/mmstress.c
index f845290..bb746ec 100644
--- a/testcases/kernel/mem/mtest05/mmstress.c
+++ b/testcases/kernel/mem/mtest05/mmstress.c
@@ -361,7 +361,7 @@ RETINFO_t *map_and_thread(char *tmpfile, /* name of temporary file to be created
int fd = 0; /* file descriptor of the file created */
int thrd_ndx = 0; /* index to the number of threads created */
int map_type = 0; /* specifies the type of the mapped object */
- int *th_status = 0; /* status of the thread when it is finished */
+ void *th_status; /* status of the thread when it is finished */
long th_args[5]; /* argument list passed to thread_fault() */
char *empty_buf = NULL; /* empty buffer used to fill temp file */
long pagesize /* contains page size at runtime */
@@ -474,13 +474,12 @@ RETINFO_t *map_and_thread(char *tmpfile, /* name of temporary file to be created
if (verbose_print)
tst_resm(TINFO, "map_and_thread(): pthread_create() success");
wait_thread = FALSE;
- th_status = malloc(sizeof(int *));
/* suspend the execution of the calling thread till the execution of the */
/* other thread has been terminated. */
for (thrd_ndx = 0; thrd_ndx < NUMTHREAD; thrd_ndx++) {
- if (pthread_join(pthread_ids[thrd_ndx], (void **)th_status)) {
+ if (pthread_join(pthread_ids[thrd_ndx], &th_status)) {
perror("map_and_thread(): pthread_join()");
free(empty_buf);
fflush(NULL);
@@ -489,7 +488,7 @@ RETINFO_t *map_and_thread(char *tmpfile, /* name of temporary file to be created
retinfo->status = FAILED;
return retinfo;
} else {
- if ((int)*th_status == 1) {
+ if ((long)th_status == 1) {
tst_resm(TINFO,
"thread [%ld] - process exited with errors",
(long)pthread_ids[thrd_ndx]);
@@ -513,13 +512,11 @@ RETINFO_t *map_and_thread(char *tmpfile, /* name of temporary file to be created
*/
if (remove_files(tmpfile, map_addr) == FAILED) {
free(empty_buf);
- free(th_status);
retinfo->status = FAILED;
return retinfo;
}
free(empty_buf);
- free(th_status);
close(fd);
retinfo->status = SUCCESS;
return retinfo;
diff --git a/testcases/kernel/mem/mtest06/mmap1.c b/testcases/kernel/mem/mtest06/mmap1.c
index 61d5369..7c80bb4 100644
--- a/testcases/kernel/mem/mtest06/mmap1.c
+++ b/testcases/kernel/mem/mtest06/mmap1.c
@@ -285,7 +285,7 @@ int main(int argc, char **argv)
int num_iter;
double exec_time;
int fd;
- int status[2];
+ void *status;
pthread_t thid[2];
long chld_args[3];
extern char *optarg;
@@ -387,15 +387,15 @@ int main(int argc, char **argv)
tst_resm(TINFO, "created reading thread[%lu]", thid[1]);
for (i = 0; i < 2; i++) {
- if ((ret = pthread_join(thid[i], (void *)&status[i])))
+ if ((ret = pthread_join(thid[i], &status)))
tst_brkm(TBROK, NULL,
"main(): pthread_join(): %s",
strerror(ret));
- if (status[i])
+ if (status)
tst_brkm(TFAIL, NULL,
"thread [%lu] - process exited "
- "with %d", thid[i], status[i]);
+ "with %ld", thid[i], (long)status);
}
close(fd);
diff --git a/testcases/kernel/mem/mtest06/mmap3.c b/testcases/kernel/mem/mtest06/mmap3.c
index ec4de47..e758314 100644
--- a/testcases/kernel/mem/mtest06/mmap3.c
+++ b/testcases/kernel/mem/mtest06/mmap3.c
@@ -264,7 +264,7 @@ int main(int argc, /* number of input parameters. */
int num_thrd; /* number of threads to create */
int thrd_ndx; /* index into the array of threads. */
float exec_time; /* period for which the test is executed */
- int status; /* exit status for light weight process */
+ void *status; /* exit status for light weight process */
int sig_ndx; /* index into signal handler structure. */
pthread_t thid[1000]; /* pids of process that will map/write/unmap */
long chld_args[3]; /* arguments to funcs execed by child process */
@@ -362,14 +362,15 @@ int main(int argc, /* number of input parameters. */
/* wait for the children to terminate */
for (thrd_ndx = 0; thrd_ndx < num_thrd; thrd_ndx++) {
- if (pthread_join(thid[thrd_ndx], (void *)&status)) {
+ if (pthread_join(thid[thrd_ndx], &status)) {
perror("main(): pthread_create()");
exit(-1);
} else {
if (status) {
fprintf(stderr,
- "thread [%d] - process exited with errors %d\n",
- WEXITSTATUS(status), status);
+ "thread [%d] - process exited with errors %ld\n",
+ WEXITSTATUS((long)status),
+ (long)status);
exit(-1);
}
}
diff --git a/testcases/kernel/mem/mtest06/shmat1.c b/testcases/kernel/mem/mtest06/shmat1.c
index ddaa49e..db37eca 100644
--- a/testcases/kernel/mem/mtest06/shmat1.c
+++ b/testcases/kernel/mem/mtest06/shmat1.c
@@ -392,7 +392,7 @@ int main(int argc, /* number of input parameters. */
int num_iter; /* number of iteration to perform */
int thrd_ndx; /* index into the array of threads. */
double exec_time; /* period for which the test is executed */
- int status[1]; /* exit status for light weight process */
+ void *status; /* exit status for light weight process */
int sig_ndx; /* index into signal handler structure. */
pthread_t thid[1000]; /* pids of process that will map/write/unmap */
long chld_args[3]; /* arguments to funcs execed by child process */
@@ -497,14 +497,14 @@ int main(int argc, /* number of input parameters. */
/* wait for the children to terminate */
for (thrd_ndx = 0; thrd_ndx < 3; thrd_ndx++) {
- if (pthread_join(thid[thrd_ndx], (void *)status)) {
+ if (pthread_join(thid[thrd_ndx], &status)) {
perror("main(): pthread_create()");
exit(-1);
}
- if (*status == -1) {
+ if (status == (void *)-1) {
fprintf(stderr,
- "thread [%#lx] - process exited with errors %d\n",
- thid[thrd_ndx], *status);
+ "thread [%#lx] - process exited with errors %ld\n",
+ thid[thrd_ndx], (long)status);
exit(-1);
}
}
diff --git a/testcases/kernel/mem/mtest07/shm_test.c b/testcases/kernel/mem/mtest07/shm_test.c
index 2f2c9f1..b3d6aaf 100644
--- a/testcases/kernel/mem/mtest07/shm_test.c
+++ b/testcases/kernel/mem/mtest07/shm_test.c
@@ -273,7 +273,7 @@ int main(int argc, /* number of input parameters */
int num_thrd = MAXT; /* number of threads to create */
int num_reps = MAXR; /* number of repatitions the test is run */
int thrd_ndx; /* index into the array of thread ids */
- int th_status; /* exit status of LWP's */
+ void *th_status; /* exit status of LWP's */
int map_size; /* size of the file mapped. */
int shmkey = 1969; /* key used to generate shmid by shmget() */
pthread_t thrdid[30]; /* maxinum of 30 threads allowed */
@@ -344,12 +344,12 @@ int main(int argc, /* number of input parameters */
sync();
for (thrd_ndx = 0; thrd_ndx < num_thrd; thrd_ndx++) {
- if (pthread_join(thrdid[thrd_ndx], (void *)&th_status) != 0) {
+ if (pthread_join(thrdid[thrd_ndx], &th_status) != 0) {
perror("shmat_rd_wr(): pthread_join()");
exit(-1);
} else {
dprt("WE ARE HERE %d\n", __LINE__);
- if (th_status == -1) {
+ if (th_status == (void *)-1) {
fprintf(stderr,
"thread [%ld] - process exited with errors\n",
(long)thrdid[thrd_ndx]);
diff --git a/testcases/network/nfs/nfsstress/make_tree.c b/testcases/network/nfs/nfsstress/make_tree.c
index 7df0b8d..7b18da3 100644
--- a/testcases/network/nfs/nfsstress/make_tree.c
+++ b/testcases/network/nfs/nfsstress/make_tree.c
@@ -721,7 +721,7 @@ int main(int argc, /* number of input parameters */
int num_dirs = MAXD; /* number of subdirectories to create */
int num_files = MAXF; /* number of files in each subdirectory */
int thrd_ndx; /* index into the array of thread ids */
- int th_status[1]; /* exit status of LWP's */
+ void *th_status; /* exit status of LWP's */
pthread_t thrdid[30]; /* maxinum of 30 threads allowed */
long chld_args[3]; /* arguments to the thread function */
extern int optopt; /* options to the program */
@@ -778,12 +778,12 @@ int main(int argc, /* number of input parameters */
sync();
for (thrd_ndx = 0; thrd_ndx < num_thrd; thrd_ndx++) {
- if (pthread_join(thrdid[thrd_ndx], (void **)&th_status) != 0) {
+ if (pthread_join(thrdid[thrd_ndx], &th_status) != 0) {
perror("crte_mk_rm(): pthread_join()");
exit(-1);
} else {
dprt("WE ARE HERE %d\n", __LINE__);
- if (*th_status == -1) {
+ if (th_status == (void *)-1) {
fprintf(stderr,
"thread [%ld] - process exited with errors\n",
thrdid[thrd_ndx]);
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_timedwait/4-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_timedwait/4-1.c
index 43cdf3f..6e0724e 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_timedwait/4-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_timedwait/4-1.c
@@ -67,7 +67,7 @@ void *t1_func(void *arg)
int main(void)
{
pthread_t thread1;
- int th_ret;
+ void *th_ret;
if (pthread_mutex_init(&td.mutex, NULL) != 0) {
fprintf(stderr, "Fail to initialize mutex\n");
@@ -85,6 +85,6 @@ int main(void)
fprintf(stderr, "Main: no condition is going to be met\n");
- pthread_join(thread1, (void *)&th_ret);
- return th_ret;
+ pthread_join(thread1, &th_ret);
+ return (long)th_ret;
}
hooks/post-receive
--
ltp
|