summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Reiche <oliver.reiche@huawei.com>2024-12-16 13:39:36 +0100
committerOliver Reiche <oliver.reiche@huawei.com>2024-12-19 16:17:46 +0100
commite2b6d9d3c41d162517019ee0bf9147e398a5b1fa (patch)
tree248f0a50ec1183836a8257580779cac79ccf51f5
parent827f05a53cb831bd54166ee812752ae3cce2b69b (diff)
downloadjustbuild-e2b6d9d3c41d162517019ee0bf9147e398a5b1fa.tar.gz
Fix cause of minor warnings
-rw-r--r--src/buildtool/common/remote/port.hpp4
-rw-r--r--src/buildtool/common/remote/remote_common.hpp9
-rw-r--r--src/buildtool/execution_api/remote/bazel/bazel_api.cpp2
-rw-r--r--src/buildtool/execution_engine/executor/executor.hpp2
-rw-r--r--src/buildtool/file_system/file_system_manager.hpp9
-rw-r--r--src/buildtool/file_system/symlinks_map/resolve_symlinks_map.cpp2
-rw-r--r--src/buildtool/main/main.cpp14
-rw-r--r--src/buildtool/storage/config.hpp2
-rw-r--r--src/other_tools/just_mr/setup_utils.cpp2
-rw-r--r--src/other_tools/utils/content.hpp10
-rw-r--r--src/utils/cpp/transformed_range.hpp2
-rw-r--r--test/buildtool/build_engine/expression/expression.test.cpp1
-rw-r--r--test/buildtool/file_system/resolve_symlinks_map.test.cpp4
-rw-r--r--test/buildtool/graph_traverser/graph_traverser.test.hpp46
-rw-r--r--test/utils/large_objects/large_object_utils.cpp4
15 files changed, 59 insertions, 54 deletions
diff --git a/src/buildtool/common/remote/port.hpp b/src/buildtool/common/remote/port.hpp
index 3cba855d..bfd4fa80 100644
--- a/src/buildtool/common/remote/port.hpp
+++ b/src/buildtool/common/remote/port.hpp
@@ -30,7 +30,7 @@
struct PortTag : TypeSafeArithmeticTag<std::uint16_t> {};
using Port = TypeSafeArithmetic<PortTag>;
-[[nodiscard]] static auto ParsePort(int const port_num) noexcept
+[[nodiscard]] static inline auto ParsePort(int const port_num) noexcept
-> std::optional<Port> {
try {
static constexpr int kMaxPortNumber{
@@ -44,7 +44,7 @@ using Port = TypeSafeArithmetic<PortTag>;
return std::nullopt;
}
-[[nodiscard]] static auto ParsePort(std::string const& port) noexcept
+[[nodiscard]] static inline auto ParsePort(std::string const& port) noexcept
-> std::optional<Port> {
try {
auto port_num = std::stoi(port);
diff --git a/src/buildtool/common/remote/remote_common.hpp b/src/buildtool/common/remote/remote_common.hpp
index cf35d9fc..0d41ad95 100644
--- a/src/buildtool/common/remote/remote_common.hpp
+++ b/src/buildtool/common/remote/remote_common.hpp
@@ -43,8 +43,8 @@ struct ServerAddress {
using ExecutionProperties = std::map<std::string, std::string>;
using DispatchEndpoint = std::pair<ExecutionProperties, ServerAddress>;
-[[nodiscard]] static auto ParseAddress(std::string const& address) noexcept
- -> std::optional<ServerAddress> {
+[[nodiscard]] static inline auto ParseAddress(
+ std::string const& address) noexcept -> std::optional<ServerAddress> {
std::istringstream iss(address);
std::string host;
std::string port;
@@ -58,7 +58,8 @@ using DispatchEndpoint = std::pair<ExecutionProperties, ServerAddress>;
return std::nullopt;
}
-[[nodiscard]] static auto ParseProperty(std::string const& property) noexcept
+[[nodiscard]] static inline auto ParseProperty(
+ std::string const& property) noexcept
-> std::optional<std::pair<std::string, std::string>> {
std::istringstream pss(property);
std::string key;
@@ -69,7 +70,7 @@ using DispatchEndpoint = std::pair<ExecutionProperties, ServerAddress>;
return std::make_pair(key, val);
}
-[[nodiscard]] static auto ParseDispatch(
+[[nodiscard]] static inline auto ParseDispatch(
std::string const& dispatch_info) noexcept
-> expected<std::vector<DispatchEndpoint>, std::string> {
nlohmann::json dispatch;
diff --git a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
index d523fbed..3a5fd860 100644
--- a/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
+++ b/src/buildtool/execution_api/remote/bazel/bazel_api.cpp
@@ -183,7 +183,7 @@ namespace {
return std::nullopt;
}
return BazelBlobContainer{std::move(blobs)};
-};
+}
} // namespace
diff --git a/src/buildtool/execution_engine/executor/executor.hpp b/src/buildtool/execution_engine/executor/executor.hpp
index 6983a4ac..db204fe6 100644
--- a/src/buildtool/execution_engine/executor/executor.hpp
+++ b/src/buildtool/execution_engine/executor/executor.hpp
@@ -682,7 +682,7 @@ class ExecutorImpl {
}
auto const has_err = response->HasStdErr();
auto const has_out = response->HasStdOut();
- auto build_message = [has_err, has_out, &logger, &action, &response]() {
+ auto build_message = [has_err, has_out, &action, &response]() {
using namespace std::string_literals;
auto message = ""s;
bool has_both = has_err and has_out;
diff --git a/src/buildtool/file_system/file_system_manager.hpp b/src/buildtool/file_system/file_system_manager.hpp
index e5e73415..47f39ee9 100644
--- a/src/buildtool/file_system/file_system_manager.hpp
+++ b/src/buildtool/file_system/file_system_manager.hpp
@@ -1229,9 +1229,10 @@ class FileSystemManager {
ssize_t wlen{};
ssize_t written_len{};
while (written_len < len and
- (wlen = write(out.fd,
- buf.data() + written_len, // NOLINT
- len - written_len)) > 0) {
+ (wlen = write(
+ out.fd,
+ buf.data() + written_len, // NOLINT
+ static_cast<std::size_t>(len - written_len))) > 0) {
written_len += wlen;
}
if (wlen < 0) {
@@ -1260,7 +1261,7 @@ class FileSystemManager {
if (len < 0) {
return PackError(ERROR_WRITE_OUTPUT, errno);
}
- pos += len;
+ pos += static_cast<std::size_t>(len);
}
return 0;
}
diff --git a/src/buildtool/file_system/symlinks_map/resolve_symlinks_map.cpp b/src/buildtool/file_system/symlinks_map/resolve_symlinks_map.cpp
index 16556153..eeca5800 100644
--- a/src/buildtool/file_system/symlinks_map/resolve_symlinks_map.cpp
+++ b/src/buildtool/file_system/symlinks_map/resolve_symlinks_map.cpp
@@ -198,7 +198,7 @@ void ResolveKnownEntry(GitObjectToResolve const& obj,
GitRepo::tree_entries_t entries{};
auto num = resolved_entries.size();
entries.reserve(num);
- for (auto i = 0; i < num; ++i) {
+ for (std::size_t i = 0; i < num; ++i) {
auto const& p = children_info[i].rel_path;
entries[*FromHexString(resolved_entries[i]->id)]
.emplace_back(
diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp
index 14da6846..a7bd14f8 100644
--- a/src/buildtool/main/main.cpp
+++ b/src/buildtool/main/main.cpp
@@ -26,6 +26,7 @@
#include <optional>
#include <set>
#include <string>
+#include <tuple>
#include <utility>
#include <variant>
#include <vector>
@@ -97,7 +98,6 @@
#include "src/buildtool/serve_api/serve_service/serve_server_implementation.hpp"
#include "src/buildtool/storage/backend_description.hpp"
#include "src/buildtool/storage/garbage_collector.hpp"
-#include "src/utils/cpp/gsl.hpp"
#endif // BOOTSTRAP_BUILD_TOOL
namespace {
@@ -245,7 +245,6 @@ void SetupFileChunker() {
/// \brief Write backend description (which determines the target cache shard)
/// to CAS.
void StoreTargetCacheShard(
- StorageConfig const& storage_config, // NOLINT(misc-unused-parameters)
Storage const& storage,
RemoteExecutionConfig const& remote_exec_config) noexcept {
auto backend_description =
@@ -256,8 +255,7 @@ void StoreTargetCacheShard(
Logger::Log(LogLevel::Error, backend_description.error());
std::exit(kExitFailure);
}
- [[maybe_unused]] auto id = storage.CAS().StoreBlob(*backend_description);
- EnsuresAudit(id and id->hash() == storage_config.backend_description_id);
+ std::ignore = storage.CAS().StoreBlob(*backend_description);
}
#endif // BOOTSTRAP_BUILD_TOOL
@@ -815,8 +813,7 @@ auto main(int argc, char* argv[]) -> int {
return kExitFailure;
}
auto const storage = Storage::Create(&*storage_config);
- StoreTargetCacheShard(
- *storage_config, storage, remote_exec_config);
+ StoreTargetCacheShard(storage, remote_exec_config);
// pack the local context instances to be passed as needed
LocalContext const local_context{
@@ -882,8 +879,7 @@ auto main(int argc, char* argv[]) -> int {
return kExitFailure;
}
auto const storage = Storage::Create(&*storage_config);
- StoreTargetCacheShard(
- *storage_config, storage, *remote_exec_config);
+ StoreTargetCacheShard(storage, *remote_exec_config);
// pack the local context instances to be passed as needed
LocalContext const local_context{
@@ -965,7 +961,7 @@ auto main(int argc, char* argv[]) -> int {
auto const storage = Storage::Create(&*storage_config);
#ifndef BOOTSTRAP_BUILD_TOOL
- StoreTargetCacheShard(*storage_config, storage, *remote_exec_config);
+ StoreTargetCacheShard(storage, *remote_exec_config);
#endif // BOOTSTRAP_BUILD_TOOL
auto jobs = arguments.build.build_jobs > 0 ? arguments.build.build_jobs
diff --git a/src/buildtool/storage/config.hpp b/src/buildtool/storage/config.hpp
index 7d3f13c7..55f79339 100644
--- a/src/buildtool/storage/config.hpp
+++ b/src/buildtool/storage/config.hpp
@@ -36,7 +36,7 @@
#include "src/utils/cpp/gsl.hpp"
#include "src/utils/cpp/tmp_dir.hpp"
-class StorageConfig;
+struct StorageConfig;
struct GenerationConfig final {
gsl::not_null<StorageConfig const*> const storage_config;
diff --git a/src/other_tools/just_mr/setup_utils.cpp b/src/other_tools/just_mr/setup_utils.cpp
index 417984ea..2ab0ebfa 100644
--- a/src/other_tools/just_mr/setup_utils.cpp
+++ b/src/other_tools/just_mr/setup_utils.cpp
@@ -218,7 +218,7 @@ auto ReadConfiguration(
absent_file_opt->string());
std::exit(kExitConfigError);
}
- absent_set.insert(repo);
+ absent_set.insert(repo.get<std::string>());
}
auto new_repos = nlohmann::json::object();
auto repos = config.value("repositories", nlohmann::json::object());
diff --git a/src/other_tools/utils/content.hpp b/src/other_tools/utils/content.hpp
index a644f5bd..6d42e060 100644
--- a/src/other_tools/utils/content.hpp
+++ b/src/other_tools/utils/content.hpp
@@ -33,8 +33,8 @@
/// \brief Fetches a file from the internet and stores its content in memory.
/// \returns the content.
-[[nodiscard]] static auto NetworkFetch(std::string const& fetch_url,
- CAInfoPtr const& ca_info) noexcept
+[[nodiscard]] static inline auto NetworkFetch(std::string const& fetch_url,
+ CAInfoPtr const& ca_info) noexcept
-> std::optional<std::string> {
auto curl_handle = CurlEasyHandle::Create(
ca_info->no_ssl_verify, ca_info->ca_bundle, LogLevel::Debug);
@@ -47,7 +47,7 @@
/// \brief Fetches a file from the internet and stores its content in memory.
/// Tries not only a given remote, but also all associated remote locations.
/// \returns The fetched data on success or an unexpected error as string.
-[[nodiscard]] static auto NetworkFetchWithMirrors(
+[[nodiscard]] static inline auto NetworkFetchWithMirrors(
std::string const& fetch_url,
std::vector<std::string> const& mirrors,
CAInfoPtr const& ca_info,
@@ -89,8 +89,8 @@
}
template <Hasher::HashType kType>
-[[nodiscard]] static auto GetContentHash(std::string const& data) noexcept
- -> std::string {
+[[nodiscard]] static inline auto GetContentHash(
+ std::string const& data) noexcept -> std::string {
auto hasher = Hasher::Create(kType);
hasher->Update(data);
auto digest = std::move(*hasher).Finalize();
diff --git a/src/utils/cpp/transformed_range.hpp b/src/utils/cpp/transformed_range.hpp
index 3d064d9c..f63f2325 100644
--- a/src/utils/cpp/transformed_range.hpp
+++ b/src/utils/cpp/transformed_range.hpp
@@ -93,7 +93,7 @@ class TransformedRange final {
[[nodiscard]] auto ToVector() const -> std::vector<Result> {
std::vector<Result> result;
- result.reserve(size());
+ result.reserve(gsl::narrow<std::size_t>(size()));
for (auto item : *this) {
result.emplace_back(std::move(item));
}
diff --git a/test/buildtool/build_engine/expression/expression.test.cpp b/test/buildtool/build_engine/expression/expression.test.cpp
index 02de11fa..6ba9bf0b 100644
--- a/test/buildtool/build_engine/expression/expression.test.cpp
+++ b/test/buildtool/build_engine/expression/expression.test.cpp
@@ -1836,7 +1836,6 @@ TEST_CASE("Expression hash computation", "[expression]") {
using namespace std::string_literals;
using path = std::filesystem::path;
using number_t = Expression::number_t;
- using artifact_t = Expression::artifact_t;
using result_t = Expression::result_t;
using list_t = Expression::list_t;
using map_t = Expression::map_t;
diff --git a/test/buildtool/file_system/resolve_symlinks_map.test.cpp b/test/buildtool/file_system/resolve_symlinks_map.test.cpp
index 729e3c54..c6e69f65 100644
--- a/test/buildtool/file_system/resolve_symlinks_map.test.cpp
+++ b/test/buildtool/file_system/resolve_symlinks_map.test.cpp
@@ -151,7 +151,7 @@ TEST_CASE("Resolve symlinks", "[resolve_symlinks_map]") {
source_cas,
source_cas)},
[&expected, &source_cas](auto const& values) {
- for (auto i = 0; i < kNumCases; ++i) {
+ for (std::size_t i = 0; i < kNumCases; ++i) {
auto const& res = ResolvedGitObject{*values[i]};
CHECK(res.id == expected[i].id);
CHECK(res.type == expected[i].type);
@@ -207,7 +207,7 @@ TEST_CASE("Resolve symlinks", "[resolve_symlinks_map]") {
source_cas,
target_cas)},
[&expected, &target_cas](auto const& values) {
- for (auto i = 0; i < kNumCases; ++i) {
+ for (std::size_t i = 0; i < kNumCases; ++i) {
auto const& res = ResolvedGitObject{*values[i]};
CHECK(res.id == expected[i].id);
CHECK(res.type == expected[i].type);
diff --git a/test/buildtool/graph_traverser/graph_traverser.test.hpp b/test/buildtool/graph_traverser/graph_traverser.test.hpp
index db2e87ac..b3340ab9 100644
--- a/test/buildtool/graph_traverser/graph_traverser.test.hpp
+++ b/test/buildtool/graph_traverser/graph_traverser.test.hpp
@@ -204,7 +204,7 @@ class TestProject {
.progress = &progress};
GraphTraverser const gt{
- clargs.gtargs, &exec_context, [](auto done, auto cv) {}};
+ clargs.gtargs, &exec_context, [](auto /*done*/, auto /*cv*/) {}};
auto const result =
gt.BuildAndStage(clargs.graph_description, clargs.artifacts);
@@ -223,8 +223,9 @@ class TestProject {
SECTION("Executable is retrieved as executable") {
auto const clargs_exec = p.CmdLineArgs("_entry_points_get_executable");
- GraphTraverser const gt_get_exec{
- clargs_exec.gtargs, &exec_context, [](auto done, auto cv) {}};
+ GraphTraverser const gt_get_exec{clargs_exec.gtargs,
+ &exec_context,
+ [](auto /*done*/, auto /*cv*/) {}};
auto const exec_result = gt_get_exec.BuildAndStage(
clargs_exec.graph_description, clargs_exec.artifacts);
@@ -279,7 +280,7 @@ class TestProject {
.progress = &progress};
GraphTraverser const gt{
- clargs.gtargs, &exec_context, [](auto done, auto cv) {}};
+ clargs.gtargs, &exec_context, [](auto /*done*/, auto /*cv*/) {}};
auto const result =
gt.BuildAndStage(clargs.graph_description, clargs.artifacts);
@@ -329,7 +330,7 @@ class TestProject {
.progress = &progress};
GraphTraverser const gt{
- clargs.gtargs, &exec_context, [](auto done, auto cv) {}};
+ clargs.gtargs, &exec_context, [](auto /*done*/, auto /*cv*/) {}};
auto const result =
gt.BuildAndStage(clargs.graph_description, clargs.artifacts);
@@ -338,8 +339,9 @@ class TestProject {
CHECK(FileSystemManager::IsFile(result->output_paths.at(0)));
auto const clargs_full_build = p.CmdLineArgs("_entry_points_full_build");
- GraphTraverser const gt_full_build{
- clargs_full_build.gtargs, &exec_context, [](auto done, auto cv) {}};
+ GraphTraverser const gt_full_build{clargs_full_build.gtargs,
+ &exec_context,
+ [](auto /*done*/, auto /*cv*/) {}};
auto const full_build_result = gt_full_build.BuildAndStage(
clargs_full_build.graph_description, clargs_full_build.artifacts);
@@ -393,8 +395,9 @@ class TestProject {
.statistics = &stats,
.progress = &progress};
- GraphTraverser const gt_upload{
- clargs_update_cpp.gtargs, &full_context, [](auto done, auto cv) {}};
+ GraphTraverser const gt_upload{clargs_update_cpp.gtargs,
+ &full_context,
+ [](auto /*done*/, auto /*cv*/) {}};
auto const cpp_result = gt_upload.BuildAndStage(
clargs_update_cpp.graph_description, clargs_update_cpp.artifacts);
@@ -421,7 +424,7 @@ class TestProject {
.statistics = &stats,
.progress = &progress};
GraphTraverser const gt{
- clargs.gtargs, &context_known, [](auto done, auto cv) {}};
+ clargs.gtargs, &context_known, [](auto /*done*/, auto /*cv*/) {}};
auto const result =
gt.BuildAndStage(clargs.graph_description, clargs.artifacts);
@@ -473,7 +476,8 @@ static void TestBlobsUploadedAndUsed(
.statistics = &stats,
.progress = &progress};
- GraphTraverser gt{clargs.gtargs, &exec_context, [](auto done, auto cv) {}};
+ GraphTraverser gt{
+ clargs.gtargs, &exec_context, [](auto /*done*/, auto /*cv*/) {}};
auto const result =
gt.BuildAndStage(clargs.graph_description, clargs.artifacts);
@@ -530,7 +534,8 @@ static void TestEnvironmentVariablesSetAndUsed(
.statistics = &stats,
.progress = &progress};
- GraphTraverser gt{clargs.gtargs, &exec_context, [](auto done, auto cv) {}};
+ GraphTraverser gt{
+ clargs.gtargs, &exec_context, [](auto /*done*/, auto /*cv*/) {}};
auto const result =
gt.BuildAndStage(clargs.graph_description, clargs.artifacts);
@@ -587,7 +592,8 @@ static void TestTreesUsed(
.statistics = &stats,
.progress = &progress};
- GraphTraverser gt{clargs.gtargs, &exec_context, [](auto done, auto cv) {}};
+ GraphTraverser gt{
+ clargs.gtargs, &exec_context, [](auto /*done*/, auto /*cv*/) {}};
auto const result =
gt.BuildAndStage(clargs.graph_description, clargs.artifacts);
@@ -644,7 +650,8 @@ static void TestNestedTreesUsed(
.statistics = &stats,
.progress = &progress};
- GraphTraverser gt{clargs.gtargs, &exec_context, [](auto done, auto cv) {}};
+ GraphTraverser gt{
+ clargs.gtargs, &exec_context, [](auto /*done*/, auto /*cv*/) {}};
auto const result =
gt.BuildAndStage(clargs.graph_description, clargs.artifacts);
@@ -703,7 +710,7 @@ static void TestFlakyHelloWorldDetected(
{
auto clargs = p.CmdLineArgs("_entry_points_ctimes");
GraphTraverser const gt{
- clargs.gtargs, &exec_context, [](auto done, auto cv) {}};
+ clargs.gtargs, &exec_context, [](auto /*done*/, auto /*cv*/) {}};
auto const result =
gt.BuildAndStage(clargs.graph_description, clargs.artifacts);
@@ -718,7 +725,7 @@ static void TestFlakyHelloWorldDetected(
auto clargs_output = p.CmdLineArgs();
clargs_output.gtargs.rebuild = RebuildArguments{};
GraphTraverser const gt_output{
- clargs_output.gtargs, &exec_context, [](auto done, auto cv) {}};
+ clargs_output.gtargs, &exec_context, [](auto /*done*/, auto /*cv*/) {}};
REQUIRE(gt_output.BuildAndStage(clargs_output.graph_description,
clargs_output.artifacts));
CHECK(stats.ActionsFlakyCounter() == 1);
@@ -729,8 +736,9 @@ static void TestFlakyHelloWorldDetected(
// make_exe[flaky]->make_output[miss]->strip_time [miss]
auto clargs_stripped = p.CmdLineArgs("_entry_points_stripped");
clargs_stripped.gtargs.rebuild = RebuildArguments{};
- GraphTraverser const gt_stripped{
- clargs_stripped.gtargs, &exec_context, [](auto done, auto cv) {}};
+ GraphTraverser const gt_stripped{clargs_stripped.gtargs,
+ &exec_context,
+ [](auto /*done*/, auto /*cv*/) {}};
REQUIRE(gt_stripped.BuildAndStage(clargs_stripped.graph_description,
clargs_stripped.artifacts));
CHECK(stats.ActionsFlakyCounter() == 1);
@@ -742,7 +750,7 @@ static void TestFlakyHelloWorldDetected(
auto clargs_ctimes = p.CmdLineArgs("_entry_points_ctimes");
clargs_ctimes.gtargs.rebuild = RebuildArguments{};
GraphTraverser const gt_ctimes{
- clargs_ctimes.gtargs, &exec_context, [](auto done, auto cv) {}};
+ clargs_ctimes.gtargs, &exec_context, [](auto /*done*/, auto /*cv*/) {}};
REQUIRE(gt_ctimes.BuildAndStage(clargs_ctimes.graph_description,
clargs_ctimes.artifacts));
CHECK(stats.ActionsFlakyCounter() == 2);
diff --git a/test/utils/large_objects/large_object_utils.cpp b/test/utils/large_objects/large_object_utils.cpp
index b61ea49e..0afa7d6f 100644
--- a/test/utils/large_objects/large_object_utils.cpp
+++ b/test/utils/large_objects/large_object_utils.cpp
@@ -55,7 +55,7 @@ class ChunkPool final {
[[nodiscard]] auto operator[](std::size_t index) const noexcept
-> std::string const& {
- return gsl::at(pool_, index);
+ return gsl::at(pool_, gsl::narrow<gsl::index>(index));
}
private:
@@ -66,7 +66,7 @@ class ChunkPool final {
Randomizer randomizer{1, std::numeric_limits<char>::max()};
for (std::size_t i = 0; i < pool_.size(); ++i) {
- auto& chunk = gsl::at(pool_, i);
+ auto& chunk = gsl::at(pool_, gsl::narrow<gsl::index>(i));
chunk.resize(kChunkLength);
for (std::size_t j = 0; j < kChunkLength; ++j) {
chunk[j] = randomizer.Get();