diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2024-09-13 10:59:52 +0200 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2024-09-26 16:52:18 +0200 |
commit | 4582c6cb76f4fc7f49025969aba7f8a29a797d64 (patch) | |
tree | f4a6f47e376368bfc240c7ad61c5b83834302c90 /src | |
parent | f0d5b0423de0eb72cda0b5624ac28d72bf65cffd (diff) | |
download | justbuild-4582c6cb76f4fc7f49025969aba7f8a29a797d64.tar.gz |
Fix assignments in conditions
...proposed by clang-tidy.
Enable bugprone-assignment-in-if-condition check.
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/execution_api/remote/config.cpp | 3 | ||||
-rw-r--r-- | src/buildtool/file_system/git_context.cpp | 3 | ||||
-rw-r--r-- | src/buildtool/file_system/git_utils.cpp | 4 | ||||
-rw-r--r-- | src/other_tools/utils/curl_context.cpp | 3 |
4 files changed, 8 insertions, 5 deletions
diff --git a/src/buildtool/execution_api/remote/config.cpp b/src/buildtool/execution_api/remote/config.cpp index 7f065296..c2832c1b 100644 --- a/src/buildtool/execution_api/remote/config.cpp +++ b/src/buildtool/execution_api/remote/config.cpp @@ -32,7 +32,8 @@ auto RemoteExecutionConfig::Builder::Build() const noexcept // Set remote endpoint. auto remote_address = default_config.remote_address; if (remote_address_raw_.has_value()) { - if (not(remote_address = ParseAddress(*remote_address_raw_))) { + remote_address = ParseAddress(*remote_address_raw_); + if (not remote_address) { return unexpected{ fmt::format("Failed to set remote endpoint address {}", nlohmann::json(*remote_address_raw_).dump())}; diff --git a/src/buildtool/file_system/git_context.cpp b/src/buildtool/file_system/git_context.cpp index 94fb3cef..4fc613a3 100644 --- a/src/buildtool/file_system/git_context.cpp +++ b/src/buildtool/file_system/git_context.cpp @@ -24,7 +24,8 @@ extern "C" { GitContext::GitContext() noexcept { #ifndef BOOTSTRAP_BUILD_TOOL - if (not(initialized_ = (git_libgit2_init() >= 0))) { + initialized_ = git_libgit2_init() >= 0; + if (not initialized_) { Logger::Log(LogLevel::Error, "initializing libgit2 failed"); } #endif diff --git a/src/buildtool/file_system/git_utils.cpp b/src/buildtool/file_system/git_utils.cpp index 8fed7d7b..d9833521 100644 --- a/src/buildtool/file_system/git_utils.cpp +++ b/src/buildtool/file_system/git_utils.cpp @@ -32,8 +32,8 @@ constexpr std::size_t kOIDHexSize{GIT_OID_HEXSZ}; auto GitLastError() noexcept -> std::string { #ifndef BOOTSTRAP_BUILD_TOOL - git_error const* err{nullptr}; - if ((err = git_error_last()) != nullptr and err->message != nullptr) { + git_error const* const err = git_error_last(); + if (err != nullptr and err->message != nullptr) { return fmt::format("error code {}: {}", err->klass, err->message); } #endif // BOOTSTRAP_BUILD_TOOL diff --git a/src/other_tools/utils/curl_context.cpp b/src/other_tools/utils/curl_context.cpp index 44d8048d..3e0b514e 100644 --- a/src/other_tools/utils/curl_context.cpp +++ b/src/other_tools/utils/curl_context.cpp @@ -23,7 +23,8 @@ extern "C" { CurlContext::CurlContext() noexcept { // NOLINTNEXTLINE(hicpp-signed-bitwise) - if (not(initialized_ = (curl_global_init(CURL_GLOBAL_DEFAULT) >= 0))) { + initialized_ = curl_global_init(CURL_GLOBAL_DEFAULT) >= 0; + if (not initialized_) { Logger::Log(LogLevel::Error, "initializing libcurl failed"); } } |