From nobody Tue Nov 07 18:44:08 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 4SPxvY36zPz4yxPc; Tue, 7 Nov 2023 18:44:09 +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 4SPxvY0X2Sz4MtS; Tue, 7 Nov 2023 18:44:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699382649; 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=KZxEroMRjPMmj/ozMY5kD4sENh6fXdaM+Ukq81xOHGs=; b=X43DhPyGb4ezAEka76VWn8fWTw3KSEfKbjiJj0BO/67T804EuJ0KvSsdPo+iM3wh0MX2G/ I6Qzy9c53f2dH8+pEXqSXGPqdV3SIKi70VZIK5Pu+MVLvLrX5c4srxds7aypqLECZP3kV3 LYyUh9UraEPYkmoCf93n9cEXoQ24c4QvdzWTcjL0lLGrizihw5vdAMDgiCsR07bGpieHad hNeMpfgCdksFPxsVyF5pFB5YW5CrV5o5GlWX62ztUXoH/pJcGb/l2h/S5GlLG8DWjA8Te4 jJbsauNBnv/Rooj2bukAEng8e98gBmPnZ2R+gxN9nkAQrAVoObr3ddI4QhtrNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699382649; 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=KZxEroMRjPMmj/ozMY5kD4sENh6fXdaM+Ukq81xOHGs=; b=KZJh5R1t+pN0fd3P3ZWZXxeOs5idFUj30l46gD67CXDqaL9PsHPOGHSNZBY9BqmO6gNGy9 Rf73zQd1fhKjjLxpxnYRtmlJhggtPwnqS1aONpOc7pZbHU2v9IpveOraLzo1Z3iFnDikcD dGweI+TlVJruWuwv+0R8TT+B7ymdyvkhxZm2yGizJcqlxPT2XeaA1YrBegLl63kabG9UUt TXxaxoZRD76JNsPzA8oij4UWQobMoLL3lsh2r3m2h2vsZoNdyiXII3N+H8Ohh8kzo5T3wc Oh2EkUBzrB1XbFgnsEpS/2DW/Df7B6nmGhQI8ceJH4pAnbgZzyLP+Hjcr+WNeA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1699382649; a=rsa-sha256; cv=none; b=sJFkigeT2huuLQy/JeySIlrAvT+W+kdjbn915jwADj650HBt0vIca3usFjunItogbukdOh ssOSmzUJNVUNsCryZyUlWP2JDBPJ3Xpb+wZcYu4ySoa92NV5acBZNODQr7M2l7xSfDxkn7 cMFBay2gf12dvr9lJwZF6tf45Lq0IEIe9rS0Gzj6ogkTdTBr2WphHyZuil7iiazNEmaKn3 KYAUVOaJfZbC0nAhMf6W5BkAkXY8tZINj7nIM0qHEvb6DG+zz6T93idhrQYIK4uxlanf6h iQA5Nr18Te7o7KegITvnua+7ei1qC31exo61BC/FKpmcbpeKH4MQt07bHEM8TA== 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 4SPxvX6ScVz11tS; Tue, 7 Nov 2023 18:44:08 +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 3A7Ii8JX070887; Tue, 7 Nov 2023 18:44:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3A7Ii8Go070884; Tue, 7 Nov 2023 18:44:08 GMT (envelope-from git) Date: Tue, 7 Nov 2023 18:44:08 GMT Message-Id: <202311071844.3A7Ii8Go070884@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 0b7939d725ba - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 0b7939d725ba0ca903c5f8a3ca6d74347eb88690 Auto-Submitted: auto-generated The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=0b7939d725ba0ca903c5f8a3ca6d74347eb88690 commit 0b7939d725ba0ca903c5f8a3ca6d74347eb88690 Author: Ed Maste AuthorDate: 2023-11-07 14:16:13 +0000 Commit: Ed Maste CommitDate: 2023-11-07 18:41:55 +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 (cherry picked from commit 4e0e01bf6511c28212d7dff94fe131a502e13026) (cherry picked from commit d2c65a1c948648f11342274029a3f18b90aa58d2) Approved by: so --- 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 dd170ee3d7dc..acf8f72076cf 100644 --- a/lib/libc/stdio/fvwrite.c +++ b/lib/libc/stdio/fvwrite.c @@ -52,7 +52,6 @@ int __sfvwrite(FILE *fp, struct __suio *uio) { size_t len; - unsigned char *old_p; char *p; struct __siov *iov; int w, s; @@ -136,12 +135,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); @@ -180,12 +175,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 808cfa588cfb..558322b4001e 100644 --- a/lib/libc/stdio/wbuf.c +++ b/lib/libc/stdio/wbuf.c @@ -50,7 +50,6 @@ static char sccsid[] = "@(#)wbuf.c 8.1 (Berkeley) 6/4/93"; int __swbuf(int c, FILE *fp) { - unsigned char *old_p; int n; /* @@ -86,15 +85,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); }