From c198bbcafbcbda5c20c0e261291b9ce1be0cc4af Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Thu, 9 May 2024 04:20:54 +0200 Subject: [PATCH] Useless changes --- src/Access/AccessBackup.cpp | 2 -- src/Access/AccessRights.cpp | 8 ++++---- src/Access/AuthenticationData.cpp | 11 +++++++---- src/Access/DiskAccessStorage.cpp | 8 ++++---- src/Access/GrantedRoles.cpp | 4 ++-- src/Access/IAccessStorage.cpp | 2 +- src/Access/LDAPAccessStorage.cpp | 6 +++--- src/Access/LDAPClient.cpp | 2 +- src/Access/MemoryAccessStorage.cpp | 6 +++--- src/Access/MultipleAccessStorage.cpp | 2 +- src/Access/ReplicatedAccessStorage.cpp | 4 ++-- src/Access/SettingsConstraints.cpp | 6 +++--- src/Backups/BackupIO_File.cpp | 6 +++--- src/Backups/BackupsWorker.cpp | 12 ++++++------ src/Backups/RestoreCoordinationLocal.cpp | 2 -- src/Backups/RestorerFromBackup.cpp | 4 ++-- .../NamedCollectionConfiguration.cpp | 4 +++- .../NamedCollections/NamedCollectionUtils.cpp | 6 +++--- src/Common/NamedCollections/NamedCollections.cpp | 4 ++-- src/Core/MySQL/MySQLReplication.cpp | 14 +++++++------- src/Core/MySQL/MySQLReplication.h | 2 +- src/Core/PostgreSQL/insertPostgreSQLValue.cpp | 9 +++------ src/Databases/PostgreSQL/DatabasePostgreSQL.cpp | 6 +++--- src/Disks/ObjectStorages/DiskObjectStorage.h | 2 +- .../MetadataStorageFromPlainObjectStorage.cpp | 2 +- src/Disks/ObjectStorages/S3/S3ObjectStorage.cpp | 1 - src/Storages/Cache/RemoteCacheController.cpp | 2 +- src/Storages/FileLog/StorageFileLog.cpp | 4 ++-- src/Storages/HDFS/HDFSCommon.cpp | 1 - src/Storages/Hive/StorageHive.cpp | 4 +--- src/Storages/Hive/StorageHive.h | 8 ++++---- src/Storages/Kafka/KafkaProducer.cpp | 2 +- src/Storages/RocksDB/EmbeddedRocksDBBulkSink.cpp | 4 ++-- src/Storages/RocksDB/StorageEmbeddedRocksDB.cpp | 2 +- 34 files changed, 78 insertions(+), 84 deletions(-) diff --git a/src/Access/AccessBackup.cpp b/src/Access/AccessBackup.cpp index 1110b9c4b21..90effdab70f 100644 --- a/src/Access/AccessBackup.cpp +++ b/src/Access/AccessBackup.cpp @@ -93,8 +93,6 @@ namespace break; } - size_t id_endpos = line.find('\t'); - String id_as_string = line.substr(0, id_endpos); UUID id = parse(line); line.clear(); diff --git a/src/Access/AccessRights.cpp b/src/Access/AccessRights.cpp index a87e9361e8e..09a610f5b85 100644 --- a/src/Access/AccessRights.cpp +++ b/src/Access/AccessRights.cpp @@ -241,11 +241,11 @@ namespace enum Level { - GLOBAL_LEVEL, - DATABASE_LEVEL, + GLOBAL_LEVEL = 0, + DATABASE_LEVEL = 1, GLOBAL_WITH_PARAMETER = DATABASE_LEVEL, - TABLE_LEVEL, - COLUMN_LEVEL, + TABLE_LEVEL = 2, + COLUMN_LEVEL = 3, }; AccessFlags getAllGrantableFlags(Level level) diff --git a/src/Access/AuthenticationData.cpp b/src/Access/AuthenticationData.cpp index a4c25b438e8..a32215f3d92 100644 --- a/src/Access/AuthenticationData.cpp +++ b/src/Access/AuthenticationData.cpp @@ -118,13 +118,16 @@ void AuthenticationData::setPassword(const String & password_) switch (type) { case AuthenticationType::PLAINTEXT_PASSWORD: - return setPasswordHashBinary(Util::stringToDigest(password_)); + setPasswordHashBinary(Util::stringToDigest(password_)); + return; case AuthenticationType::SHA256_PASSWORD: - return setPasswordHashBinary(Util::encodeSHA256(password_)); + setPasswordHashBinary(Util::encodeSHA256(password_)); + return; case AuthenticationType::DOUBLE_SHA1_PASSWORD: - return setPasswordHashBinary(Util::encodeDoubleSHA1(password_)); + setPasswordHashBinary(Util::encodeDoubleSHA1(password_)); + return; case AuthenticationType::BCRYPT_PASSWORD: case AuthenticationType::NO_PASSWORD: @@ -146,7 +149,7 @@ void AuthenticationData::setPasswordBcrypt(const String & password_, int workfac if (type != AuthenticationType::BCRYPT_PASSWORD) throw Exception(ErrorCodes::LOGICAL_ERROR, "Cannot specify bcrypt password for authentication type {}", toString(type)); - return setPasswordHashBinary(Util::encodeBcrypt(password_, workfactor_)); + setPasswordHashBinary(Util::encodeBcrypt(password_, workfactor_)); } String AuthenticationData::getPassword() const diff --git a/src/Access/DiskAccessStorage.cpp b/src/Access/DiskAccessStorage.cpp index 3c20ef3d102..1b4b6c440b1 100644 --- a/src/Access/DiskAccessStorage.cpp +++ b/src/Access/DiskAccessStorage.cpp @@ -71,7 +71,7 @@ namespace SCOPE_EXIT( { if (!succeeded) - std::filesystem::remove(tmp_file_path); + (void)std::filesystem::remove(tmp_file_path); }); /// Write the file. @@ -302,7 +302,7 @@ void DiskAccessStorage::writeLists() } /// The list files was successfully written, we don't need the 'need_rebuild_lists.mark' file any longer. - std::filesystem::remove(getNeedRebuildListsMarkFilePath(directory_path)); + (void)std::filesystem::remove(getNeedRebuildListsMarkFilePath(directory_path)); types_of_lists_to_write.clear(); } @@ -419,7 +419,7 @@ void DiskAccessStorage::removeAllExceptInMemory(const boost::container::flat_set const auto & id = it->first; ++it; /// We must go to the next element in the map `entries_by_id` here because otherwise removeNoLock() can invalidate our iterator. if (!ids_to_keep.contains(id)) - removeNoLock(id, /* throw_if_not_exists */ true, /* write_on_disk= */ false); + (void)removeNoLock(id, /* throw_if_not_exists */ true, /* write_on_disk= */ false); } } @@ -549,7 +549,7 @@ bool DiskAccessStorage::insertNoLock(const UUID & id, const AccessEntityPtr & ne if (name_collision && (id_by_name != id)) { assert(replace_if_exists); - removeNoLock(id_by_name, /* throw_if_not_exists= */ false, write_on_disk); + removeNoLock(id_by_name, /* throw_if_not_exists= */ false, write_on_disk); // NOLINT } if (id_collision) diff --git a/src/Access/GrantedRoles.cpp b/src/Access/GrantedRoles.cpp index bb07cbd6951..e1a23182cc0 100644 --- a/src/Access/GrantedRoles.cpp +++ b/src/Access/GrantedRoles.cpp @@ -161,9 +161,9 @@ void GrantedRoles::makeUnion(const GrantedRoles & other) void GrantedRoles::makeIntersection(const GrantedRoles & other) { - boost::range::remove_erase_if(roles, [&other](const UUID & id) { return other.roles.find(id) == other.roles.end(); }); + boost::range::remove_erase_if(roles, [&other](const UUID & id) { return other.roles.find(id) == other.roles.end(); }); // NOLINT - boost::range::remove_erase_if(roles_with_admin_option, [&other](const UUID & id) + boost::range::remove_erase_if(roles_with_admin_option, [&other](const UUID & id) // NOLINT { return other.roles_with_admin_option.find(id) == other.roles_with_admin_option.end(); }); diff --git a/src/Access/IAccessStorage.cpp b/src/Access/IAccessStorage.cpp index 1d6b8d99cd5..ace8c3b5848 100644 --- a/src/Access/IAccessStorage.cpp +++ b/src/Access/IAccessStorage.cpp @@ -583,7 +583,7 @@ void IAccessStorage::backup(BackupEntriesCollector & backup_entries_collector, c throwBackupNotAllowed(); auto entities = readAllWithIDs(type); - boost::range::remove_erase_if(entities, [](const std::pair & x) { return !x.second->isBackupAllowed(); }); + boost::range::remove_erase_if(entities, [](const std::pair & x) { return !x.second->isBackupAllowed(); }); // NOLINT if (entities.empty()) return; diff --git a/src/Access/LDAPAccessStorage.cpp b/src/Access/LDAPAccessStorage.cpp index b1f10cd2d49..3206b20b691 100644 --- a/src/Access/LDAPAccessStorage.cpp +++ b/src/Access/LDAPAccessStorage.cpp @@ -76,7 +76,7 @@ void LDAPAccessStorage::setConfiguration(const Poco::Util::AbstractConfiguration config.keys(prefix, all_keys); for (const auto & key : all_keys) { - if (key == "role_mapping" || key.find("role_mapping[") == 0) + if (key == "role_mapping" || key.starts_with("role_mapping[")) parseLDAPRoleSearchParams(role_search_params_cfg.emplace_back(), config, prefix_str + key); } } @@ -94,7 +94,7 @@ void LDAPAccessStorage::setConfiguration(const Poco::Util::AbstractConfiguration role_change_subscription = access_control.subscribeForChanges( [this] (const UUID & id, const AccessEntityPtr & entity) { - return this->processRoleChange(id, entity); + this->processRoleChange(id, entity); } ); } @@ -200,7 +200,7 @@ void LDAPAccessStorage::applyRoleChangeNoLock(bool grant, const UUID & role_id, void LDAPAccessStorage::assignRolesNoLock(User & user, const LDAPClient::SearchResultsList & external_roles) const { const auto external_roles_hash = boost::hash{}(external_roles); - return assignRolesNoLock(user, external_roles, external_roles_hash); + assignRolesNoLock(user, external_roles, external_roles_hash); } diff --git a/src/Access/LDAPClient.cpp b/src/Access/LDAPClient.cpp index 3a0b82b9a76..b32b1222829 100644 --- a/src/Access/LDAPClient.cpp +++ b/src/Access/LDAPClient.cpp @@ -196,7 +196,7 @@ void LDAPClient::handleError(int result_code, String text) } }); - ldap_get_option(handle, LDAP_OPT_DIAGNOSTIC_MESSAGE, &raw_message); + ldap_get_option(handle, LDAP_OPT_DIAGNOSTIC_MESSAGE, static_cast(&raw_message)); if (raw_message && *raw_message != '\0') { diff --git a/src/Access/MemoryAccessStorage.cpp b/src/Access/MemoryAccessStorage.cpp index 999e2c41d0b..791030b9b12 100644 --- a/src/Access/MemoryAccessStorage.cpp +++ b/src/Access/MemoryAccessStorage.cpp @@ -106,7 +106,7 @@ bool MemoryAccessStorage::insertNoLock(const UUID & id, const AccessEntityPtr & if (name_collision && (id_by_name != id)) { assert(replace_if_exists); - removeNoLock(id_by_name, /* throw_if_not_exists= */ true); + removeNoLock(id_by_name, /* throw_if_not_exists= */ true); // NOLINT } if (id_collision) @@ -128,7 +128,7 @@ bool MemoryAccessStorage::insertNoLock(const UUID & id, const AccessEntityPtr & } return true; } - removeNoLock(id, /* throw_if_not_exists= */ true); + removeNoLock(id, /* throw_if_not_exists= */ true); // NOLINT } /// Do insertion. @@ -238,7 +238,7 @@ void MemoryAccessStorage::removeAllExceptNoLock(const boost::container::flat_set const auto & id = it->first; ++it; /// We must go to the next element in the map `entries_by_id` here because otherwise removeNoLock() can invalidate our iterator. if (!ids_to_keep.contains(id)) - removeNoLock(id, /* throw_if_not_exists */ true); + removeNoLock(id, /* throw_if_not_exists */ true); // NOLINT } } diff --git a/src/Access/MultipleAccessStorage.cpp b/src/Access/MultipleAccessStorage.cpp index 03d690de0bd..a8b508202b5 100644 --- a/src/Access/MultipleAccessStorage.cpp +++ b/src/Access/MultipleAccessStorage.cpp @@ -238,7 +238,7 @@ void MultipleAccessStorage::moveAccessEntities(const std::vector & ids, co try { - source_storage->remove(ids); + source_storage->remove(ids); // NOLINT need_rollback = true; destination_storage->insert(to_move, ids); } diff --git a/src/Access/ReplicatedAccessStorage.cpp b/src/Access/ReplicatedAccessStorage.cpp index 275672da115..2c4b49de181 100644 --- a/src/Access/ReplicatedAccessStorage.cpp +++ b/src/Access/ReplicatedAccessStorage.cpp @@ -616,7 +616,7 @@ void ReplicatedAccessStorage::setEntityNoLock(const UUID & id, const AccessEntit void ReplicatedAccessStorage::removeEntityNoLock(const UUID & id) { LOG_DEBUG(getLogger(), "Removing entity with id {}", toString(id)); - memory_storage.remove(id, /* throw_if_not_exists= */ false); + memory_storage.remove(id, /* throw_if_not_exists= */ false); // NOLINT } @@ -654,7 +654,7 @@ void ReplicatedAccessStorage::backup(BackupEntriesCollector & backup_entries_col throwBackupNotAllowed(); auto entities = readAllWithIDs(type); - boost::range::remove_erase_if(entities, [](const std::pair & x) { return !x.second->isBackupAllowed(); }); + boost::range::remove_erase_if(entities, [](const std::pair & x) { return !x.second->isBackupAllowed(); }); // NOLINT if (entities.empty()) return; diff --git a/src/Access/SettingsConstraints.cpp b/src/Access/SettingsConstraints.cpp index db805c83e17..fb596d96a55 100644 --- a/src/Access/SettingsConstraints.cpp +++ b/src/Access/SettingsConstraints.cpp @@ -190,11 +190,11 @@ void SettingsConstraints::check(const Settings & current_settings, const Setting void SettingsConstraints::check(const Settings & current_settings, SettingsChanges & changes, SettingSource source) const { - boost::range::remove_erase_if( + boost::range::remove_erase_if( // NOLINT changes, [&](SettingChange & change) -> bool { - return !checkImpl(current_settings, const_cast(change), THROW_ON_VIOLATION, source); + return !checkImpl(current_settings, change, THROW_ON_VIOLATION, source); }); } @@ -211,7 +211,7 @@ void SettingsConstraints::check(const MergeTreeSettings & current_settings, cons void SettingsConstraints::clamp(const Settings & current_settings, SettingsChanges & changes, SettingSource source) const { - boost::range::remove_erase_if( + boost::range::remove_erase_if( // NOLINT changes, [&](SettingChange & change) -> bool { diff --git a/src/Backups/BackupIO_File.cpp b/src/Backups/BackupIO_File.cpp index 35544a526f1..39abd4fa906 100644 --- a/src/Backups/BackupIO_File.cpp +++ b/src/Backups/BackupIO_File.cpp @@ -105,7 +105,7 @@ std::unique_ptr BackupWriterFile::writeFile(const String & file_nam void BackupWriterFile::removeFile(const String & file_name) { - fs::remove(root_path / file_name); + (void)fs::remove(root_path / file_name); if (fs::is_directory(root_path) && fs::is_empty(root_path)) fs::remove(root_path); } @@ -113,9 +113,9 @@ void BackupWriterFile::removeFile(const String & file_name) void BackupWriterFile::removeFiles(const Strings & file_names) { for (const auto & file_name : file_names) - fs::remove(root_path / file_name); + (void)fs::remove(root_path / file_name); if (fs::is_directory(root_path) && fs::is_empty(root_path)) - fs::remove(root_path); + (void)fs::remove(root_path); } void BackupWriterFile::copyFileFromDisk(const String & path_in_backup, DiskPtr src_disk, const String & src_path, diff --git a/src/Backups/BackupsWorker.cpp b/src/Backups/BackupsWorker.cpp index 8143fa74a6f..9057dc9d198 100644 --- a/src/Backups/BackupsWorker.cpp +++ b/src/Backups/BackupsWorker.cpp @@ -259,23 +259,23 @@ namespace enum class BackupsWorker::ThreadPoolId : uint8_t { /// "BACKUP ON CLUSTER ASYNC" waits in background while "BACKUP ASYNC" is finished on the nodes of the cluster, then finalizes the backup. - BACKUP_ASYNC_ON_CLUSTER, + BACKUP_ASYNC_ON_CLUSTER = 0, /// "BACKUP ASYNC" waits in background while all file infos are built and then it copies the backup's files. - BACKUP_ASYNC, + BACKUP_ASYNC = 1, /// Making a list of files to copy and copying of those files is always sequential, so those operations can share one thread pool. - BACKUP_MAKE_FILES_LIST, + BACKUP_MAKE_FILES_LIST = 2, BACKUP_COPY_FILES = BACKUP_MAKE_FILES_LIST, /// "RESTORE ON CLUSTER ASYNC" waits in background while "BACKUP ASYNC" is finished on the nodes of the cluster, then finalizes the backup. - RESTORE_ASYNC_ON_CLUSTER, + RESTORE_ASYNC_ON_CLUSTER = 3, /// "RESTORE ASYNC" waits in background while the data of all tables are restored. - RESTORE_ASYNC, + RESTORE_ASYNC = 4, /// Restores from backups. - RESTORE, + RESTORE = 5, }; diff --git a/src/Backups/RestoreCoordinationLocal.cpp b/src/Backups/RestoreCoordinationLocal.cpp index 4a91b8d95a5..f51d6c0c1d8 100644 --- a/src/Backups/RestoreCoordinationLocal.cpp +++ b/src/Backups/RestoreCoordinationLocal.cpp @@ -81,8 +81,6 @@ void RestoreCoordinationLocal::generateUUIDForTable(ASTCreateQuery & create_quer auto new_uuids = create_query.generateRandomUUID(/* always_generate_new_uuid= */ true); - String new_query_str = serializeAST(create_query); - { std::lock_guard lock{mutex}; if (find_in_map()) diff --git a/src/Backups/RestorerFromBackup.cpp b/src/Backups/RestorerFromBackup.cpp index 58268971afe..1a3fdf58cc4 100644 --- a/src/Backups/RestorerFromBackup.cpp +++ b/src/Backups/RestorerFromBackup.cpp @@ -798,7 +798,7 @@ void RestorerFromBackup::applyCustomStoragePolicy(ASTPtr query_ptr) { if (restore_settings.storage_policy.value().empty()) /// it has been set to "" deliberately, so the source storage policy is erased - storage->settings->changes.removeSetting(setting_name); + storage->settings->changes.removeSetting(setting_name); // NOLINT else /// it has been set to a custom value, so it either overwrites the existing value or is added as a new one storage->settings->changes.setSetting(setting_name, restore_settings.storage_policy.value()); @@ -838,7 +838,7 @@ void RestorerFromBackup::removeUnresolvedDependencies() return true; /// Exclude this dependency. }; - tables_dependencies.removeTablesIf(need_exclude_dependency); + tables_dependencies.removeTablesIf(need_exclude_dependency); // NOLINT if (tables_dependencies.getNumberOfTables() != table_infos.size()) throw Exception(ErrorCodes::LOGICAL_ERROR, "Number of tables to be restored is not as expected. It's a bug"); diff --git a/src/Common/NamedCollections/NamedCollectionConfiguration.cpp b/src/Common/NamedCollections/NamedCollectionConfiguration.cpp index 2bb0dcd9b69..94756d32c8e 100644 --- a/src/Common/NamedCollections/NamedCollectionConfiguration.cpp +++ b/src/Common/NamedCollections/NamedCollectionConfiguration.cpp @@ -182,7 +182,9 @@ void listKeys( if (enumerate_paths.empty()) enumerate_paths.push(""); - const bool do_finish = depth >= 0 && --depth < 0; + const bool do_finish = depth == 0; + if (depth >= 0) + --depth; auto initial_paths = std::move(enumerate_paths); enumerate_paths = {}; diff --git a/src/Common/NamedCollections/NamedCollectionUtils.cpp b/src/Common/NamedCollections/NamedCollectionUtils.cpp index e9b319f02a5..21fa9b64c22 100644 --- a/src/Common/NamedCollections/NamedCollectionUtils.cpp +++ b/src/Common/NamedCollections/NamedCollectionUtils.cpp @@ -253,7 +253,7 @@ public: "Cannot remove collection `{}`, because it doesn't exist", collection_name); } - fs::remove(collection_path); + (void)fs::remove(collection_path); } private: @@ -291,7 +291,7 @@ private: files_to_remove.push_back(current_path); } for (const auto & file : files_to_remove) - fs::remove(file); + (void)fs::remove(file); } static ASTCreateNamedCollectionQuery readCreateQueryFromMetadata( @@ -402,7 +402,7 @@ void loadIfNot() if (is_loaded_from_sql && is_loaded_from_config) return; auto lock = lockNamedCollectionsTransaction(); - return loadIfNotUnlocked(lock); + loadIfNotUnlocked(lock); } void removeFromSQL(const ASTDropNamedCollectionQuery & query, ContextPtr context) diff --git a/src/Common/NamedCollections/NamedCollections.cpp b/src/Common/NamedCollections/NamedCollections.cpp index 5b377e94b21..6ee47fd6523 100644 --- a/src/Common/NamedCollections/NamedCollections.cpp +++ b/src/Common/NamedCollections/NamedCollections.cpp @@ -100,7 +100,7 @@ void NamedCollectionFactory::add( MutableNamedCollectionPtr collection) { std::lock_guard lock(mutex); - return addUnlocked(collection_name, collection, lock); + addUnlocked(collection_name, collection, lock); } void NamedCollectionFactory::add(NamedCollectionsMap collections) @@ -141,7 +141,7 @@ void NamedCollectionFactory::remove(const std::string & collection_name) void NamedCollectionFactory::removeIfExists(const std::string & collection_name) { std::lock_guard lock(mutex); - removeIfExistsUnlocked(collection_name, lock); + removeIfExistsUnlocked(collection_name, lock); // NOLINT } bool NamedCollectionFactory::removeIfExistsUnlocked( diff --git a/src/Core/MySQL/MySQLReplication.cpp b/src/Core/MySQL/MySQLReplication.cpp index 403f98360c1..6e1ae87f25e 100644 --- a/src/Core/MySQL/MySQLReplication.cpp +++ b/src/Core/MySQL/MySQLReplication.cpp @@ -513,49 +513,49 @@ namespace MySQLReplication { UInt8 val = 0; payload.readStrict(reinterpret_cast(&val), 1); - row.push_back(Field{UInt8{val}}); + row.push_back(Field{val}); break; } case MYSQL_TYPE_SHORT: { UInt16 val = 0; payload.readStrict(reinterpret_cast(&val), 2); - row.push_back(Field{UInt16{val}}); + row.push_back(Field{val}); break; } case MYSQL_TYPE_INT24: { Int32 val = 0; payload.readStrict(reinterpret_cast(&val), 3); - row.push_back(Field{Int32{val}}); + row.push_back(Field{val}); break; } case MYSQL_TYPE_LONG: { UInt32 val = 0; payload.readStrict(reinterpret_cast(&val), 4); - row.push_back(Field{UInt32{val}}); + row.push_back(Field{val}); break; } case MYSQL_TYPE_LONGLONG: { UInt64 val = 0; payload.readStrict(reinterpret_cast(&val), 8); - row.push_back(Field{UInt64{val}}); + row.push_back(Field{val}); break; } case MYSQL_TYPE_FLOAT: { Float32 val = 0; payload.readStrict(reinterpret_cast(&val), 4); - row.push_back(Field{Float32{val}}); + row.push_back(Field{val}); break; } case MYSQL_TYPE_DOUBLE: { Float64 val = 0; payload.readStrict(reinterpret_cast(&val), 8); - row.push_back(Field{Float64{val}}); + row.push_back(Field{val}); break; } case MYSQL_TYPE_TIMESTAMP: diff --git a/src/Core/MySQL/MySQLReplication.h b/src/Core/MySQL/MySQLReplication.h index 3387d952711..a42ee224310 100644 --- a/src/Core/MySQL/MySQLReplication.h +++ b/src/Core/MySQL/MySQLReplication.h @@ -119,7 +119,7 @@ namespace MySQLReplication { BINLOG_CHECKSUM_ALG_OFF = 0, BINLOG_CHECKSUM_ALG_CRC32 = 1, - BINLOG_CHECKSUM_ALG_ENUM_END, + BINLOG_CHECKSUM_ALG_ENUM_END = 3, BINLOG_CHECKSUM_ALG_UNDEF = 255 }; diff --git a/src/Core/PostgreSQL/insertPostgreSQLValue.cpp b/src/Core/PostgreSQL/insertPostgreSQLValue.cpp index b507b300769..0ce7222a9a5 100644 --- a/src/Core/PostgreSQL/insertPostgreSQLValue.cpp +++ b/src/Core/PostgreSQL/insertPostgreSQLValue.cpp @@ -99,8 +99,7 @@ void insertPostgreSQLValue( ReadBufferFromString in(value); time_t time = 0; readDateTimeText(time, in, assert_cast(data_type.get())->getTimeZone()); - if (time < 0) - time = 0; + time = std::max(time, 0); assert_cast(column).insertValue(static_cast(time)); break; } @@ -217,8 +216,7 @@ void preparePostgreSQLArrayInfo( ReadBufferFromString in(field); time_t time = 0; readDateTimeText(time, in, assert_cast(nested.get())->getTimeZone()); - if (time < 0) - time = 0; + time = std::max(time, 0); return time; }; else if (which.isDateTime64()) @@ -227,8 +225,7 @@ void preparePostgreSQLArrayInfo( ReadBufferFromString in(field); DateTime64 time = 0; readDateTime64Text(time, 6, in, assert_cast(nested.get())->getTimeZone()); - if (time < 0) - time = 0; + time = std::max(time, 0); return time; }; else if (which.isDecimal32()) diff --git a/src/Databases/PostgreSQL/DatabasePostgreSQL.cpp b/src/Databases/PostgreSQL/DatabasePostgreSQL.cpp index 3f62b9719d2..136fb7fd6d2 100644 --- a/src/Databases/PostgreSQL/DatabasePostgreSQL.cpp +++ b/src/Databases/PostgreSQL/DatabasePostgreSQL.cpp @@ -241,7 +241,7 @@ void DatabasePostgreSQL::attachTable(ContextPtr /* context_ */, const String & t fs::path table_marked_as_removed = fs::path(getMetadataPath()) / (escapeForFileName(table_name) + suffix); if (fs::exists(table_marked_as_removed)) - fs::remove(table_marked_as_removed); + (void)fs::remove(table_marked_as_removed); } @@ -298,7 +298,7 @@ void DatabasePostgreSQL::dropTable(ContextPtr, const String & table_name, bool / void DatabasePostgreSQL::drop(ContextPtr /*context*/) { - fs::remove_all(getMetadataPath()); + (void)fs::remove_all(getMetadataPath()); } @@ -368,7 +368,7 @@ void DatabasePostgreSQL::removeOutdatedTables() iter = detached_or_dropped.erase(iter); fs::path table_marked_as_removed = fs::path(getMetadataPath()) / (escapeForFileName(table_name) + suffix); if (fs::exists(table_marked_as_removed)) - fs::remove(table_marked_as_removed); + (void)fs::remove(table_marked_as_removed); } else ++iter; diff --git a/src/Disks/ObjectStorages/DiskObjectStorage.h b/src/Disks/ObjectStorages/DiskObjectStorage.h index 787937af846..fe8a5e2844a 100644 --- a/src/Disks/ObjectStorages/DiskObjectStorage.h +++ b/src/Disks/ObjectStorages/DiskObjectStorage.h @@ -4,9 +4,9 @@ #include #include #include -#include #include + namespace CurrentMetrics { extern const Metric DiskSpaceReservedForMerge; diff --git a/src/Disks/ObjectStorages/MetadataStorageFromPlainObjectStorage.cpp b/src/Disks/ObjectStorages/MetadataStorageFromPlainObjectStorage.cpp index 071b2ff4613..faa7ca38b75 100644 --- a/src/Disks/ObjectStorages/MetadataStorageFromPlainObjectStorage.cpp +++ b/src/Disks/ObjectStorages/MetadataStorageFromPlainObjectStorage.cpp @@ -158,7 +158,7 @@ void MetadataStorageFromPlainObjectStorageTransaction::createDirectory(const std void MetadataStorageFromPlainObjectStorageTransaction::createDirectoryRecursive(const std::string & path) { - return createDirectory(path); + createDirectory(path); } void MetadataStorageFromPlainObjectStorageTransaction::moveDirectory(const std::string & path_from, const std::string & path_to) diff --git a/src/Disks/ObjectStorages/S3/S3ObjectStorage.cpp b/src/Disks/ObjectStorages/S3/S3ObjectStorage.cpp index a58b37f1df9..043e5b8ef8c 100644 --- a/src/Disks/ObjectStorages/S3/S3ObjectStorage.cpp +++ b/src/Disks/ObjectStorages/S3/S3ObjectStorage.cpp @@ -557,7 +557,6 @@ std::unique_ptr S3ObjectStorage::cloneObjectStorage( { auto new_s3_settings = getSettings(config, config_prefix, context); auto new_client = getClient(config, config_prefix, context, *new_s3_settings); - String endpoint = context->getMacros()->expand(config.getString(config_prefix + ".endpoint")); auto new_uri{uri}; new_uri.bucket = new_namespace; diff --git a/src/Storages/Cache/RemoteCacheController.cpp b/src/Storages/Cache/RemoteCacheController.cpp index 403d0c8e43b..092cabc7239 100644 --- a/src/Storages/Cache/RemoteCacheController.cpp +++ b/src/Storages/Cache/RemoteCacheController.cpp @@ -206,7 +206,7 @@ void RemoteCacheController::close() // delete directory LOG_TRACE(log, "Removing the local cache. local path: {}", local_path.string()); if (fs::exists(local_path)) - fs::remove_all(local_path); + (void)fs::remove_all(local_path); } std::unique_ptr RemoteCacheController::allocFile() diff --git a/src/Storages/FileLog/StorageFileLog.cpp b/src/Storages/FileLog/StorageFileLog.cpp index d3e31101d3b..abd4b4ce23b 100644 --- a/src/Storages/FileLog/StorageFileLog.cpp +++ b/src/Storages/FileLog/StorageFileLog.cpp @@ -416,7 +416,7 @@ void StorageFileLog::drop() { try { - std::filesystem::remove_all(metadata_base_path); + (void)std::filesystem::remove_all(metadata_base_path); } catch (...) { @@ -1009,7 +1009,7 @@ bool StorageFileLog::updateFileInfos() file_infos.meta_by_inode.erase(meta); if (std::filesystem::exists(getFullMetaPath(file_name))) - std::filesystem::remove(getFullMetaPath(file_name)); + (void)std::filesystem::remove(getFullMetaPath(file_name)); file_infos.context_by_name.erase(it); } else diff --git a/src/Storages/HDFS/HDFSCommon.cpp b/src/Storages/HDFS/HDFSCommon.cpp index f9a55a1285a..9eb0d10cc16 100644 --- a/src/Storages/HDFS/HDFSCommon.cpp +++ b/src/Storages/HDFS/HDFSCommon.cpp @@ -113,7 +113,6 @@ HDFSBuilderWrapper createHDFSBuilder(const String & uri_str, const Poco::Util::A const Poco::URI uri(uri_str); const auto & host = uri.getHost(); auto port = uri.getPort(); - const String path = "//"; if (host.empty()) throw Exception(ErrorCodes::BAD_ARGUMENTS, "Illegal HDFS URI: {}", uri.toString()); diff --git a/src/Storages/Hive/StorageHive.cpp b/src/Storages/Hive/StorageHive.cpp index 88ab8e15e76..b80bf8d7f46 100644 --- a/src/Storages/Hive/StorageHive.cpp +++ b/src/Storages/Hive/StorageHive.cpp @@ -921,9 +921,7 @@ void ReadFromHive::initializePipeline(QueryPipelineBuilder & pipeline, const Bui } sources_info->hive_files = std::move(*hive_files); - - if (num_streams > sources_info->hive_files.size()) - num_streams = sources_info->hive_files.size(); + num_streams = std::min(num_streams, sources_info->hive_files.size()); Pipes pipes; for (size_t i = 0; i < num_streams; ++i) diff --git a/src/Storages/Hive/StorageHive.h b/src/Storages/Hive/StorageHive.h index ee4a3a791d6..0fc1e3ff8d9 100644 --- a/src/Storages/Hive/StorageHive.h +++ b/src/Storages/Hive/StorageHive.h @@ -70,10 +70,10 @@ private: enum class PruneLevel : uint8_t { - None, /// Do not prune - Partition, - File, - Split, + None = 0, /// Do not prune + Partition = 1, + File = 2, + Split = 3, Max = Split, }; diff --git a/src/Storages/Kafka/KafkaProducer.cpp b/src/Storages/Kafka/KafkaProducer.cpp index 77676fb010b..8b7f03c52ed 100644 --- a/src/Storages/Kafka/KafkaProducer.cpp +++ b/src/Storages/Kafka/KafkaProducer.cpp @@ -60,7 +60,7 @@ void KafkaProducer::produce(const String & message, size_t rows_in_message, cons { const auto & timestamp_column = assert_cast(*columns[timestamp_column_index.value()]); const auto timestamp = std::chrono::seconds{timestamp_column.getElement(last_row)}; - builder.timestamp(timestamp); + (void)builder.timestamp(timestamp); } while (!shutdown_called) diff --git a/src/Storages/RocksDB/EmbeddedRocksDBBulkSink.cpp b/src/Storages/RocksDB/EmbeddedRocksDBBulkSink.cpp index 9909bf34d7a..7094578a9cc 100644 --- a/src/Storages/RocksDB/EmbeddedRocksDBBulkSink.cpp +++ b/src/Storages/RocksDB/EmbeddedRocksDBBulkSink.cpp @@ -100,7 +100,7 @@ EmbeddedRocksDBBulkSink::~EmbeddedRocksDBBulkSink() try { if (fs::exists(insert_directory_queue)) - fs::remove_all(insert_directory_queue); + (void)fs::remove_all(insert_directory_queue); } catch (...) { @@ -210,7 +210,7 @@ void EmbeddedRocksDBBulkSink::consume(Chunk chunk_) throw Exception(ErrorCodes::ROCKSDB_ERROR, "RocksDB write error: {}", status.ToString()); if (fs::exists(sst_file_path)) - fs::remove(sst_file_path); + (void)fs::remove(sst_file_path); } void EmbeddedRocksDBBulkSink::onFinish() diff --git a/src/Storages/RocksDB/StorageEmbeddedRocksDB.cpp b/src/Storages/RocksDB/StorageEmbeddedRocksDB.cpp index ad185f8ec2b..01417b8977b 100644 --- a/src/Storages/RocksDB/StorageEmbeddedRocksDB.cpp +++ b/src/Storages/RocksDB/StorageEmbeddedRocksDB.cpp @@ -211,7 +211,7 @@ void StorageEmbeddedRocksDB::truncate(const ASTPtr &, const StorageMetadataPtr & rocksdb_ptr->Close(); rocksdb_ptr = nullptr; - fs::remove_all(rocksdb_dir); + (void)fs::remove_all(rocksdb_dir); fs::create_directories(rocksdb_dir); initDB(); }