From: Mathieu Desnoyers Date: Tue, 29 May 2012 02:10:54 +0000 (-0400) Subject: Test fix: test_perthreadlock uninitialized mutex X-Git-Tag: v0.7.3~5 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=dee093381aa4f642a707fb4b28dbb9df0b8ad155;p=userspace-rcu.git Test fix: test_perthreadlock uninitialized mutex - Initialize the per thread mutexes. (fix) - Remove unused count_reader/count_writer variables. (cleanup) Signed-off-by: Mathieu Desnoyers --- diff --git a/tests/test_perthreadlock.c b/tests/test_perthreadlock.c index 6ff0412..e8e6166 100644 --- a/tests/test_perthreadlock.c +++ b/tests/test_perthreadlock.c @@ -283,7 +283,6 @@ int main(int argc, char **argv) int err; pthread_t *tid_reader, *tid_writer; void *tret; - unsigned long long *count_reader, *count_writer; unsigned long long tot_reads = 0, tot_writes = 0; int i, a; @@ -369,11 +368,14 @@ int main(int argc, char **argv) tid_reader = malloc(sizeof(*tid_reader) * nr_readers); tid_writer = malloc(sizeof(*tid_writer) * nr_writers); - count_reader = malloc(sizeof(*count_reader) * nr_readers); - count_writer = malloc(sizeof(*count_writer) * nr_writers); tot_nr_reads = malloc(sizeof(*tot_nr_reads) * nr_readers); tot_nr_writes = malloc(sizeof(*tot_nr_writes) * nr_writers); per_thread_lock = malloc(sizeof(*per_thread_lock) * nr_readers); + for (i = 0; i < nr_readers; i++) { + err = pthread_mutex_init(&per_thread_lock[i].lock, NULL); + if (err != 0) + exit(1); + } next_aff = 0; @@ -422,8 +424,6 @@ int main(int argc, char **argv) free(tid_reader); free(tid_writer); - free(count_reader); - free(count_writer); free(tot_nr_reads); free(tot_nr_writes); free(per_thread_lock);