From nobody Tue Nov 07 17:58:59 2023 X-Original-To: dev-commits-src-branches@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 4SPwvR72xdz4ylvj; Tue, 7 Nov 2023 17:58:59 +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 4SPwvR6R43z4GDy; Tue, 7 Nov 2023 17:58:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699379939; 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=8ILRvpK3OeTyuvY1d4hqP1l7RwDElm6GOLltn/ihFVE=; b=pqAxDKekr1JNomEUJhPRL+9FKaq2NsLbkNK6jMzMCGKzj45upAXHcCRAOUrT1FKL24Ixtc m8pdH55YCFtO+qiYONkaWUsCAhVA5nfqz+gj9mei1aVW2Pl06qqAChNjLBf5iTXp7kcl9Z Zb05cDYuumHEzxwsZckgp1taoxyDx9emC7ADmEtKqkD2V0bqV45VLul1qT79PwsfLZpIIX h/dsSa35X5ju4jjkhkcnFzyL/VYgb3YWHzLN+EqDNDi5mCC+KPbJyibR1Sd4qvTz4T0ybq nChZV1h4H7F6sbSnIgdWlr/DRQ5CER8FoDVoabtVxA1/JP6KEjIxicY+zDEUGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699379939; 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=8ILRvpK3OeTyuvY1d4hqP1l7RwDElm6GOLltn/ihFVE=; b=txYijMGb0AfZ77Zg8vKXa5koCnk1WD+19nsanbCaQEiNQKczKvx4Gr5DfarQ7L0tCBel8K /cBGeDRHLwN7vMZ1SKhLIowZEYYhQ8jb4hfJsa7yZD+op+6IDqJFlqbkYBtD5A7zXr5E81 HxpttJR7Stv76aMoXykvK1z7HC4iR5hUQQlQ405k/sXuRhNMLgbj0CdNPP/rQBKE/CO1yI hqSrksd3X11DdwSnE47pzb+Im+5Qo1gdSxLCrrlgIr04sUnEH/YhgJVSAZdJjFPUxexGMT CD4db4iJjKJrEitYQwUStJA3lN2ADBeqhsWlrVHWJYgKe6ngx1+B71uzb61Fvw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1699379939; a=rsa-sha256; cv=none; b=jhzB5fxWPMdmboLrNve2pbCG71TPd7FF0EnN0YsYCrxvC0b17wPCZFzOM+ujm2C/WgsceM U2bjoedQEMaamSd09+j1swLB/90Mp4rfPTBaNG22qrgNiLNFmkT7p9nJ3IOs81ve+UU03u +KxvwC2gD7u7+3KiFYU+cQPmV9EJ7bAwzlzXm6MuTcrrHEzSqFp39t6icCZslquK5/5qCy Pk4353J7kN+snYYwH/n4JiCo0ozXp/reZIJ14s66KA3PytR/5WCPGPo2K0UEcKatNdLgho vOZX4J5G7K60ckK4zhIn2XZr/cnI+4jqm9+zFAE0Q5D54U7+GrfEP/3tvLsRIA== 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 4SPwvR5Fpnz10nw; Tue, 7 Nov 2023 17:58:59 +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 3A7HwxoS087535; Tue, 7 Nov 2023 17:58:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3A7HwxTd087532; Tue, 7 Nov 2023 17:58:59 GMT (envelope-from git) Date: Tue, 7 Nov 2023 17:58:59 GMT Message-Id: <202311071758.3A7HwxTd087532@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: d2c65a1c9486 - stable/14 - fflush: correct buffer handling in __sflush List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/14 X-Git-Reftype: branch X-Git-Commit: d2c65a1c948648f11342274029a3f18b90aa58d2 Auto-Submitted: auto-generated The branch stable/14 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=d2c65a1c948648f11342274029a3f18b90aa58d2 commit d2c65a1c948648f11342274029a3f18b90aa58d2 Author: Ed Maste AuthorDate: 2023-11-07 14:16:13 +0000 Commit: Ed Maste CommitDate: 2023-11-07 17:31: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 (cherry picked from commit 4e0e01bf6511c28212d7dff94fe131a502e13026) 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); }