From 4d0bc462a8ecb187039fd548f4179d2d04d40484 Mon Sep 17 00:00:00 2001 From: Konstantin Bogdanov Date: Wed, 16 Oct 2024 18:18:52 +0200 Subject: [PATCH] Another batch of clang-tidy fixes --- src/Columns/tests/gtest_column_dump_structure.cpp | 1 + src/Common/ZooKeeper/examples/zkutil_test_async.cpp | 2 ++ src/Common/tests/gtest_log.cpp | 1 + src/IO/tests/gtest_DateTime64_parsing_and_writing.cpp | 2 +- src/IO/tests/gtest_file_encryption.cpp | 2 +- src/Interpreters/tests/gtest_page_cache.cpp | 3 +++ src/Storages/MergeTree/tests/gtest_async_inserts.cpp | 2 +- utils/memcpy-bench/memcpy-bench.cpp | 2 +- 8 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Columns/tests/gtest_column_dump_structure.cpp b/src/Columns/tests/gtest_column_dump_structure.cpp index d9647147157..209a1703b88 100644 --- a/src/Columns/tests/gtest_column_dump_structure.cpp +++ b/src/Columns/tests/gtest_column_dump_structure.cpp @@ -13,6 +13,7 @@ TEST(IColumn, dumpStructure) String expected_structure = "LowCardinality(size = 0, UInt8(size = 0), Unique(size = 1, String(size = 1)))"; std::vector threads; + threads.reserve(6); for (size_t i = 0; i < 6; ++i) { threads.emplace_back([&] diff --git a/src/Common/ZooKeeper/examples/zkutil_test_async.cpp b/src/Common/ZooKeeper/examples/zkutil_test_async.cpp index 7a9498542d2..f056c9b97fb 100644 --- a/src/Common/ZooKeeper/examples/zkutil_test_async.cpp +++ b/src/Common/ZooKeeper/examples/zkutil_test_async.cpp @@ -17,6 +17,8 @@ try size_t num_threads = DB::parse(argv[1]); std::vector threads; + threads.reserve(num_threads); + for (size_t i = 0; i < num_threads; ++i) { threads.emplace_back([&] diff --git a/src/Common/tests/gtest_log.cpp b/src/Common/tests/gtest_log.cpp index 6d2bd56ad77..d531ed2b124 100644 --- a/src/Common/tests/gtest_log.cpp +++ b/src/Common/tests/gtest_log.cpp @@ -150,6 +150,7 @@ TEST(Logger, SharedLoggersThreadSafety) size_t loggers_size_before = names.size(); std::vector threads; + threads.reserve(threads_count); for (size_t thread_index = 0; thread_index < threads_count; ++thread_index) { diff --git a/src/IO/tests/gtest_DateTime64_parsing_and_writing.cpp b/src/IO/tests/gtest_DateTime64_parsing_and_writing.cpp index 83c20701353..9c010a6f908 100644 --- a/src/IO/tests/gtest_DateTime64_parsing_and_writing.cpp +++ b/src/IO/tests/gtest_DateTime64_parsing_and_writing.cpp @@ -63,7 +63,7 @@ TEST_P(DateTime64StringWriteTest, WriteText) EXPECT_NO_THROW(writeDateTimeText(param.dt64, param.scale, write_buffer, param.timezone)); write_buffer.finalize(); - EXPECT_STREQ(param.string.data(), actual_string.data()); + EXPECT_STREQ(param.string.data(), actual_string.data()); /// NOLINT(bugprone-suspicious-stringview-data-usage) } TEST_P(DateTime64StringParseBestEffortTest, parse) diff --git a/src/IO/tests/gtest_file_encryption.cpp b/src/IO/tests/gtest_file_encryption.cpp index 2b3d7ce81c5..18fe7a27a97 100644 --- a/src/IO/tests/gtest_file_encryption.cpp +++ b/src/IO/tests/gtest_file_encryption.cpp @@ -117,7 +117,7 @@ TEST_P(FileEncryptionCipherTest, Encryption) { WriteBufferFromOwnString buf; encryptor.setOffset(base_offset); - encryptor.encrypt(input.data(), i, buf); + encryptor.encrypt(input.data(), i, buf); /// NOLINT(bugprone-suspicious-stringview-data-usage) ASSERT_EQ(expected.substr(0, i), buf.str()); } } diff --git a/src/Interpreters/tests/gtest_page_cache.cpp b/src/Interpreters/tests/gtest_page_cache.cpp index 30fa3b921c9..a81ef5e7384 100644 --- a/src/Interpreters/tests/gtest_page_cache.cpp +++ b/src/Interpreters/tests/gtest_page_cache.cpp @@ -146,6 +146,7 @@ TEST(PageCache, DISABLED_Stress) auto start_time = std::chrono::steady_clock::now(); std::vector threads; + threads.reserve(num_threads); for (size_t i = 0; i < num_threads; ++i) threads.emplace_back(thread_func); @@ -247,6 +248,8 @@ TEST(PageCache, DISABLED_HitsBench) auto start_time = std::chrono::steady_clock::now(); std::vector threads; + threads.reserve(num_threads); + for (size_t i = 0; i < num_threads; ++i) threads.emplace_back(thread_func); diff --git a/src/Storages/MergeTree/tests/gtest_async_inserts.cpp b/src/Storages/MergeTree/tests/gtest_async_inserts.cpp index 2d8cd0acc3e..ae96b916000 100644 --- a/src/Storages/MergeTree/tests/gtest_async_inserts.cpp +++ b/src/Storages/MergeTree/tests/gtest_async_inserts.cpp @@ -28,7 +28,7 @@ TEST(AsyncInsertsTest, testScatterOffsetsBySelector) ASSERT_EQ(results.size(), expected.size()); for (size_t i = 0; i < results.size(); i++) { - auto result = results[i]; + const auto & result = results[i]; auto expect = expected[i]; ASSERT_EQ(result->offsets.size(), expect.size()); ASSERT_EQ(result->tokens.size(), expect.size()); diff --git a/utils/memcpy-bench/memcpy-bench.cpp b/utils/memcpy-bench/memcpy-bench.cpp index 6e862daf4ce..3025ba6e854 100644 --- a/utils/memcpy-bench/memcpy-bench.cpp +++ b/utils/memcpy-bench/memcpy-bench.cpp @@ -70,7 +70,7 @@ uint64_t test(uint8_t * dst, uint8_t * src, size_t size, size_t iterations, size iteration % 2 ? &dst[begin] : &src[begin], end - begin, [rng = RNG(), &generator]() mutable { return generator(rng); }, - std::forward(impl)); /// NOLINT(bugprone-use-after-move) + std::forward(impl)); /// NOLINT(bugprone-use-after-move,hicpp-invalid-access-moved) } }); }