From 367f7fe6c93cb086977a74758c50a34cfc065e22 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Sat, 8 May 2021 23:50:12 +0300 Subject: [PATCH] Fix warnings by PVS-Studio --- base/glibc-compatibility/musl/libm.h | 9 +++------ src/Access/DiskAccessStorage.cpp | 5 +++-- src/Common/HashTable/HashTable.h | 2 +- src/Coordination/Changelog.h | 2 +- src/Functions/hasColumnInTable.cpp | 2 +- src/Functions/isDecimalOverflow.cpp | 2 +- src/Storages/RabbitMQ/StorageRabbitMQ.cpp | 4 ++-- 7 files changed, 12 insertions(+), 14 deletions(-) diff --git a/base/glibc-compatibility/musl/libm.h b/base/glibc-compatibility/musl/libm.h index cdf766b49f3..e5029318693 100644 --- a/base/glibc-compatibility/musl/libm.h +++ b/base/glibc-compatibility/musl/libm.h @@ -1,9 +1,6 @@ #ifndef _LIBM_H #define _LIBM_H -// Disable warnings by PVS-Studio -//-V::GA - #include #include #include @@ -158,7 +155,7 @@ static inline long double fp_barrierl(long double x) static inline void fp_force_evalf(float x) { volatile float y; - y = x; + y = x; //-V1001 } #endif @@ -167,7 +164,7 @@ static inline void fp_force_evalf(float x) static inline void fp_force_eval(double x) { volatile double y; - y = x; + y = x; //-V1001 } #endif @@ -176,7 +173,7 @@ static inline void fp_force_eval(double x) static inline void fp_force_evall(long double x) { volatile long double y; - y = x; + y = x; //-V1001 } #endif diff --git a/src/Access/DiskAccessStorage.cpp b/src/Access/DiskAccessStorage.cpp index 80594f66dfc..8c38cd02f9c 100644 --- a/src/Access/DiskAccessStorage.cpp +++ b/src/Access/DiskAccessStorage.cpp @@ -355,8 +355,9 @@ String DiskAccessStorage::getStorageParamsJSON() const std::lock_guard lock{mutex}; Poco::JSON::Object json; json.set("path", directory_path); - if (readonly) - json.set("readonly", readonly.load()); + bool readonly_loaded = readonly; + if (readonly_loaded) + json.set("readonly", Poco::Dynamic::Var{true}); std::ostringstream oss; // STYLE_CHECK_ALLOW_STD_STRING_STREAM oss.exceptions(std::ios::failbit); Poco::JSON::Stringifier::stringify(json, oss); diff --git a/src/Common/HashTable/HashTable.h b/src/Common/HashTable/HashTable.h index 60271aabba7..128fed7822e 100644 --- a/src/Common/HashTable/HashTable.h +++ b/src/Common/HashTable/HashTable.h @@ -305,7 +305,7 @@ template struct ZeroValueStorage; template -struct ZeroValueStorage //-V308 +struct ZeroValueStorage //-V730 { private: bool has_zero = false; diff --git a/src/Coordination/Changelog.h b/src/Coordination/Changelog.h index 856e6035164..a50b734c5b4 100644 --- a/src/Coordination/Changelog.h +++ b/src/Coordination/Changelog.h @@ -32,7 +32,7 @@ struct ChangelogRecordHeader ChangelogVersion version = CURRENT_CHANGELOG_VERSION; uint64_t index = 0; /// entry log number uint64_t term = 0; - nuraft::log_val_type value_type; + nuraft::log_val_type value_type{}; uint64_t blob_size = 0; }; diff --git a/src/Functions/hasColumnInTable.cpp b/src/Functions/hasColumnInTable.cpp index 28f83a63386..6f34082a87d 100644 --- a/src/Functions/hasColumnInTable.cpp +++ b/src/Functions/hasColumnInTable.cpp @@ -134,7 +134,7 @@ ColumnPtr FunctionHasColumnInTable::executeImpl(const ColumnsWithTypeAndName & a has_column = remote_columns.hasPhysical(column_name); } - return DataTypeUInt8().createColumnConst(input_rows_count, Field(has_column)); + return DataTypeUInt8().createColumnConst(input_rows_count, Field{UInt64(has_column)}); } } diff --git a/src/Functions/isDecimalOverflow.cpp b/src/Functions/isDecimalOverflow.cpp index 0cac3675d12..ed69f28711f 100644 --- a/src/Functions/isDecimalOverflow.cpp +++ b/src/Functions/isDecimalOverflow.cpp @@ -85,7 +85,7 @@ public: auto result_column = ColumnUInt8::create(); - auto call = [&](const auto & types) -> bool //-V567 + auto call = [&](const auto & types) -> bool //-V657 { using Types = std::decay_t; using Type = typename Types::RightType; diff --git a/src/Storages/RabbitMQ/StorageRabbitMQ.cpp b/src/Storages/RabbitMQ/StorageRabbitMQ.cpp index 6f2d4813f05..95a9fe468b5 100644 --- a/src/Storages/RabbitMQ/StorageRabbitMQ.cpp +++ b/src/Storages/RabbitMQ/StorageRabbitMQ.cpp @@ -402,7 +402,7 @@ void StorageRabbitMQ::bindExchange() } } - while (!binding_created) //-V1044 + while (!binding_created) //-V776 { event_handler->iterateLoop(); } @@ -463,7 +463,7 @@ void StorageRabbitMQ::bindQueue(size_t queue_id) const String queue_name = !hash_exchange ? queue_base : std::to_string(queue_id) + "_" + queue_base; setup_channel->declareQueue(queue_name, AMQP::durable, queue_settings).onSuccess(success_callback).onError(error_callback); - while (!binding_created) //-V1044 + while (!binding_created) //-V776 { event_handler->iterateLoop(); }