Useless changes

This commit is contained in:
Alexey Milovidov 2024-05-10 03:31:40 +02:00
parent 42710158e4
commit c17a3bb944
29 changed files with 73 additions and 85 deletions

View File

@ -131,6 +131,7 @@ Checks: [
'-readability-redundant-member-init',
'-bugprone-crtp-constructor-accessibility',
'-bugprone-suspicious-stringview-data-usage',
'-bugprone-multi-level-implicit-pointer-conversion',
'-zircon-*'
]

View File

@ -27,7 +27,7 @@ namespace TypeListUtils /// In some contexts it's more handy to use functions in
constexpr Root<Args...> changeRoot(TypeList<Args...>) { return {}; }
template <typename F, typename ...Args>
constexpr void forEach(TypeList<Args...>, F && f) { (std::forward<F>(f)(TypeList<Args>{}), ...); }
constexpr void forEach(TypeList<Args...>, F && f) { (f(TypeList<Args>{}), ...); }
}
template <typename TypeListLeft, typename TypeListRight>

View File

@ -233,7 +233,7 @@ namespace
/**
* Levels:
* 1. GLOBAL
* 1. GLOBAL
* 2. DATABASE_LEVEL 2. GLOBAL_WITH_PARAMETER (parameter example: named collection)
* 3. TABLE_LEVEL
* 4. COLUMN_LEVEL
@ -246,6 +246,7 @@ namespace
GLOBAL_WITH_PARAMETER = DATABASE_LEVEL,
TABLE_LEVEL = 2,
COLUMN_LEVEL = 3,
MAX = COLUMN_LEVEL,
};
AccessFlags getAllGrantableFlags(Level level)
@ -520,7 +521,7 @@ public:
private:
AccessFlags getAllGrantableFlags() const { return ::DB::getAllGrantableFlags(level); }
AccessFlags getChildAllGrantableFlags() const { return ::DB::getAllGrantableFlags(static_cast<Level>(level + 1)); }
AccessFlags getChildAllGrantableFlags() const { return ::DB::getAllGrantableFlags(static_cast<Level>(level == Level::MAX ? level : (level + 1))); }
Node * tryGetChild(std::string_view name) const
{

View File

@ -574,7 +574,7 @@ bool DiskAccessStorage::insertNoLock(const UUID & id, const AccessEntityPtr & ne
return true;
}
removeNoLock(id, /* throw_if_not_exists= */ false, write_on_disk);
removeNoLock(id, /* throw_if_not_exists= */ false, write_on_disk); // NOLINT
}
/// Do insertion.

View File

@ -196,7 +196,7 @@ void LDAPClient::handleError(int result_code, String text)
}
});
ldap_get_option(handle, LDAP_OPT_DIAGNOSTIC_MESSAGE, static_cast<void*>(&raw_message));
ldap_get_option(handle, LDAP_OPT_DIAGNOSTIC_MESSAGE, &raw_message);
if (raw_message && *raw_message != '\0')
{

View File

@ -107,7 +107,7 @@ void BackupWriterFile::removeFile(const String & 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::removeFiles(const Strings & file_names)

View File

@ -105,7 +105,7 @@ std::optional<size_t> decodeBase58(const UInt8 * src, size_t src_length, UInt8 *
}
for (size_t j = 0; j < idx; ++j)
{
carry += static_cast<UInt8>(dst[j] * 58);
carry += dst[j] * 58;
dst[j] = static_cast<UInt8>(carry & 0xFF);
carry >>= 8;
}

View File

@ -1,3 +1,5 @@
// NOLINTBEGIN(clang-analyzer-optin.core.EnumCastOutOfRange)
#include "FST.h"
#include <algorithm>
#include <cassert>
@ -483,3 +485,5 @@ std::pair<UInt64, bool> FiniteStateTransducer::getOutput(std::string_view term)
}
}
// NOLINTEND(clang-analyzer-optin.core.EnumCastOutOfRange)

View File

