From nobody Sat Aug 1 03:35:27 2026 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 4hBpVY1JbLz6mlkV for ; Sat, 01 Aug 2026 03:35:33 +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 "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hBpVX47Q0z3F1m for ; Sat, 01 Aug 2026 03:35:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1785555332; 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=2Tf8GXx6Nv6Cfuxrus2rUbKSZ34fZ5NqvHM5VtMGvgE=; b=QzF/Oj2gzZiaU4FXutaD0k6cz6uDPvRmRxBfHJDhRpgQWttvrP4hUi/Z408dmCCxfuzlr0 JJvDG1dYteUPT6TqwzreP1D8Fd3U7oCKFvQAeQ6e1UIgYmaZBOydClMc6ERbKiCCoIszhF 0ZkQ4YmrRi+8TLOuhijeakZFC3EoME0X4g4uS4nFtGHDuLCf1BSX5TstWRWG6hHd3QPKR9 hANlQrP0ZdDIScV3ARHo0pOoeSf5Mq34PYIoo/N780gZSnd6b9Y0hFNaUkzGMgrSFrv3Sw dY++/utKrA4lJo4xuYS0hqwjJ6QRmFLnaIB4GqOmsPWcHfjSAajjCMK/x44HDg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1785555332; a=rsa-sha256; cv=none; b=FuptVl5mh0jXqZHhvW5eU69h/dbdY1nBlpYMnQdAWv6upIj7WLLzzrSy2UOHu56EMBsnu+ zYuyOKn6XVFazdyI9BXAiH+XF3enfOGHq9jUnl5t3YMsBb2YgWNXBeAHiyjK3t2aXo1ufG 3Zs7krOqWYOyEJs3w/wCeUk9zCuF5xKfCJh+dj2gQxnwx6gh5U+CaC0W5oD5YbsJQLQVhA R2B0tw+L37UJybp4YV6nC14JfDtOk90uPMeS8SFvRu5Hw8mzt+lge/7XN0I9Bexxbz1+we C2A8YGJmiewO0zypvbn7jch+2i+8lSPcVYs76/rfT+2V4pm9KE4zwQivwnr4qw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1785555332; 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=2Tf8GXx6Nv6Cfuxrus2rUbKSZ34fZ5NqvHM5VtMGvgE=; b=Uo9psr/+dAQ4BsjQlGWM/6BlR91QJ47ZiB/G7ainW0bPCafvIX6gsaR6jTAPEHf3uPt2hx 1fzuGSnEmDlBLma/5sqSjdrWaf2uR6yZlvOam/fG1PKbss94N+0uLiJN8FNit0GAXuKzYa VQwvOm5yH7SRg5P2N1qETj5fG1T2I9VQxV0LdZo/oOI5o7heBdsh2NttLGQVGq7s7ZvTsQ 9WD2w7EWmgoaXof0eyCIZ9NVg1xydIO24ONEy1R/q4DGwKC+Tot/g2uqBKijCvKgatFMsa zWDNnDj22w+KRfqgA4LhNFLVzx5XlM9S9NUXIWxziKNVZvVfL/y4wYgY1eC4iw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hBpVX38jTzD3c for ; Sat, 01 Aug 2026 03:35:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 35da7 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 01 Aug 2026 03:35:27 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: 28327c58ee6d - main - stdio: *memstream: slightly streamline growth function 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 28327c58ee6de7ddbdcf0e56352b257d37f2103d Auto-Submitted: auto-generated Date: Sat, 01 Aug 2026 03:35:27 +0000 Message-Id: <6a6d697f.35da7.6651c5db@gitrepo.freebsd.org> The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=28327c58ee6de7ddbdcf0e56352b257d37f2103d commit 28327c58ee6de7ddbdcf0e56352b257d37f2103d Author: Kyle Evans AuthorDate: 2026-08-01 03:34:37 +0000 Commit: Kyle Evans CommitDate: 2026-08-01 03:34:37 +0000 stdio: *memstream: slightly streamline growth function Inverting the condition after realloc*() is a minor cleanup, but makes the success path a little cleaner to ease a future change. Reviewed by: des, jhb Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D57353 --- lib/libc/stdio/open_memstream.c | 17 ++++++++--------- lib/libc/stdio/open_wmemstream.c | 16 +++++++--------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/lib/libc/stdio/open_memstream.c b/lib/libc/stdio/open_memstream.c index 371022adf6b3..29de688376bf 100644 --- a/lib/libc/stdio/open_memstream.c +++ b/lib/libc/stdio/open_memstream.c @@ -62,17 +62,16 @@ memstream_grow(struct memstream *ms, fpos_t newoff) newsize = newoff; if (newsize > ms->len) { buf = realloc(*ms->bufp, newsize + 1); - if (buf != NULL) { + if (buf == NULL) + return (0); + #ifdef DEBUG - fprintf(stderr, "MS: %p growing from %zd to %zd\n", - ms, ms->len, newsize); + fprintf(stderr, "MS: %p growing from %zd to %zd\n", + ms, ms->len, newsize); #endif - memset(buf + ms->len + 1, 0, newsize - ms->len); - *ms->bufp = buf; - ms->len = newsize; - return (1); - } - return (0); + memset(buf + ms->len + 1, 0, newsize - ms->len); + *ms->bufp = buf; + ms->len = newsize; } return (1); } diff --git a/lib/libc/stdio/open_wmemstream.c b/lib/libc/stdio/open_wmemstream.c index 213d61fcd4dd..0bed4cff5d11 100644 --- a/lib/libc/stdio/open_wmemstream.c +++ b/lib/libc/stdio/open_wmemstream.c @@ -63,17 +63,15 @@ wmemstream_grow(struct wmemstream *ms, fpos_t newoff) newsize = newoff; if (newsize > ms->len) { buf = reallocarray(*ms->bufp, newsize + 1, sizeof(wchar_t)); - if (buf != NULL) { + if (buf == NULL) + return (0); #ifdef DEBUG - fprintf(stderr, "WMS: %p growing from %zd to %zd\n", - ms, ms->len, newsize); + fprintf(stderr, "WMS: %p growing from %zd to %zd\n", + ms, ms->len, newsize); #endif - wmemset(buf + ms->len + 1, 0, newsize - ms->len); - *ms->bufp = buf; - ms->len = newsize; - return (1); - } - return (0); + wmemset(buf + ms->len + 1, 0, newsize - ms->len); + *ms->bufp = buf; + ms->len = newsize; } return (1); }