summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/build_engine/target_map/target_map.cpp5
-rw-r--r--src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp2
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_api.cpp10
-rw-r--r--src/buildtool/execution_engine/executor/executor.hpp3
-rw-r--r--src/buildtool/file_system/file_system_manager.hpp13
-rw-r--r--src/buildtool/graph_traverser/graph_traverser.hpp10
-rw-r--r--src/buildtool/main/archive.cpp6
-rw-r--r--src/buildtool/main/serve.cpp5
8 files changed, 32 insertions, 22 deletions
diff --git a/src/buildtool/build_engine/target_map/target_map.cpp b/src/buildtool/build_engine/target_map/target_map.cpp
index 27ffc1a4..9b0d62a1 100644
--- a/src/buildtool/build_engine/target_map/target_map.cpp
+++ b/src/buildtool/build_engine/target_map/target_map.cpp
@@ -15,6 +15,7 @@
#include "src/buildtool/build_engine/target_map/target_map.hpp"
#include <algorithm>
+#include <cstdint>
#include <memory>
#include <set>
#include <sstream>
@@ -352,8 +353,8 @@ void withDependencies(
std::size_t const b,
auto* deps) {
std::transform(
- dependency_values.begin() + a,
- dependency_values.begin() + b,
+ dependency_values.begin() + static_cast<std::int64_t>(a),
+ dependency_values.begin() + static_cast<std::int64_t>(b),
std::back_inserter(*deps),
[](auto dep) { return (*(dep))->GraphInformation().Node(); });
};
diff --git a/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp b/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp
index 0bcd11cc..4a29f5f7 100644
--- a/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp
+++ b/src/buildtool/execution_api/bazel_msg/bazel_msg_factory.cpp
@@ -204,7 +204,7 @@ struct DirectoryNodeBundle final {
auto duration = std::make_unique<google::protobuf::Duration>();
duration->set_seconds(sec.count());
- duration->set_nanos(nanos.count());
+ duration->set_nanos(static_cast<int>(nanos.count()));
bazel_re::Action msg;
msg.set_do_not_cache(request.skip_action_cache);
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
index c5d77194..8dbd026e 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
@@ -151,14 +151,16 @@ namespace {
transmitted_bytes += chunk_digest.size();
}
}
- double transmission_factor =
- (total_size > 0) ? 100.0 * transmitted_bytes / total_size
- : 100.0;
+ double transmission_factor = 0.;
+ if (total_size > 0) {
+ transmission_factor = static_cast<double>(transmitted_bytes) /
+ static_cast<double>(total_size);
+ }
return fmt::format(
"Blob splitting saved {} bytes ({:.2f}%) of network traffic "
"when fetching {}.\n",
total_size - transmitted_bytes,
- 100.0 - transmission_factor,
+ transmission_factor,
artifact_info.ToString());
});
diff --git a/src/buildtool/execution_engine/executor/executor.hpp b/src/buildtool/execution_engine/executor/executor.hpp
index 9428a6e4..0018cafc 100644
--- a/src/buildtool/execution_engine/executor/executor.hpp
+++ b/src/buildtool/execution_engine/executor/executor.hpp
@@ -697,7 +697,8 @@ class ExecutorImpl {
[[nodiscard]] static inline auto ScaleTime(std::chrono::milliseconds t,
double f)
-> std::chrono::milliseconds {
- return std::chrono::milliseconds(std::lround(t.count() * f));
+ return std::chrono::milliseconds(
+ std::lround(static_cast<double>(t.count()) * f));
}
[[nodiscard]] static inline auto MergeProperties(
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 <ssize_t kChunkSize = kDefaultChunkSize>
+ template <std::size_t kChunkSize = kDefaultChunkSize>
[[nodiscard]] static auto CopyFile(char const* src,
char const* dst,
bool skip_existing) noexcept -> int {
@@ -1238,18 +1238,19 @@ class FileSystemManager {
return 0;
}
- template <ssize_t kChunkSize = kDefaultChunkSize>
+ template <std::size_t kChunkSize = kDefaultChunkSize>
[[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);
}
diff --git a/src/buildtool/graph_traverser/graph_traverser.hpp b/src/buildtool/graph_traverser/graph_traverser.hpp
index 51cb23d6..2cc47911 100644
--- a/src/buildtool/graph_traverser/graph_traverser.hpp
+++ b/src/buildtool/graph_traverser/graph_traverser.hpp
@@ -17,6 +17,7 @@
#include <algorithm>
#include <cstddef>
+#include <cstdint>
#include <cstdlib>
#include <filesystem>
#include <functional>
@@ -506,12 +507,13 @@ class GraphTraverser {
}
// split extra artifacts' nodes from artifact nodes
+ auto const itExtra =
+ std::next(artifact_nodes->begin(),
+ static_cast<std::int64_t>(output_paths.size()));
auto extra_nodes = std::vector<DependencyGraph::ArtifactNode const*>{
- std::make_move_iterator(artifact_nodes->begin() +
- output_paths.size()),
+ std::make_move_iterator(itExtra),
std::make_move_iterator(artifact_nodes->end())};
- artifact_nodes->erase(artifact_nodes->begin() + output_paths.size(),
- artifact_nodes->end());
+ artifact_nodes->erase(itExtra, artifact_nodes->end());
return std::make_tuple(std::move(output_paths),
std::move(*artifact_nodes),
diff --git a/src/buildtool/main/archive.cpp b/src/buildtool/main/archive.cpp
index d4e720b2..13d377ca 100644
--- a/src/buildtool/main/archive.cpp
+++ b/src/buildtool/main/archive.cpp
@@ -74,7 +74,8 @@ auto add_to_archive(HashFunction::Type hash_type,
std::unique_ptr<archive_entry, decltype(&archive_entry_cleanup)>
entry{archive_entry_new(), archive_entry_cleanup};
archive_entry_set_pathname(entry.get(), location.string().c_str());
- archive_entry_set_size(entry.get(), payload->size());
+ archive_entry_set_size(entry.get(),
+ static_cast<la_int64_t>(payload->size()));
archive_entry_set_filetype(entry.get(), AE_IFREG);
archive_entry_set_perm(entry.get(),
artifact.type == ObjectType::Executable
@@ -88,7 +89,8 @@ auto add_to_archive(HashFunction::Type hash_type,
std::unique_ptr<archive_entry, decltype(&archive_entry_cleanup)>
entry{archive_entry_new(), archive_entry_cleanup};
archive_entry_set_pathname(entry.get(), location.string().c_str());
- archive_entry_set_size(entry.get(), payload->size());
+ archive_entry_set_size(entry.get(),
+ static_cast<la_int64_t>(payload->size()));
archive_entry_set_filetype(entry.get(), AE_IFLNK);
archive_entry_set_symlink(entry.get(), payload->c_str());
archive_entry_set_perm(entry.get(), kDefaultPerm);
diff --git a/src/buildtool/main/serve.cpp b/src/buildtool/main/serve.cpp
index ecd82f38..29bff253 100644
--- a/src/buildtool/main/serve.cpp
+++ b/src/buildtool/main/serve.cpp
@@ -423,7 +423,7 @@ void ReadJustServeConfig(gsl::not_null<CommandLineArguments*> const& clargs) {
jobs->ToString());
std::exit(kExitFailure);
}
- clargs->common.jobs = jobs->Number();
+ clargs->common.jobs = static_cast<std::size_t>(jobs->Number());
}
// read build options
auto build_args = serve_config["build"];
@@ -448,7 +448,8 @@ void ReadJustServeConfig(gsl::not_null<CommandLineArguments*> const& clargs) {
build_jobs->ToString());
std::exit(kExitFailure);
}
- clargs->build.build_jobs = build_jobs->Number();
+ clargs->build.build_jobs =
+ static_cast<std::size_t>(build_jobs->Number());
}
else {
clargs->build.build_jobs = clargs->common.jobs;