diff options
Diffstat (limited to 'libc/misc/ttyent')
-rw-r--r-- | libc/misc/ttyent/getttyent.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/libc/misc/ttyent/getttyent.c b/libc/misc/ttyent/getttyent.c index 89c39876f..c9c68f1cc 100644 --- a/libc/misc/ttyent/getttyent.c +++ b/libc/misc/ttyent/getttyent.c @@ -126,6 +126,7 @@ struct ttyent * getttyent(void) register int c; register char *p; static char *line = NULL; + struct ttyent *retval = NULL; if (!tf && !setttyent()) return (NULL); @@ -140,8 +141,7 @@ struct ttyent * getttyent(void) for (;;) { if (!fgets_unlocked(p = line, BUFSIZ, tf)) { - __STDIO_ALWAYS_THREADUNLOCK(tf); - return (NULL); + goto DONE; } /* skip lines that are too big */ if (!strchr(p, '\n')) { @@ -184,8 +184,6 @@ struct ttyent * getttyent(void) else break; } - /* We can release the lock only here since `zapchar' is global. */ - __STDIO_ALWAYS_THREADUNLOCK(tf); if (zapchar == '#' || *p == '#') while ((c = *++p) == ' ' || c == '\t') @@ -195,7 +193,11 @@ struct ttyent * getttyent(void) tty.ty_comment = 0; if ((p = strchr(p, '\n'))) *p = '\0'; - return (&tty); + retval = &tty; + + DONE: + __STDIO_ALWAYS_THREADUNLOCK(tf); + return retval; } libc_hidden_def(getttyent) |