From nobody Tue Nov 07 17:28:28 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SPwDD4ptQz50sy2; Tue, 7 Nov 2023 17:28:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SPwDD4Mplz3cqy; Tue, 7 Nov 2023 17:28:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699378108; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Y9YukV7jNebu+pO9YK8GsFswrJVofKFnqYXf+EnfV4I=; b=SzUJqyZ/8+wQtzxDDmtY2k31XCX7AaTpP957fPchnJN1B7oYVf5H+iq1eGFmzVrmmjMiC5 mGU7dMpOh/9CMvboI7AQUWeITKU7N0BSPMRl0KqenR8Mmih4zgZBBAVQEqP36c9LHFvY3v J8XP3dEWiBBt1ZROZPBi2OGs1WXA3xtAPs4/guHnq1mJ6qfFpO1QHRETgTw61vX2Mrcmo8 8xHRUXDL9RU8NkpWEHpnzoFxw0YDcaZUurOoA7ju0dP/TRrhhmRyAuUN9KLRDRgjwgM7tF qcmL/XdK2sHzhEX/n0kPFXujB3uJxvNNyGVtWVvSUj4mOwhX4g602af2TIilOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699378108; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Y9YukV7jNebu+pO9YK8GsFswrJVofKFnqYXf+EnfV4I=; b=hHNR4Vz5evNBPe8dNbVQboTJsFIglb9b9q5i0ZuB9hPZD9eU1l+mdYFV5mZ+mAB2zgrj17 zIk2Wo9sG4b0UWRtVS5TbuLXxVkxD+ywFiQtT62Ov1TJDvRITOM63+2mF+AECcl3PE1MM9 +CZT/hodZ8TLrZyzkfGK6JVCA8u8uvEQDKI9unsvx6ba39RCCxt/Qfe6EOQsvy6PRr4Hg7 j0E3zP3pKpmVXMgLdv2N9sw8mUeM5EFZ2JEKw3s3WNvSH+h9ZYbbqAgIP/KwGpn8MxZcC2 4tFpBBu0MSewZLhphOyOeoImaqraqXIgejhMGXN2KbtD2qCTQEXnPInjNRtDrg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1699378108; a=rsa-sha256; cv=none; b=mOk4/W/Jzs+v/wH52IA8EbseyLVr4rkzZ6IfVigRS180Sm2adLh6NfiapBmgIeijk6B9b3 m544sPQQARdRWr/p1vo3/RbPxLfGoUDxl2vkN0RCGJLhskXHOSfDFJPK8jxHd0yJh3/7/A ObdynSa0vNj7/QRQQhhLSkOyctPtpXokedcf4sttJoRd8wuZpO7JuM7KUXogMe79bFWQyW +DHdVXJQr93gzbRKN1Xwo491JVhBXLGx8zMc87pAHvhC4m0Ym61rXCcd8CWGUBVMvezN0I /2P5shx1UjZq0wZpTMDloGYQBrtAckeiNVEhz86ThG3YBBTDI+g8mIZxRxoBOQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4SPwDD3Qpczysd; Tue, 7 Nov 2023 17:28:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3A7HSSLf037847; Tue, 7 Nov 2023 17:28:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3A7HSShE037844; Tue, 7 Nov 2023 17:28:28 GMT (envelope-from git) Date: Tue, 7 Nov 2023 17:28:28 GMT Message-Id: <202311071728.3A7HSShE037844@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 4e0e01bf6511 - main - fflush: correct buffer handling in __sflush List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4e0e01bf6511c28212d7dff94fe131a502e13026 Auto-Submitted: auto-generated The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=4e0e01bf6511c28212d7dff94fe131a502e13026 commit 4e0e01bf6511c28212d7dff94fe131a502e13026 Author: Ed Maste AuthorDate: 2023-11-07 14:16:13 +0000 Commit: Ed Maste CommitDate: 2023-11-07 16:03:34 +0000 fflush: correct buffer handling in __sflush Two additional stdio changes followed 86a16ada1ea6 and need to be reverted as part of the fflush fix. This reverts commit 6e13794fbe6e82c21365d0fd66769bf8b19c0197. This reverts commit bafaa70b6f9098d83d074968c8e6747ecec1e118. Fixes: d09a3bf72c0b ("fflush: correct buffer handling in __sflush") Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D42491 --- lib/libc/stdio/fvwrite.c | 13 ++----------- lib/libc/stdio/wbuf.c | 12 ++---------- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/lib/libc/stdio/fvwrite.c b/lib/libc/stdio/fvwrite.c index 63d17a8f8ffd..6162ca01aa63 100644 --- a/lib/libc/stdio/fvwrite.c +++ b/lib/libc/stdio/fvwrite.c @@ -51,7 +51,6 @@ int __sfvwrite(FILE *fp, struct __suio *uio) { size_t len; - unsigned char *old_p; char *p; struct __siov *iov; int w, s; @@ -135,12 +134,8 @@ __sfvwrite(FILE *fp, struct __suio *uio) COPY(w); /* fp->_w -= w; */ /* unneeded */ fp->_p += w; - old_p = fp->_p; - if (__fflush(fp) == EOF) { - if (old_p == fp->_p) - fp->_p -= w; + if (__fflush(fp)) goto err; - } } else if (len >= (w = fp->_bf._size)) { /* write directly */ w = _swrite(fp, p, w); @@ -179,12 +174,8 @@ __sfvwrite(FILE *fp, struct __suio *uio) COPY(w); /* fp->_w -= w; */ fp->_p += w; - old_p = fp->_p; - if (__fflush(fp) == EOF) { - if (old_p == fp->_p) - fp->_p -= w; + if (__fflush(fp)) goto err; - } } else if (s >= (w = fp->_bf._size)) { w = _swrite(fp, p, w); if (w <= 0) diff --git a/lib/libc/stdio/wbuf.c b/lib/libc/stdio/wbuf.c index 7153350c99f1..9aab55a207cb 100644 --- a/lib/libc/stdio/wbuf.c +++ b/lib/libc/stdio/wbuf.c @@ -49,7 +49,6 @@ static char sccsid[] = "@(#)wbuf.c 8.1 (Berkeley) 6/4/93"; int __swbuf(int c, FILE *fp) { - unsigned char *old_p; int n; /* @@ -85,15 +84,8 @@ __swbuf(int c, FILE *fp) } fp->_w--; *fp->_p++ = c; - old_p = fp->_p; - if (++n == fp->_bf._size || (fp->_flags & __SLBF && c == '\n')) { - if (__fflush(fp) != 0) { - if (fp->_p == old_p) { - fp->_p--; - fp->_w++; - } + if (++n == fp->_bf._size || (fp->_flags & __SLBF && c == '\n')) + if (__fflush(fp) != 0) return (EOF); - } - } return (c); }