summaryrefslogtreecommitdiff
path: root/lib/libc/stdio/fputws.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/stdio/fputws.c')
-rw-r--r--lib/libc/stdio/fputws.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/libc/stdio/fputws.c b/lib/libc/stdio/fputws.c
index 41530673c0076..19da946054b70 100644
--- a/lib/libc/stdio/fputws.c
+++ b/lib/libc/stdio/fputws.c
@@ -53,11 +53,13 @@ fputws_l(const wchar_t * __restrict ws, FILE * __restrict fp, locale_t locale)
const wchar_t *wsp;
FIX_LOCALE(locale);
struct xlocale_ctype *l = XLOCALE_CTYPE(locale);
+ int ret;
- FLOCKFILE(fp);
+ ret = -1;
+ FLOCKFILE_CANCELSAFE(fp);
ORIENT(fp, 1);
if (prepwrite(fp) != 0)
- goto error;
+ goto end;
uio.uio_iov = &iov;
uio.uio_iovcnt = 1;
iov.iov_base = buf;
@@ -66,17 +68,15 @@ fputws_l(const wchar_t * __restrict ws, FILE * __restrict fp, locale_t locale)
nbytes = l->__wcsnrtombs(buf, &wsp, SIZE_T_MAX, sizeof(buf),
&fp->_mbstate);
if (nbytes == (size_t)-1)
- goto error;
+ goto end;
uio.uio_resid = iov.iov_len = nbytes;
if (__sfvwrite(fp, &uio) != 0)
- goto error;
+ goto end;
} while (wsp != NULL);
- FUNLOCKFILE(fp);
- return (0);
-
-error:
- FUNLOCKFILE(fp);
- return (-1);
+ ret = 0;
+end:
+ FUNLOCKFILE_CANCELSAFE();
+ return (ret);
}
int