@ -580,7 +580,7 @@ namespace MySQLReplication
case MYSQL_TYPE_YEAR: {
Int16 val = 0;
payload.readStrict(reinterpret_cast<char *>(&val), 1);
row.push_back(Field{UInt16{static_cast<UInt16>(val + 1900)}});
row.push_back(Field{static_cast<UInt16>(val + 1900)});
break;
}
case MYSQL_TYPE_TIME2:
@ -665,8 +665,9 @@ namespace MySQLReplication
Int64 time_micro = 0;
time_micro = (hh * 3600 + mm * 60 + ss) * 1000000 + std::abs(frac);
if (negative) time_micro = - time_micro;
row.push_back(Field{Int64{time_micro}});
if (negative)
time_micro = - time_micro;
row.push_back(Field{time_micro});
break;
}
case MYSQL_TYPE_DATETIME2:
@ -812,13 +813,13 @@ namespace MySQLReplication
{
UInt8 val = 0;
payload.readStrict(reinterpret_cast<char *>(&val), 1);
row.push_back(Field{UInt8{val}});
row.push_back(Field{val});
}
else
{
UInt16 val = 0;
payload.readStrict(reinterpret_cast<char *>(&val), 2);
row.push_back(Field{UInt16{val}});
row.push_back(Field{val});
}
break;
}

View File

@ -61,7 +61,7 @@ static std::pair<DataTypePtr, DataTypeCustomDescPtr> create(const ASTPtr & argum
void registerDataTypeNested(DataTypeFactory & factory)
{
return factory.registerDataTypeCustom("Nested", create);
factory.registerDataTypeCustom("Nested", create);
}
DataTypePtr createNested(const DataTypes & types, const Names & names)

View File

@ -151,11 +151,7 @@ size_t DataTypeVariant::getMaximumSizeOfValueInMemory() const
{
size_t max_size = 0;
for (const auto & elem : variants)
{
size_t elem_max_size = elem->getMaximumSizeOfValueInMemory();
if (elem_max_size > max_size)
max_size = elem_max_size;
}
max_size = std::max(max_size, elem->getMaximumSizeOfValueInMemory());
return max_size;
}

View File

@ -189,8 +189,7 @@ DataTypePtr FieldToDataType<on_error>::operator() (const Object &) const
template <LeastSupertypeOnError on_error>
DataTypePtr FieldToDataType<on_error>::operator() (const AggregateFunctionStateData & x) const
{
const auto & name = static_cast<const AggregateFunctionStateData &>(x).name;
return DataTypeFactory::instance().get(name);
return DataTypeFactory::instance().get(x.name);
}
template <LeastSupertypeOnError on_error>

View File

@ -63,9 +63,7 @@ void SerializationAggregateFunction::serializeBinaryBulk(const IColumn & column,
ColumnAggregateFunction::Container::const_iterator it = vec.begin() + offset;
ColumnAggregateFunction::Container::const_iterator end = limit ? it + limit : vec.end();
if (end > vec.end())
end = vec.end();
end = std::min(end, vec.end());
for (; it != end; ++it)
function->serialize(*it, ostr, version);
}

View File

@ -31,15 +31,13 @@ inline void readText(time_t & x, ReadBuffer & istr, const FormatSettings & setti
break;
}
if (x < 0)
x = 0;
x = std::max<time_t>(0, x);
}
inline void readAsIntText(time_t & x, ReadBuffer & istr)
{
readIntText(x, istr);
if (x < 0)
x = 0;
x = std::max<time_t>(0, x);
}
inline bool tryReadText(time_t & x, ReadBuffer & istr, const FormatSettings & settings, const DateLUTImpl & time_zone, const DateLUTImpl & utc_time_zone)
@ -58,9 +56,7 @@ inline bool tryReadText(time_t & x, ReadBuffer & istr, const FormatSettings & se
break;
}
if (x < 0)
x = 0;
x = std::max<time_t>(0, x);
return res;
}
@ -68,8 +64,7 @@ inline bool tryReadAsIntText(time_t & x, ReadBuffer & istr)
{
if (!tryReadIntText(x, istr))
return false;
if (x < 0)
x = 0;
x = std::max<time_t>(0, x);
return true;
}

View File

