Useless changes

This commit is contained in:
Alexey Milovidov 2024-05-09 03:58:34 +02:00
parent 97f24f38b8
commit 224e1940ae
28 changed files with 57 additions and 57 deletions

View File

@ -130,6 +130,7 @@ Checks: [
'-readability-redundant-inline-specifier', '-readability-redundant-inline-specifier',
'-readability-redundant-member-init', '-readability-redundant-member-init',
'-bugprone-crtp-constructor-accessibility', '-bugprone-crtp-constructor-accessibility',
'-bugprone-suspicious-stringview-data-usage',
'-zircon-*' '-zircon-*'
] ]

View File

@ -52,7 +52,7 @@ function(absl_cc_library)
) )
target_include_directories(${_NAME} target_include_directories(${_NAME}
PUBLIC "${ABSL_COMMON_INCLUDE_DIRS}") SYSTEM PUBLIC "${ABSL_COMMON_INCLUDE_DIRS}")
target_compile_options(${_NAME} target_compile_options(${_NAME}
PRIVATE ${ABSL_CC_LIB_COPTS}) PRIVATE ${ABSL_CC_LIB_COPTS})
target_compile_definitions(${_NAME} PUBLIC ${ABSL_CC_LIB_DEFINES}) target_compile_definitions(${_NAME} PUBLIC ${ABSL_CC_LIB_DEFINES})
@ -61,7 +61,7 @@ function(absl_cc_library)
# Generating header-only library # Generating header-only library
add_library(${_NAME} INTERFACE) add_library(${_NAME} INTERFACE)
target_include_directories(${_NAME} target_include_directories(${_NAME}
INTERFACE "${ABSL_COMMON_INCLUDE_DIRS}") SYSTEM INTERFACE "${ABSL_COMMON_INCLUDE_DIRS}")
target_link_libraries(${_NAME} target_link_libraries(${_NAME}
INTERFACE INTERFACE

View File

@ -323,7 +323,7 @@ int mainEntryClickHouseInstall(int argc, char ** argv)
{ {
fmt::print("Symlink {} already exists but it points to {}. Will replace the old symlink to {}.\n", fmt::print("Symlink {} already exists but it points to {}. Will replace the old symlink to {}.\n",
main_bin_path.string(), points_to.string(), binary_self_canonical_path.string()); main_bin_path.string(), points_to.string(), binary_self_canonical_path.string());
fs::remove(main_bin_path); (void)fs::remove(main_bin_path);
} }
} }
} }
@ -489,7 +489,7 @@ int mainEntryClickHouseInstall(int argc, char ** argv)
{ {
fmt::print("Symlink {} already exists but it points to {}. Will replace the old symlink to {}.\n", fmt::print("Symlink {} already exists but it points to {}. Will replace the old symlink to {}.\n",
symlink_path.string(), points_to.string(), main_bin_path.string()); symlink_path.string(), points_to.string(), main_bin_path.string());
fs::remove(symlink_path); (void)fs::remove(symlink_path);
} }
} }
} }
@ -1006,7 +1006,7 @@ namespace
else else
{ {
fmt::print("{} file exists but damaged, ignoring.\n", pid_file.string()); fmt::print("{} file exists but damaged, ignoring.\n", pid_file.string());
fs::remove(pid_file); (void)fs::remove(pid_file);
} }
} }
else else
@ -1014,7 +1014,7 @@ namespace
/// Create a directory for pid file. /// Create a directory for pid file.
/// It's created by "install" but we also support cases when ClickHouse is already installed different way. /// It's created by "install" but we also support cases when ClickHouse is already installed different way.
fs::path pid_path = pid_file; fs::path pid_path = pid_file;
pid_path.remove_filename(); pid_path = pid_path.remove_filename();
fs::create_directories(pid_path); fs::create_directories(pid_path);
/// All users are allowed to read pid file (for clickhouse status command). /// All users are allowed to read pid file (for clickhouse status command).
fs::permissions(pid_path, fs::perms::owner_all | fs::perms::group_read | fs::perms::others_read, fs::perm_options::replace); fs::permissions(pid_path, fs::perms::owner_all | fs::perms::group_read | fs::perms::others_read, fs::perm_options::replace);
@ -1098,7 +1098,7 @@ namespace
else else
{ {
fmt::print("{} file exists but damaged, ignoring.\n", pid_file.string()); fmt::print("{} file exists but damaged, ignoring.\n", pid_file.string());
fs::remove(pid_file); (void)fs::remove(pid_file);
} }
} }
catch (const Exception & e) catch (const Exception & e)

