void-packages/srcpkgs/cpp-utilities/patches/fix-32bit-sendfile.patch
2023-04-06 15:21:48 -04:00

26 lines
1.1 KiB
Diff

From 92757f253113515e96bb4ddbb4627b314ada6b58 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Thu, 6 Apr 2023 11:33:41 -0400
Subject: [PATCH] Fix use of `sendfile()` on 32-bit systems
---
io/copy.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/io/copy.h b/io/copy.h
index 4abbe8d..0635a8e 100644
--- a/io/copy.h
+++ b/io/copy.h
@@ -155,7 +155,8 @@ void CopyHelper<bufferSize>::callbackCopy(NativeFileStream &input, NativeFileStr
output.flush();
const auto totalBytes = static_cast<std::streamoff>(count);
while (count) {
- const auto bytesCopied = ::sendfile64(output.fileDescriptor(), input.fileDescriptor(), nullptr, std::min(count, bufferSize));
+ const auto bytesToCopy = static_cast<std::size_t>(std::min(count, static_cast<std::uint64_t>(bufferSize)));
+ const auto bytesCopied = ::sendfile64(output.fileDescriptor(), input.fileDescriptor(), nullptr, bytesToCopy);
if (bytesCopied < 0) {
throw std::ios_base::failure(argsToString("sendfile64() failed: ", std::strerror(errno)));
}
--
2.40.0