From c9131ce6e73bb2a643a3a4d1f6936fb46db51d3c Mon Sep 17 00:00:00 2001 From: "Andrew J. Hesford" 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..6edae23 100644 --- a/io/copy.h +++ b/io/copy.h @@ -155,7 +155,8 @@ void CopyHelper::callbackCopy(NativeFileStream &input, NativeFileStr output.flush(); const auto totalBytes = static_cast(count); while (count) { - const auto bytesCopied = ::sendfile64(output.fileDescriptor(), input.fileDescriptor(), nullptr, std::min(count, bufferSize)); + const auto bytesToCopy = static_cast(std::min(count, static_cast(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))); }