diff options
author | Federico G. Schwindt <fgsch@cvs.openbsd.org> | 2001-09-12 12:07:40 +0000 |
---|---|---|
committer | Federico G. Schwindt <fgsch@cvs.openbsd.org> | 2001-09-12 12:07:40 +0000 |
commit | ab4af65d9af319cc4ea8ded28695df3790a0bb53 (patch) | |
tree | 4e47e306d3d3a6758074067b42e7072def872e05 /regress/lib/libc_r | |
parent | 07e8f9f442a133d2aba1c20e52602b4e4f15c864 (diff) |
Fix test.
Diffstat (limited to 'regress/lib/libc_r')
-rw-r--r-- | regress/lib/libc_r/group/group.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/regress/lib/libc_r/group/group.c b/regress/lib/libc_r/group/group.c index 8ace598e9d8..cec7667e516 100644 --- a/regress/lib/libc_r/group/group.c +++ b/regress/lib/libc_r/group/group.c @@ -1,18 +1,20 @@ -/* $OpenBSD: group.c,v 1.3 2001/09/11 04:57:32 pvalchev Exp $ */ +/* $OpenBSD: group.c,v 1.4 2001/09/12 12:07:39 fgsch Exp $ */ + /* David Leonard <d@openbsd.org>, 2001. Public Domain. */ /* * Test getgrgid_r() across multiple threads to see if the members list changes. */ +#include <sys/types.h> +#include <grp.h> #include <pthread.h> #include <unistd.h> #include <stdio.h> -#include <grp.h> -#include <sys/types.h> +#include <stdlib.h> #include "test.h" -struct group * getgrgid_r(gid_t, struct group *, char *, size_t, struct group **); +int getgrgid_r(gid_t, struct group *, char *, size_t, struct group **); char fail[] = "fail"; @@ -22,14 +24,15 @@ volatile int done_count; pthread_mutex_t display; pthread_mutex_t display2; -void* -test(void* arg) +void * +test(void *arg) { gid_t gid = *(gid_t *)arg; gid_t ogid; struct group grpbuf; struct group *grp; char **p; + char buffer[5000]; char buf[2048]; char *cpy[128]; int i; @@ -37,7 +40,6 @@ test(void* arg) char *s; char *oname; char *opasswd; - size_t size = 0; /* Acquire lock for running first part. */ CHECKr(pthread_mutex_lock(&display)); @@ -47,7 +49,7 @@ test(void* arg) /* Call getgrgid_r() */ printf("gid %d\n", gid); - CHECKn(grp = getgrgid_r(gid, &grpbuf, buf, size, &grp)); + CHECKr(getgrgid_r(gid, &grpbuf, buffer, sizeof(buffer), &grp)); /* Test for non-alteration of group structure */ ASSERT(grp->gr_name != fail); @@ -153,7 +155,10 @@ main() /* Get separate threads to do a group open separately */ for (gid = 0; gid < NGRPS; gid++) { - CHECKr(pthread_create(&thread[gid], NULL, test, (void *)&gid)); + int *n = (int *)malloc(sizeof(int)); + *n = gid; + + CHECKr(pthread_create(&thread[gid], NULL, test, (void *)n)); } /* Allow all threads to run their first part */ |