From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 14FF43858416; Fri, 17 Nov 2023 16:09:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 14FF43858416 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1700237396; bh=+nJdUKJxWjkDK9B7I9a/VdlCDZ8RwuArbvSga22wskI=; h=From:To:Subject:Date:From; b=MyyOZMmALNtTbfN8ytETyaQE54x+ZecUyL/SYdamy44B+EW5ZKgj/1iv8SBUnhacN +PqkMDSpNmflTv+b/Yue5kzInnaBuYoPqwTJT5pP91Anic7coxVaMH/JBSi7YXT2hQ cCllAOxBLAxq33s1uOrKet/dXsrzEcgrgUGv2T+o= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: newlib-cvs@sourceware.org Subject: [newlib-cygwin/main] __sfvwrite_r: call __sputc_r rather than putc in __SCLE case X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/main X-Git-Oldrev: 61ccd3f94f92bcfc0940f0595ea5b3b72bce3c6d X-Git-Newrev: 6ccbfe6a3d8a2aedb2c6f80bcc03bf946acc1b6c Message-Id: <20231117160956.14FF43858416@sourceware.org> Date: Fri, 17 Nov 2023 16:09:56 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D6ccbfe6a3d8= a2aedb2c6f80bcc03bf946acc1b6c commit 6ccbfe6a3d8a2aedb2c6f80bcc03bf946acc1b6c Author: Corinna Vinschen AuthorDate: Fri Nov 17 17:00:54 2023 +0100 Commit: Corinna Vinschen CommitDate: Fri Nov 17 17:09:42 2023 +0100 __sfvwrite_r: call __sputc_r rather than putc in __SCLE case =20 __sfvwrite_r is called under lock. There's no reason to call putc, locking the file recursively. Add a comment that locking is required when calling __sfvwrite_r. =20 Fixes: 49d64538cd20 ("* libc/include/stdio.h (FILE): define __SCLE for = "convert line endings" for Cygwin.") Signed-off-by: Corinna Vinschen Diff: --- newlib/libc/stdio/fvwrite.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/newlib/libc/stdio/fvwrite.c b/newlib/libc/stdio/fvwrite.c index 34361cb8d135..fc79951032ad 100644 --- a/newlib/libc/stdio/fvwrite.c +++ b/newlib/libc/stdio/fvwrite.c @@ -40,6 +40,9 @@ /* * Write some memory regions. Return zero on success, EOF on error. * + * On systems supporting threads, this function *must* be called under + * _newlib_flockfile_start locking. + * * This routine is large and unsightly, but most of the ugliness due * to the three different kinds of output buffering is handled here. */ @@ -74,7 +77,7 @@ __sfvwrite_r (struct _reent *ptr, GETIOV (;); while (len > 0) { - if (putc (*p, fp) =3D=3D EOF) + if (__sputc_r (ptr, *p, fp) =3D=3D EOF) return EOF; p++; len--;