From 7df9944604e2ef92abce20c00ea265793b151261 Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Tue, 1 Oct 2024 12:23:17 +0200 Subject: Enable bugprone-narrowing-conversions check --- src/buildtool/file_system/file_system_manager.hpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/buildtool/file_system/file_system_manager.hpp') diff --git a/src/buildtool/file_system/file_system_manager.hpp b/src/buildtool/file_system/file_system_manager.hpp index f035e407..d506f4b9 100644 --- a/src/buildtool/file_system/file_system_manager.hpp +++ b/src/buildtool/file_system/file_system_manager.hpp @@ -1185,14 +1185,14 @@ class FileSystemManager { /// Non-zero return values indicate errors, which can be decoded using /// \ref ErrorToString. class LowLevel { - static constexpr ssize_t kDefaultChunkSize = 1024 * 32; + static constexpr std::size_t kDefaultChunkSize = 1024 * 32; static constexpr int kWriteFlags = O_WRONLY | O_CREAT | O_TRUNC; // NOLINT static constexpr int kWritePerms = // 644 S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; // NOLINT public: - template + template [[nodiscard]] static auto CopyFile(char const* src, char const* dst, bool skip_existing) noexcept -> int { @@ -1238,18 +1238,19 @@ class FileSystemManager { return 0; } - template + template [[nodiscard]] static auto WriteFile(char const* content, - ssize_t size, + std::size_t size, char const* file) noexcept -> int { auto out = FdOpener{file, kWriteFlags, kWritePerms}; if (out.fd == -1) { return PackError(ERROR_OPEN_OUTPUT, errno); } - ssize_t pos{}; + std::size_t pos = 0; while (pos < size) { auto const write_len = std::min(kChunkSize, size - pos); - auto len = write(out.fd, content + pos, write_len); // NOLINT + auto const len = + write(out.fd, content + pos, write_len); // NOLINT if (len < 0) { return PackError(ERROR_WRITE_OUTPUT, errno); } -- cgit v1.2.3