diff options
author | Philip Guenthe <guenther@cvs.openbsd.org> | 2012-03-03 09:36:27 +0000 |
---|---|---|
committer | Philip Guenthe <guenther@cvs.openbsd.org> | 2012-03-03 09:36:27 +0000 |
commit | 10be96f2d3f09efc66492720718c3dedc5ed5657 (patch) | |
tree | 4adfdf1f52b3d94a4d5217e5cf78dbe3edf74007 | |
parent | c4a6567d1168a9e2c74534ebe286c8403c7fb54e (diff) |
While we guarantee that a zero-filled sem_t variable will trigger
EINVAL errors, a sem_t on the stack may have garbage, so make the
tests portable by moving the sem_t from function to file scope.
problem found by miod@
3 files changed, 9 insertions, 6 deletions
diff --git a/regress/lib/libpthread/semaphore/sem_getvalue/sem_getvalue.c b/regress/lib/libpthread/semaphore/sem_getvalue/sem_getvalue.c index 8f9cf62d782..19e596f90f7 100644 --- a/regress/lib/libpthread/semaphore/sem_getvalue/sem_getvalue.c +++ b/regress/lib/libpthread/semaphore/sem_getvalue/sem_getvalue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sem_getvalue.c,v 1.1 2012/01/04 17:36:40 mpi Exp $ */ +/* $OpenBSD: sem_getvalue.c,v 1.2 2012/03/03 09:36:26 guenther Exp $ */ /* * Martin Pieuchot <mpi@openbsd.org>, 2011. Public Domain. */ @@ -7,10 +7,11 @@ #include <semaphore.h> #include "test.h" +sem_t sem; + int main(int argc, char **argv) { - sem_t sem; int val; CHECKr(sem_init(&sem, 0, 0)); diff --git a/regress/lib/libpthread/semaphore/sem_trywait/sem_trywait.c b/regress/lib/libpthread/semaphore/sem_trywait/sem_trywait.c index 2430c1386d7..b4a4fe64ff6 100644 --- a/regress/lib/libpthread/semaphore/sem_trywait/sem_trywait.c +++ b/regress/lib/libpthread/semaphore/sem_trywait/sem_trywait.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sem_trywait.c,v 1.1 2012/01/04 17:36:40 mpi Exp $ */ +/* $OpenBSD: sem_trywait.c,v 1.2 2012/03/03 09:36:26 guenther Exp $ */ /* * Martin Pieuchot <mpi@openbsd.org>, 2011. Public Domain. */ @@ -8,10 +8,11 @@ #include <semaphore.h> #include "test.h" +sem_t sem; + int main(int argc, char **argv) { - sem_t sem; int val; CHECKn(sem_trywait(&sem)); diff --git a/regress/lib/libpthread/semaphore/sem_wait/sem_wait.c b/regress/lib/libpthread/semaphore/sem_wait/sem_wait.c index 8da14c6f507..efc3e932ffe 100644 --- a/regress/lib/libpthread/semaphore/sem_wait/sem_wait.c +++ b/regress/lib/libpthread/semaphore/sem_wait/sem_wait.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sem_wait.c,v 1.1 2012/01/04 17:36:40 mpi Exp $ */ +/* $OpenBSD: sem_wait.c,v 1.2 2012/03/03 09:36:26 guenther Exp $ */ /* * Martin Pieuchot <mpi@openbsd.org>, 2011. Public Domain. */ @@ -12,11 +12,12 @@ void *waiter(void *arg); +sem_t sem; + int main(int argc, char **argv) { pthread_t th; - sem_t sem; CHECKn(sem_wait(&sem)); ASSERT(errno == EINVAL); |