summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/getdelim.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2017-07-13 09:27:11 +0000
committerkib <kib@FreeBSD.org>2017-07-13 09:27:11 +0000
commit668d59a23068fc4a8aa806b914d95c71e903e92f (patch)
tree2479fb648c9c841acba46263712cd58a9c7dc384 /lib/libc/stdio/getdelim.c
parent55a89eef51d5a91be65f136631688b2c5b3371ab (diff)
downloadFreeBSD-src-668d59a23068fc4a8aa806b914d95c71e903e92f.zip
FreeBSD-src-668d59a23068fc4a8aa806b914d95c71e903e92f.tar.gz
MFC r320472,r320508,r320509:
Make stdio deferred cancel-safe.
Diffstat (limited to 'lib/libc/stdio/getdelim.c')
-rw-r--r--lib/libc/stdio/getdelim.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/libc/stdio/getdelim.c b/lib/libc/stdio/getdelim.c
index 7e0b2e2..26c608f 100644
--- a/lib/libc/stdio/getdelim.c
+++ b/lib/libc/stdio/getdelim.c
@@ -112,7 +112,7 @@ getdelim(char ** __restrict linep, size_t * __restrict linecapp, int delim,
u_char *endp;
size_t linelen;
- FLOCKFILE(fp);
+ FLOCKFILE_CANCELSAFE(fp);
ORIENT(fp, -1);
if (linep == NULL || linecapp == NULL) {
@@ -127,9 +127,9 @@ getdelim(char ** __restrict linep, size_t * __restrict linecapp, int delim,
/* If fp is at EOF already, we just need space for the NUL. */
if (!__sfeof(fp) || expandtofit(linep, 1, linecapp))
goto error;
- FUNLOCKFILE(fp);
(*linep)[0] = '\0';
- return (-1);
+ linelen = -1;
+ goto end;
}
linelen = 0;
@@ -150,11 +150,12 @@ getdelim(char ** __restrict linep, size_t * __restrict linecapp, int delim,
done:
/* Invariant: *linep has space for at least linelen+1 bytes. */
(*linep)[linelen] = '\0';
- FUNLOCKFILE(fp);
+end:
+ FUNLOCKFILE_CANCELSAFE();
return (linelen);
error:
fp->_flags |= __SERR;
- FUNLOCKFILE(fp);
- return (-1);
+ linelen = -1;
+ goto end;
}
OpenPOWER on IntegriCloud