From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 9DFB21582EF for ; Sun, 09 Mar 2025 18:09:26 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id 84A5834310B for ; Sun, 09 Mar 2025 18:09:26 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id CD2A61103A8; Sun, 09 Mar 2025 18:09:19 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id C1FAB1103A8 for ; Sun, 09 Mar 2025 18:09:19 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (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) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 5003C3430BF for ; Sun, 09 Mar 2025 18:09:19 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id AEDF328B0 for ; Sun, 09 Mar 2025 18:09:17 +0000 (UTC) From: "Mike Gilbert" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Gilbert" Message-ID: <1741462564.ff39a244215a4ee206bff0a78deb702d9c9702dc.floppym@gentoo> Subject: [gentoo-commits] proj/sandbox:master commit in: libsbutil/ X-VCS-Repository: proj/sandbox X-VCS-Files: libsbutil/sb_write_fd.c X-VCS-Directories: libsbutil/ X-VCS-Committer: floppym X-VCS-Committer-Name: Mike Gilbert X-VCS-Revision: ff39a244215a4ee206bff0a78deb702d9c9702dc X-VCS-Branch: master Date: Sun, 09 Mar 2025 18:09:17 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: b52ce67d-8fe6-44ea-9eb2-988fe0821dd0 X-Archives-Hash: 797827ad7d0b24f4753d57385f65fd02 commit: ff39a244215a4ee206bff0a78deb702d9c9702dc Author: Mike Gilbert gentoo org> AuthorDate: Sat Mar 8 19:22:18 2025 +0000 Commit: Mike Gilbert gentoo org> CommitDate: Sat Mar 8 19:36:04 2025 +0000 URL: https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=ff39a244 libsbutil: sb_write_fd: use a small buffer on the stack Signed-off-by: Mike Gilbert gentoo.org> libsbutil/sb_write_fd.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libsbutil/sb_write_fd.c b/libsbutil/sb_write_fd.c index f19d7de..fdcd34e 100644 --- a/libsbutil/sb_write_fd.c +++ b/libsbutil/sb_write_fd.c @@ -12,16 +12,15 @@ int sb_copy_file_to_fd(const char *file, int ofd) { + char buf[128]; int ret = -1; int ifd = sb_open(file, O_RDONLY|O_CLOEXEC, 0); if (ifd == -1) return ret; - size_t pagesz = getpagesize(); - char *buf = xmalloc(pagesz); while (1) { - size_t len = sb_read(ifd, buf, pagesz); + size_t len = sb_read(ifd, buf, sizeof(buf)); if (len == -1) goto error; else if (!len) @@ -37,6 +36,5 @@ int sb_copy_file_to_fd(const char *file, int ofd) ret = 0; error: sb_close(ifd); - free(buf); return ret; }