View File

@ -37,7 +37,7 @@ std::string getIdentifierQuote(nanodbc::ConnectionHolderPtr connection_holder)
IdentifierQuotingStyle getQuotingStyle(nanodbc::ConnectionHolderPtr connection) IdentifierQuotingStyle getQuotingStyle(nanodbc::ConnectionHolderPtr connection)
{ {
auto identifier_quote = getIdentifierQuote(connection); auto identifier_quote = getIdentifierQuote(connection);
if (identifier_quote.length() == 0) if (identifier_quote.empty())
return IdentifierQuotingStyle::None; return IdentifierQuotingStyle::None;
else if (identifier_quote[0] == '`') else if (identifier_quote[0] == '`')
return IdentifierQuotingStyle::Backticks; return IdentifierQuotingStyle::Backticks;

View File

@ -111,13 +111,11 @@ void processTableFiles(const fs::path & data_path, fs::path dst_path, bool test_
std::shared_ptr<WriteBuffer> directory_meta; std::shared_ptr<WriteBuffer> directory_meta;
if (test_mode) if (test_mode)
{ {
auto files_root = dst_path / prefix;
directory_meta = std::make_shared<WriteBufferFromHTTP>(HTTPConnectionGroupType::HTTP, Poco::URI(dst_path / directory_prefix / ".index"), Poco::Net::HTTPRequest::HTTP_PUT); directory_meta = std::make_shared<WriteBufferFromHTTP>(HTTPConnectionGroupType::HTTP, Poco::URI(dst_path / directory_prefix / ".index"), Poco::Net::HTTPRequest::HTTP_PUT);
} }
else else
{ {
dst_path = fs::canonical(dst_path); dst_path = fs::canonical(dst_path);
auto files_root = dst_path / prefix;
fs::create_directories(dst_path / directory_prefix); fs::create_directories(dst_path / directory_prefix);
directory_meta = std::make_shared<WriteBufferFromFile>(dst_path / directory_prefix / ".index"); directory_meta = std::make_shared<WriteBufferFromFile>(dst_path / directory_prefix / ".index");
} }

View File

@ -115,15 +115,15 @@ namespace
{ {
UNKNOWN = -2, UNKNOWN = -2,
GROUP = -1, GROUP = -1,
GLOBAL, GLOBAL = 0,
DATABASE, DATABASE = 1,
TABLE, TABLE = 2,
VIEW = TABLE, VIEW = TABLE,
COLUMN, COLUMN = 3,
DICTIONARY, DICTIONARY = 4,
NAMED_COLLECTION, NAMED_COLLECTION = 5,
USER_NAME, USER_NAME = 6,
TABLE_ENGINE, TABLE_ENGINE = 7,
}; };
struct Node; struct Node;

View File

@ -1159,7 +1159,7 @@ void AsynchronousMetrics::update(TimePoint update_time, bool force_update)
core_id = std::stoi(s.substr(core_id_start)); core_id = std::stoi(s.substr(core_id_start));
} }
else if (s.rfind("cpu MHz", 0) == 0) else if (s.starts_with("cpu MHz"))
{ {
if (auto colon = s.find_first_of(':')) if (auto colon = s.find_first_of(':'))
{ {

View File

@ -424,7 +424,7 @@ public:
if (unlikely(this->c_end + sizeof(T) > this->c_end_of_storage)) if (unlikely(this->c_end + sizeof(T) > this->c_end_of_storage))
this->reserveForNextSize(std::forward<TAllocatorParams>(allocator_params)...); this->reserveForNextSize(std::forward<TAllocatorParams>(allocator_params)...);
new (t_end()) T(std::forward<U>(x)); new (reinterpret_cast<void*>(t_end())) T(std::forward<U>(x));
this->c_end += sizeof(T); this->c_end += sizeof(T);
} }

View File

@ -61,7 +61,7 @@ DynamicResourceManager::State::Resource::Resource(
// Create nodes // Create nodes
bool has_root = false; bool has_root = false;
for (auto [path, key] : path2key) for (const auto & [path, key] : path2key)
{ {
// Validate path // Validate path
size_t slash = path.rfind('/'); size_t slash = path.rfind('/');

View File

@ -888,7 +888,7 @@ void TestKeeper::multi(
const Requests & requests, const Requests & requests,
MultiCallback callback) MultiCallback callback)
{ {
return multi(std::span(requests), std::move(callback)); multi(std::span(requests), std::move(callback));
} }
void TestKeeper::multi( void TestKeeper::multi(

View File

@ -689,21 +689,29 @@ void CompressionCodecT64::doDecompressData(const char * src, UInt32 src_size, ch
switch (baseType(saved_type_id)) switch (baseType(saved_type_id))
{ {
case TypeIndex::Int8: case TypeIndex::Int8:
return decompressData<Int8>(src, src_size, dst, uncompressed_size, saved_variant); decompressData<Int8>(src, src_size, dst, uncompressed_size, saved_variant);
return;
case TypeIndex::Int16: case TypeIndex::Int16:
return decompressData<Int16>(src, src_size, dst, uncompressed_size, saved_variant); decompressData<Int16>(src, src_size, dst, uncompressed_size, saved_variant);
return;
case TypeIndex::Int32: case TypeIndex::Int32:
return decompressData<Int32>(src, src_size, dst, uncompressed_size, saved_variant); decompressData<Int32>(src, src_size, dst, uncompressed_size, saved_variant);
return;
case TypeIndex::Int64: case TypeIndex::Int64:
return decompressData<Int64>(src, src_size, dst, uncompressed_size, saved_variant); decompressData<Int64>(src, src_size, dst, uncompressed_size, saved_variant);
return;
case TypeIndex::UInt8: case TypeIndex::UInt8:
return decompressData<UInt8>(src, src_size, dst, uncompressed_size, saved_variant); decompressData<UInt8>(src, src_size, dst, uncompressed_size, saved_variant);
return;
case TypeIndex::UInt16: case TypeIndex::UInt16:
return decompressData<UInt16>(src, src_size, dst, uncompressed_size, saved_variant); decompressData<UInt16>(src, src_size, dst, uncompressed_size, saved_variant);
return;
case TypeIndex::UInt32: case TypeIndex::UInt32:
return decompressData<UInt32>(src, src_size, dst, uncompressed_size, saved_variant); decompressData<UInt32>(src, src_size, dst, uncompressed_size, saved_variant);
return;
case TypeIndex::UInt64: case TypeIndex::UInt64:
return decompressData<UInt64>(src, src_size, dst, uncompressed_size, saved_variant); decompressData<UInt64>(src, src_size, dst, uncompressed_size, saved_variant);
return;
default: default:
break; break;
} }

View File

@ -44,7 +44,7 @@ public:
void setReadUntilPosition(size_t position) override; /// [..., position). void setReadUntilPosition(size_t position) override; /// [..., position).
void setReadUntilEnd() override { return setReadUntilPosition(getFileSize()); } void setReadUntilEnd() override { setReadUntilPosition(getFileSize()); }
size_t getFileOffsetOfBufferEnd() const override { return file_offset_of_buffer_end; } size_t getFileOffsetOfBufferEnd() const override { return file_offset_of_buffer_end; }

View File

@ -454,7 +454,7 @@ FunctionBasePtr IFunctionOverloadResolver::build(const ColumnsWithTypeAndName &
void IFunctionOverloadResolver::getLambdaArgumentTypes(DataTypes & arguments [[maybe_unused]]) const void IFunctionOverloadResolver::getLambdaArgumentTypes(DataTypes & arguments [[maybe_unused]]) const
{ {
checkNumberOfArguments(arguments.size()); checkNumberOfArguments(arguments.size());
return getLambdaArgumentTypesImpl(arguments); getLambdaArgumentTypesImpl(arguments);
} }
DataTypePtr IFunctionOverloadResolver::getReturnTypeWithoutLowCardinality(const ColumnsWithTypeAndName & arguments) const DataTypePtr IFunctionOverloadResolver::getReturnTypeWithoutLowCardinality(const ColumnsWithTypeAndName & arguments) const

View File

@ -975,7 +975,7 @@ private:
break; break;
} }
return result_type->createColumnConst(item_arg->size(), static_cast<ResultType>(current)); return result_type->createColumnConst(item_arg->size(), current);
} }
else else
{ {

View File

@ -173,7 +173,7 @@ off_t ReadBufferFromFileDescriptor::seek(off_t offset, int whence)
if (new_pos + (working_buffer.end() - pos) == file_offset_of_buffer_end) if (new_pos + (working_buffer.end() - pos) == file_offset_of_buffer_end)
return new_pos; return new_pos;
if (file_offset_of_buffer_end - working_buffer.size() <= static_cast<size_t>(new_pos) if (file_offset_of_buffer_end - working_buffer.size() <= new_pos
&& new_pos <= file_offset_of_buffer_end) && new_pos <= file_offset_of_buffer_end)
{ {
/// Position is still inside the buffer. /// Position is still inside the buffer.

View File

@ -102,17 +102,17 @@ static inline void writeProbablyQuotedStringImpl(StringRef s, WriteBuffer & buf,
void writeProbablyBackQuotedString(StringRef s, WriteBuffer & buf) void writeProbablyBackQuotedString(StringRef s, WriteBuffer & buf)
{ {
writeProbablyQuotedStringImpl(s, buf, [](StringRef s_, WriteBuffer & buf_) { return writeBackQuotedString(s_, buf_); }); writeProbablyQuotedStringImpl(s, buf, [](StringRef s_, WriteBuffer & buf_) { writeBackQuotedString(s_, buf_); });
} }
void writeProbablyDoubleQuotedString(StringRef s, WriteBuffer & buf) void writeProbablyDoubleQuotedString(StringRef s, WriteBuffer & buf)
{ {
writeProbablyQuotedStringImpl(s, buf, [](StringRef s_, WriteBuffer & buf_) { return writeDoubleQuotedString(s_, buf_); }); writeProbablyQuotedStringImpl(s, buf, [](StringRef s_, WriteBuffer & buf_) { writeDoubleQuotedString(s_, buf_); });
} }
void writeProbablyBackQuotedStringMySQL(StringRef s, WriteBuffer & buf) void writeProbablyBackQuotedStringMySQL(StringRef s, WriteBuffer & buf)
{ {
writeProbablyQuotedStringImpl(s, buf, [](StringRef s_, WriteBuffer & buf_) { return writeBackQuotedStringMySQL(s_, buf_); }); writeProbablyQuotedStringImpl(s, buf, [](StringRef s_, WriteBuffer & buf_) { writeBackQuotedStringMySQL(s_, buf_); });
} }
void writePointerHex(const void * ptr, WriteBuffer & buf) void writePointerHex(const void * ptr, WriteBuffer & buf)

View File

@ -712,12 +712,12 @@ bool tryParseDateTimeBestEffortUS(time_t & res, ReadBuffer & in, const DateLUTIm
void parseDateTime64BestEffort(DateTime64 & res, UInt32 scale, ReadBuffer & in, const DateLUTImpl & local_time_zone, const DateLUTImpl & utc_time_zone) void parseDateTime64BestEffort(DateTime64 & res, UInt32 scale, ReadBuffer & in, const DateLUTImpl & local_time_zone, const DateLUTImpl & utc_time_zone)
{ {
return parseDateTime64BestEffortImpl<void, false>(res, scale, in, local_time_zone, utc_time_zone); parseDateTime64BestEffortImpl<void, false>(res, scale, in, local_time_zone, utc_time_zone);
} }
void parseDateTime64BestEffortUS(DateTime64 & res, UInt32 scale, ReadBuffer & in, const DateLUTImpl & local_time_zone, const DateLUTImpl & utc_time_zone) void parseDateTime64BestEffortUS(DateTime64 & res, UInt32 scale, ReadBuffer & in, const DateLUTImpl & local_time_zone, const DateLUTImpl & utc_time_zone)
{ {
return parseDateTime64BestEffortImpl<void, true>(res, scale, in, local_time_zone, utc_time_zone); parseDateTime64BestEffortImpl<void, true>(res, scale, in, local_time_zone, utc_time_zone);
} }
bool tryParseDateTime64BestEffort(DateTime64 & res, UInt32 scale, ReadBuffer & in, const DateLUTImpl & local_time_zone, const DateLUTImpl & utc_time_zone) bool tryParseDateTime64BestEffort(DateTime64 & res, UInt32 scale, ReadBuffer & in, const DateLUTImpl & local_time_zone, const DateLUTImpl & utc_time_zone)

View File

@ -5,7 +5,6 @@
#include <Common/Exception.h> #include <Common/Exception.h>
#include <Interpreters/Cache/FileSegmentInfo.h> #include <Interpreters/Cache/FileSegmentInfo.h>
#include <Interpreters/Cache/Guards.h> #include <Interpreters/Cache/Guards.h>
#include <Interpreters/Cache/IFileCachePriority.h>
#include <Interpreters/Cache/FileCache_fwd_internal.h> #include <Interpreters/Cache/FileCache_fwd_internal.h>
#include <Interpreters/Cache/UserInfo.h> #include <Interpreters/Cache/UserInfo.h>

View File

@ -81,7 +81,7 @@ public:
}; };
PriorityDumpPtr dump(const CachePriorityGuard::Lock &) override; PriorityDumpPtr dump(const CachePriorityGuard::Lock &) override;
void pop(const CachePriorityGuard::Lock & lock) { remove(queue.begin(), lock); } void pop(const CachePriorityGuard::Lock & lock) { remove(queue.begin(), lock); } // NOLINT
bool modifySizeLimits(size_t max_size_, size_t max_elements_, double size_ratio_, const CachePriorityGuard::Lock &) override; bool modifySizeLimits(size_t max_size_, size_t max_elements_, double size_ratio_, const CachePriorityGuard::Lock &) override;

View File

@ -110,17 +110,17 @@ public:
/// Returns the result of loading the object. /// Returns the result of loading the object.
/// The function doesn't load anything, it just returns the current load result as is. /// The function doesn't load anything, it just returns the current load result as is.
template <typename ReturnType = LoadResult, typename = std::enable_if_t<is_scalar_load_result_type<ReturnType>, void>> template <typename ReturnType = LoadResult, typename = std::enable_if_t<is_scalar_load_result_type<ReturnType>, void>> // NOLINT
ReturnType getLoadResult(const String & name) const; ReturnType getLoadResult(const String & name) const;
using FilterByNameFunction = std::function<bool(const String &)>; using FilterByNameFunction = std::function<bool(const String &)>;
/// Returns all the load results as a map. /// Returns all the load results as a map.
/// The function doesn't load anything, it just returns the current load results as is. /// The function doesn't load anything, it just returns the current load results as is.
template <typename ReturnType = LoadResults, typename = std::enable_if_t<is_vector_load_result_type<ReturnType>, void>> template <typename ReturnType = LoadResults, typename = std::enable_if_t<is_vector_load_result_type<ReturnType>, void>> // NOLINT
ReturnType getLoadResults() const { return getLoadResults<ReturnType>(FilterByNameFunction{}); } ReturnType getLoadResults() const { return getLoadResults<ReturnType>(FilterByNameFunction{}); }
template <typename ReturnType = LoadResults, typename = std::enable_if_t<is_vector_load_result_type<ReturnType>, void>> template <typename ReturnType = LoadResults, typename = std::enable_if_t<is_vector_load_result_type<ReturnType>, void>> // NOLINT
ReturnType getLoadResults(const FilterByNameFunction & filter) const; ReturnType getLoadResults(const FilterByNameFunction & filter) const;
/// Returns all loaded objects as a map. /// Returns all loaded objects as a map.

View File

@ -40,7 +40,6 @@ BlockIO InterpreterRenameQuery::execute()
getContext()->checkAccess(getRequiredAccess(rename.database ? RenameType::RenameDatabase : RenameType::RenameTable)); getContext()->checkAccess(getRequiredAccess(rename.database ? RenameType::RenameDatabase : RenameType::RenameTable));
String path = getContext()->getPath();
String current_database = getContext()->getCurrentDatabase(); String current_database = getContext()->getCurrentDatabase();
/** In case of error while renaming, it is possible that only part of tables was renamed /** In case of error while renaming, it is possible that only part of tables was renamed

View File

@ -671,7 +671,8 @@ void ASTFunction::formatImplWithoutAlias(const FormatSettings & settings, Format
if (written) if (written)
{ {
return finishFormatWithWindow(settings, state, frame); finishFormatWithWindow(settings, state, frame);
return;
} }
settings.ostr << (settings.hilite ? hilite_function : "") << name; settings.ostr << (settings.hilite ? hilite_function : "") << name;
@ -753,8 +754,7 @@ void ASTFunction::formatImplWithoutAlias(const FormatSettings & settings, Format
settings.ostr << (settings.hilite ? hilite_function : "") << ')'; settings.ostr << (settings.hilite ? hilite_function : "") << ')';
settings.ostr << (settings.hilite ? hilite_none : ""); settings.ostr << (settings.hilite ? hilite_none : "");
finishFormatWithWindow(settings, state, frame);
return finishFormatWithWindow(settings, state, frame);
} }
bool ASTFunction::hasSecretParts() const bool ASTFunction::hasSecretParts() const

View File

@ -285,8 +285,6 @@ void ASTTablesInSelectQueryElement::formatImpl(const FormatSettings & settings,
void ASTTablesInSelectQuery::formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const void ASTTablesInSelectQuery::formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
{ {
std::string indent_str = settings.one_line ? "" : std::string(4 * frame.indent, ' ');
for (const auto & child : children) for (const auto & child : children)
child->formatImpl(settings, state, frame); child->formatImpl(settings, state, frame);
} }

View File

@ -219,7 +219,7 @@ namespace
void throwIfNotGrantable(AccessRightsElements & elements) void throwIfNotGrantable(AccessRightsElements & elements)
{ {
boost::range::remove_erase_if(elements, [](AccessRightsElement & element) boost::range::remove_erase_if(elements, [](AccessRightsElement & element) // NOLINT
{ {
if (element.empty()) if (element.empty())
return true; return true;

View File

@ -137,7 +137,6 @@ bool DatatypeInt::convertImpl(String & out, IParser::Pos & pos)
const String fn_name = getKQLFunctionName(pos); const String fn_name = getKQLFunctionName(pos);
if (fn_name.empty()) if (fn_name.empty())
return false; return false;
String guid_str;
++pos; ++pos;
if (pos->type == TokenType::QuotedIdentifier || pos->type == TokenType::StringLiteral) if (pos->type == TokenType::QuotedIdentifier || pos->type == TokenType::StringLiteral)

View File

@ -240,7 +240,7 @@ void inline getTokens(String format, std::vector<String> & res)
pos = str.find_first_not_of("abcdefghijklmnopqrstuvwxyzQWERTYUIOPASDFGHJKLZXCVBNM"); pos = str.find_first_not_of("abcdefghijklmnopqrstuvwxyzQWERTYUIOPASDFGHJKLZXCVBNM");
} }
// Cover the last (or only) token // Cover the last (or only) token
if (str.length() > 0) if (!str.empty())
{ {
token = str; token = str;
res.insert(res.begin(), token); res.insert(res.begin(), token);

View File

@ -92,9 +92,7 @@ void writeQueryWithHighlightedErrorPositions(
} }
else else
{ {
ssize_t bytes_to_hilite = UTF8::seqLength(*current_position_to_hilite); ssize_t bytes_to_hilite = std::min<ssize_t>(UTF8::seqLength(*current_position_to_hilite), end - current_position_to_hilite);
if (bytes_to_hilite > end - current_position_to_hilite)
bytes_to_hilite = end - current_position_to_hilite;
/// Bright on red background. /// Bright on red background.
out << "\033[41;1m"; out << "\033[41;1m";

View File

@ -62,7 +62,7 @@ public:
size_t max_block_size, size_t max_block_size,
size_t num_streams) override size_t num_streams) override
{ {
return getNested()->read(query_plan, column_names, storage_snapshot, query_info, context, processed_stage, max_block_size, num_streams); getNested()->read(query_plan, column_names, storage_snapshot, query_info, context, processed_stage, max_block_size, num_streams);
} }
SinkToStoragePtr write(const ASTPtr & query, const StorageMetadataPtr & metadata_snapshot, ContextPtr context, bool async_insert) override SinkToStoragePtr write(const ASTPtr & query, const StorageMetadataPtr & metadata_snapshot, ContextPtr context, bool async_insert) override