summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaksim Denisov <denisov.maksim@huawei.com>2024-09-13 10:59:52 +0200
committerMaksim Denisov <denisov.maksim@huawei.com>2024-09-26 16:52:18 +0200
commit4582c6cb76f4fc7f49025969aba7f8a29a797d64 (patch)
treef4a6f47e376368bfc240c7ad61c5b83834302c90
parentf0d5b0423de0eb72cda0b5624ac28d72bf65cffd (diff)
downloadjustbuild-4582c6cb76f4fc7f49025969aba7f8a29a797d64.tar.gz
Fix assignments in conditions
...proposed by clang-tidy. Enable bugprone-assignment-in-if-condition check.
-rw-r--r--.clang-tidy2
-rw-r--r--src/buildtool/execution_api/remote/config.cpp3
-rw-r--r--src/buildtool/file_system/git_context.cpp3
-rw-r--r--src/buildtool/file_system/git_utils.cpp4
-rw-r--r--src/other_tools/utils/curl_context.cpp3
5 files changed, 9 insertions, 6 deletions
diff --git a/.clang-tidy b/.clang-tidy
index a1727cff..03134235 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -1,6 +1,6 @@
FormatStyle: Google
Checks: '*,-abseil-*,-altera-*,-android-*,-boost-*,-cert-*,-darwin-*,-fuchsia-*,-linuxkernel-*,-llvm-*,-llvmlibc-*,-mpi-*,-objc-*,-zircon-*'
-WarningsAsErrors: 'clang-diagnostic-*,-clang-diagnostic-unused-command-line-argument,clang-analyzer-*,-clang-analyzer-cplusplus.NewDeleteLeaks,-clang-analyzer-cplusplus.StringChecker,bugprone-*,-bugprone-easily-swappable-parameters,-bugprone-unchecked-optional-access,-bugprone-narrowing-conversions,-bugprone-unhandled-exception-at-new,-bugprone-empty-catch,-bugprone-optional-value-conversion,-bugprone-implicit-widening-of-multiplication-result,-bugprone-inc-dec-in-conditions,-bugprone-assignment-in-if-condition,-bugprone-exception-escape,portability-*,hicpp-*,performance-*,-performance-avoid-endl,-performance-enum-size,-performance-no-automatic-move'
+WarningsAsErrors: 'clang-diagnostic-*,-clang-diagnostic-unused-command-line-argument,clang-analyzer-*,-clang-analyzer-cplusplus.NewDeleteLeaks,-clang-analyzer-cplusplus.StringChecker,bugprone-*,-bugprone-easily-swappable-parameters,-bugprone-unchecked-optional-access,-bugprone-narrowing-conversions,-bugprone-unhandled-exception-at-new,-bugprone-empty-catch,-bugprone-optional-value-conversion,-bugprone-implicit-widening-of-multiplication-result,-bugprone-inc-dec-in-conditions,-bugprone-exception-escape,portability-*,hicpp-*,performance-*,-performance-avoid-endl,-performance-enum-size,-performance-no-automatic-move'
CheckOptions: [
{
key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic,
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");
}
}