From 49202df2dae60986f5a4187706e0f447f20d13b1 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Mon, 28 Oct 2024 15:26:01 +0100 Subject: [PATCH] fixup --- src/file.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/file.cpp b/src/file.cpp index 9e36518414..8d5c800cb9 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -91,6 +91,10 @@ see LICENSE file. #endif // posix part +#if TORRENT_USE_PWRITEV && defined TORRENT_BSD +#include // for pwritev() and iovec +#endif + #include "libtorrent/aux_/disable_warnings_pop.hpp" #include "libtorrent/aux_/alloca.hpp" @@ -99,11 +103,11 @@ namespace libtorrent::aux { #if TORRENT_USE_PWRITEV namespace { - span advance_iovec(span bufs, std::size_t advance_bytes) + span advance_iovec(span bufs, ssize_t advance_bytes) { while (advance_bytes > 0) { - if (bufs.front().iov_len <= advance_bytes) + if (static_cast(bufs.front().iov_len) <= advance_bytes) { advance_bytes -= bufs.front().iov_len; bufs = bufs.subspan(1); @@ -128,11 +132,11 @@ namespace { for (int i = 0; i < bufs.size(); ++i) { vec[i].iov_base = const_cast(bufs[i].data()); - vec[i].iov_len = bufs[i].size(); + vec[i].iov_len = static_cast(bufs[i].size()); } do { - auto const r = ::pwritev(handle, vec.data(), vec.size(), file_offset); + ssize_t const r = ::pwritev(handle, vec.data(), vec.size(), file_offset); if (r == 0) { ec = boost::asio::error::eof; @@ -162,7 +166,7 @@ namespace { int ret = 0; // TODO: if we have more than 1 buffer, coalesce into a single buffer // and a single call - for (auto const b : bufs) + for (auto const& b : bufs) { int r = pwrite_all(handle, b, file_offset, ec); if (ec) return -1;