@ -243,7 +243,7 @@ void SerializationInfoByName::writeJSON(WriteBuffer & out) const
oss.exceptions(std::ios::failbit);
Poco::JSON::Stringifier::stringify(object, oss);
return writeString(oss.str(), out);
writeString(oss.str(), out);
}
SerializationInfoByName SerializationInfoByName::readJSON(

View File

@ -80,7 +80,6 @@ void SerializationUUID::deserializeTextQuoted(IColumn & column, ReadBuffer & ist
bool SerializationUUID::tryDeserializeTextQuoted(IColumn & column, ReadBuffer & istr, const FormatSettings &) const
{
UUID uuid;
String field;
if (!checkChar('\'', istr) || !tryReadText(uuid, istr) || !checkChar('\'', istr))
return false;

View File

@ -494,10 +494,8 @@ std::tuple<size_t, size_t, size_t> getTypeTextDeserializePriority(const DataType
{
auto [elem_nested_depth, elem_priority, elem_simple_nested_depth] = getTypeTextDeserializePriority(elem, nested_depth + 1, simple_nested_depth, priority_map);
sum_priority += elem_priority;
if (elem_nested_depth > max_nested_depth)
max_nested_depth = elem_nested_depth;
if (elem_simple_nested_depth > max_simple_nested_depth)
max_simple_nested_depth = elem_simple_nested_depth;
max_nested_depth = std::max(elem_nested_depth, max_nested_depth);
max_simple_nested_depth = std::max(elem_simple_nested_depth, max_simple_nested_depth);
}
return {max_nested_depth, sum_priority + priority_map.at(TypeIndex::Tuple), max_simple_nested_depth};
@ -518,12 +516,9 @@ std::tuple<size_t, size_t, size_t> getTypeTextDeserializePriority(const DataType
for (const auto & variant : variant_type->getVariants())
{
auto [variant_max_depth, variant_priority, variant_simple_nested_depth] = getTypeTextDeserializePriority(variant, nested_depth, simple_nested_depth, priority_map);
if (variant_priority > max_priority)
max_priority = variant_priority;
if (variant_max_depth > max_depth)
max_depth = variant_max_depth;
if (variant_simple_nested_depth > max_simple_nested_depth)
max_simple_nested_depth = variant_simple_nested_depth;
max_priority = std::max(variant_priority, max_priority);
max_depth = std::max(variant_max_depth, max_depth);
max_simple_nested_depth = std::max(variant_simple_nested_depth, max_simple_nested_depth);
}
return {max_depth, max_priority, max_simple_nested_depth};

View File

@ -79,8 +79,7 @@ DataTypePtr getNumericType(const TypeIndexSet & types)
auto maximize = [](size_t & what, size_t value)
{
if (value > what)
what = value;
what = std::max(value, what);
};
for (const auto & type : types)
@ -596,9 +595,7 @@ DataTypePtr getLeastSupertype(const DataTypes & types)
continue;
}
UInt32 scale = getDecimalScale(*type);
if (scale > max_scale)
max_scale = scale;
max_scale = std::max(max_scale, getDecimalScale(*type));
}
UInt32 min_precision = max_scale + leastDecimalPrecisionFor(max_int);

View File

@ -81,14 +81,14 @@ void DatabaseAtomic::drop(ContextPtr)
assert(TSA_SUPPRESS_WARNING_FOR_READ(tables).empty());
try
{
fs::remove(path_to_metadata_symlink);
fs::remove_all(path_to_table_symlinks);
(void)fs::remove(path_to_metadata_symlink);
(void)fs::remove_all(path_to_table_symlinks);
}
catch (...)
{
LOG_WARNING(log, getCurrentExceptionMessageAndPattern(/* with_stacktrace */ true));
}
fs::remove_all(getMetadataPath());
(void)fs::remove_all(getMetadataPath());
}
void DatabaseAtomic::attachTable(ContextPtr /* context_ */, const String & name, const StoragePtr & table, const String & relative_table_path)
@ -335,7 +335,7 @@ void DatabaseAtomic::commitCreateTable(const ASTCreateQuery & query, const Stora
}
catch (...)
{
fs::remove(table_metadata_tmp_path);
(void)fs::remove(table_metadata_tmp_path);
throw;
}
if (table->storesDataOnDisk())
@ -346,7 +346,11 @@ void DatabaseAtomic::commitAlterTable(const StorageID & table_id, const String &
const String & /*statement*/, ContextPtr query_context)
{
bool check_file_exists = true;
SCOPE_EXIT({ std::error_code code; if (check_file_exists) std::filesystem::remove(table_metadata_tmp_path, code); });
SCOPE_EXIT({
std::error_code code;
if (check_file_exists)
(void)std::filesystem::remove(table_metadata_tmp_path, code);
});
std::lock_guard lock{mutex};
auto actual_table_id = getTableUnlocked(table_id.table_name)->getStorageID();
@ -447,7 +451,7 @@ void DatabaseAtomic::beforeLoadingMetadata(ContextMutablePtr /*context*/, Loadin
"'{}' is not a symlink. Atomic database should contains only symlinks.", std::string(table_path.path()));
}
fs::remove(table_path);
(void)fs::remove(table_path);
}
}
@ -526,7 +530,7 @@ void DatabaseAtomic::tryRemoveSymlink(const String & table_name)
try
{
String path = path_to_table_symlinks + escapeForFileName(table_name);
fs::remove(path);
(void)fs::remove(path);
}
catch (...)
{
@ -551,7 +555,7 @@ void DatabaseAtomic::tryCreateMetadataSymlink()
{
/// fs::exists could return false for broken symlink
if (FS::isSymlinkNoThrow(metadata_symlink))
fs::remove(metadata_symlink);
(void)fs::remove(metadata_symlink);
fs::create_directory_symlink(metadata_path, path_to_metadata_symlink);
}
catch (...)
@ -578,7 +582,7 @@ void DatabaseAtomic::renameDatabase(ContextPtr query_context, const String & new
try
{
fs::remove(path_to_metadata_symlink);
(void)fs::remove(path_to_metadata_symlink);
}
catch (...)
{

View File

@ -79,7 +79,7 @@ void DatabaseMemory::dropTable(
{
fs::path table_data_dir{fs::path{getContext()->getPath()} / getTableDataPath(table_name)};
if (fs::exists(table_data_dir))
fs::remove_all(table_data_dir);
(void)fs::remove_all(table_data_dir);
}
}
catch (...)
@ -135,7 +135,7 @@ UUID DatabaseMemory::tryGetTableUUID(const String & table_name) const
void DatabaseMemory::removeDataPath(ContextPtr local_context)
{
std::filesystem::remove_all(local_context->getPath() + data_path);
(void)std::filesystem::remove_all(local_context->getPath() + data_path);
}
void DatabaseMemory::drop(ContextPtr local_context)

View File

@ -265,7 +265,7 @@ void DatabaseOnDisk::removeDetachedPermanentlyFlag(ContextPtr, const String & ta
fs::path detached_permanently_flag(table_metadata_path + detached_suffix);
if (fs::exists(detached_permanently_flag))
fs::remove(detached_permanently_flag);
(void)fs::remove(detached_permanently_flag);
}
catch (Exception & e)
{
@ -289,7 +289,7 @@ void DatabaseOnDisk::commitCreateTable(const ASTCreateQuery & query, const Stora
}
catch (...)
{
fs::remove(table_metadata_tmp_path);
(void)fs::remove(table_metadata_tmp_path);
throw;
}
}
@ -338,7 +338,7 @@ void DatabaseOnDisk::dropTable(ContextPtr local_context, const String & table_na
fs::path table_data_dir(local_context->getPath() + table_data_path_relative);
if (fs::exists(table_data_dir))
fs::remove_all(table_data_dir);
(void)fs::remove_all(table_data_dir);
}
catch (...)
{
@ -349,7 +349,7 @@ void DatabaseOnDisk::dropTable(ContextPtr local_context, const String & table_na
throw;
}
fs::remove(table_metadata_path_drop);
(void)fs::remove(table_metadata_path_drop);
}
void DatabaseOnDisk::checkMetadataFilenameAvailability(const String & to_table_name) const
@ -468,7 +468,7 @@ void DatabaseOnDisk::renameTable(
/// Now table data are moved to new database, so we must add metadata and attach table to new database
to_database.createTable(local_context, to_table_name, table, attach_query);
fs::remove(table_metadata_path);
(void)fs::remove(table_metadata_path);
if (from_atomic_to_ordinary)
{
@ -548,15 +548,15 @@ void DatabaseOnDisk::drop(ContextPtr local_context)
assert(TSA_SUPPRESS_WARNING_FOR_READ(tables).empty());
if (local_context->getSettingsRef().force_remove_data_recursively_on_drop)
{
fs::remove_all(local_context->getPath() + getDataPath());
fs::remove_all(getMetadataPath());
(void)fs::remove_all(local_context->getPath() + getDataPath());
(void)fs::remove_all(getMetadataPath());
}
else
{
try
{
fs::remove(local_context->getPath() + getDataPath());
fs::remove(getMetadataPath());
(void)fs::remove(local_context->getPath() + getDataPath());
(void)fs::remove(getMetadataPath());
}
catch (const fs::filesystem_error & e)
{
@ -610,7 +610,7 @@ void DatabaseOnDisk::iterateMetadataFiles(ContextPtr local_context, const Iterat
else
{
LOG_INFO(log, "Removing file {}", getMetadataPath() + file_name);
fs::remove(getMetadataPath() + file_name);
(void)fs::remove(getMetadataPath() + file_name);
}
};
@ -642,7 +642,7 @@ void DatabaseOnDisk::iterateMetadataFiles(ContextPtr local_context, const Iterat
{
/// There are files .sql.tmp - delete
LOG_INFO(log, "Removing file {}", dir_it->path().string());
fs::remove(dir_it->path());
(void)fs::remove(dir_it->path());
}
else if (endsWith(file_name, ".sql"))
{
@ -708,7 +708,7 @@ ASTPtr DatabaseOnDisk::parseQueryFromMetadata(
{
if (logger)
LOG_ERROR(logger, "File {} is empty. Removing.", metadata_file_path);
fs::remove(metadata_file_path);
(void)fs::remove(metadata_file_path);
return nullptr;
}

View File

@ -304,7 +304,7 @@ void DatabaseOrdinary::restoreMetadataAfterConvertingToReplicated(StoragePtr tab
if (!fs::exists(convert_to_replicated_flag_path))
return;
fs::remove(convert_to_replicated_flag_path);
(void)fs::remove(convert_to_replicated_flag_path);
LOG_INFO
(
log,
@ -540,7 +540,7 @@ void DatabaseOrdinary::commitAlterTable(const StorageID &, const String & table_
}
catch (...)
{
fs::remove(table_metadata_tmp_path);
(void)fs::remove(table_metadata_tmp_path);
throw;
}
}

View File

@ -169,7 +169,7 @@ void DatabaseMaterializedMySQL::drop(ContextPtr context_)
fs::path metadata(getMetadataPath() + "/.metadata");
if (fs::exists(metadata))
fs::remove(metadata);
(void)fs::remove(metadata);
DatabaseAtomic::drop(context_);
}

View File

@ -341,7 +341,7 @@ void DatabaseMySQL::shutdown()
void DatabaseMySQL::drop(ContextPtr /*context*/)
{
fs::remove_all(getMetadataPath());
(void)fs::remove_all(getMetadataPath());
}
void DatabaseMySQL::cleanOutdatedTables()
@ -390,7 +390,7 @@ void DatabaseMySQL::attachTable(ContextPtr /* context_ */, const String & table_
fs::path remove_flag = fs::path(getMetadataPath()) / (escapeForFileName(table_name) + suffix);
if (fs::exists(remove_flag))
fs::remove(remove_flag);
(void)fs::remove(remove_flag);
}
StoragePtr DatabaseMySQL::detachTable(ContextPtr /* context */, const String & table_name)

View File

@ -228,7 +228,7 @@ void commitMetadata(Fn<void()> auto && function, const String & persistent_tmp_p
}
catch (...)
{
fs::remove(persistent_tmp_path);
(void)fs::remove(persistent_tmp_path);
throw;
}
}

View File

@ -199,7 +199,7 @@ void TablesLoader::removeUnresolvableDependencies()
return true; /// Exclude this dependency.
};
all_loading_dependencies.removeTablesIf(need_exclude_dependency);
all_loading_dependencies.removeTablesIf(need_exclude_dependency); // NOLINT
if (all_loading_dependencies.getNumberOfTables() != metadata.parsed_tables.size())
throw Exception(ErrorCodes::LOGICAL_ERROR, "Number of tables to be loaded is not as expected. It's a bug");

View File

@ -297,7 +297,7 @@ void DiskLocal::createDirectories(const String & path)
void DiskLocal::clearDirectory(const String & path)
{
for (const auto & entry : fs::directory_iterator(fs::path(disk_path) / path))
fs::remove(entry.path());
(void)fs::remove(entry.path());
}
void DiskLocal::moveDirectory(const String & from_path, const String & to_path)
@ -377,7 +377,7 @@ void DiskLocal::removeDirectory(const String & path)
void DiskLocal::removeRecursive(const String & path)
{
fs::remove_all(fs::path(disk_path) / path);
(void)fs::remove_all(fs::path(disk_path) / path);
}
void DiskLocal::listFiles(const String & path, std::vector<String> & file_names) const

View File

@ -298,8 +298,7 @@ QueryPipelineBuilder QueryPipelineBuilder::unitePipelines(
/// If one of pipelines uses more threads then current limit, will keep it.
/// It may happen if max_distributed_connections > max_threads
if (pipeline.max_threads > max_threads_limit)
max_threads_limit = pipeline.max_threads;
max_threads_limit = std::max(pipeline.max_threads, max_threads_limit);
concurrency_control = pipeline.getConcurrencyControl();
}

View File

@ -74,7 +74,6 @@ std::unique_ptr<ReadBuffer> RemoteReadBuffer::create(
bool is_random_accessed)
{
auto remote_path = remote_file_metadata->remote_path;
auto remote_read_buffer = std::make_unique<RemoteReadBuffer>(buff_size);
std::tie(remote_read_buffer->local_file_holder, read_buffer)
@ -205,7 +204,7 @@ void ExternalDataSourceCache::recoverTask()
}
}
for (auto & path : invalid_paths)
fs::remove_all(path);
(void)fs::remove_all(path);
initialized = true;
auto root_dirs_to_string = [&]()