From da7e369bc190855700cb76cb0dfb86caf0c90902 Mon Sep 17 00:00:00 2001 From: dl239 Date: Sun, 13 Nov 2022 23:40:00 -0600 Subject: [PATCH] Fix modernize-make-unique warning reported by clang-tidy (#1113) --- .clang-tidy | 2 +- src/server/server.cc | 2 +- src/storage/storage.cc | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 44a45f45a71..c8274ac0e30 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,7 +1,7 @@ # refer to https://clang.llvm.org/extra/clang-tidy/checks/list.html Checks: -*, clang-analyzer-core.*, clang-analyzer-cplusplus.*, clang-analyzer-deadcode.*, clang-analyzer-nullability.*, clang-analyzer-security.*, clang-analyzer-unix.*, clang-analyzer-valist.*, cppcoreguidelines-init-variables, cppcoreguidelines-macro-usage, cppcoreguidelines-interfaces-global-init, cppcoreguidelines-narrowing-conversions, cppcoreguidelines-no-malloc, cppcoreguidelines-prefer-member-initializer, cppcoreguidelines-special-member-functions, cppcoreguidelines-slicing, google-build-explicit-make-pair, google-default-arguments, google-explicit-constructor, modernize-avoid-bind, modernize-loop-convert, modernize-macro-to-enum, modernize-make-shared, modernize-make-unique, modernize-pass-by-value, modernize-redundant-void-arg, modernize-return-braced-init-list, modernize-use-auto, modernize-use-bool-literals, modernize-use-emplace, modernize-use-equals-default, modernize-use-equals-delete, modernize-use-nullptr, modernize-use-override, modernize-use-using, performance-faster-string-find, performance-for-range-copy, performance-implicit-conversion-in-loop, performance-inefficient-algorithm, performance-inefficient-vector-operation, performance-move-const-arg, performance-move-constructor-init, performance-no-automatic-move, performance-trivially-destructible, performance-type-promotion-in-math-fn, performance-unnecessary-copy-initialization, performance-unnecessary-value-param -WarningsAsErrors: clang-analyzer-*, -clang-analyzer-security.insecureAPI.rand, cppcoreguidelines-interfaces-global-init, cppcoreguidelines-no-malloc, cppcoreguidelines-slicing, google-*, modernize-use-emplace, modernize-use-equals-default, modernize-use-equals-delete, performance-implicit-conversion-in-loop, performance-inefficient-algorithm, performance-move-constructor-init, performance-no-automatic-move, performance-trivially-destructible, performance-type-promotion-in-math-fn, performance-unnecessary-copy-initialization, modernize-use-bool-literals, performance-unnecessary-value-param +WarningsAsErrors: clang-analyzer-*, -clang-analyzer-security.insecureAPI.rand, cppcoreguidelines-interfaces-global-init, cppcoreguidelines-no-malloc, cppcoreguidelines-slicing, google-*, modernize-use-emplace, modernize-use-equals-default, modernize-use-equals-delete, performance-implicit-conversion-in-loop, performance-inefficient-algorithm, performance-move-constructor-init, performance-no-automatic-move, performance-trivially-destructible, performance-type-promotion-in-math-fn, performance-unnecessary-copy-initialization, modernize-use-bool-literals, performance-unnecessary-value-param, modernize-make-unique CheckOptions: - key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor diff --git a/src/server/server.cc b/src/server/server.cc index 13614f5e8a9..89762260034 100644 --- a/src/server/server.cc +++ b/src/server/server.cc @@ -230,7 +230,7 @@ Status Server::AddMaster(const std::string &host, uint32_t port, bool force_reco // replication, and uses 'listen-port + 1' as thread listening port. uint32_t master_listen_port = port; if (GetConfig()->master_use_repl_port) master_listen_port += 1; - replication_thread_ = std::unique_ptr(new ReplicationThread(host, master_listen_port, this)); + replication_thread_ = std::make_unique(host, master_listen_port, this); auto s = replication_thread_->Start([this]() { PrepareRestoreDB(); }, [this]() { this->is_loading_ = false; diff --git a/src/storage/storage.cc b/src/storage/storage.cc index 1b815f636f4..a7318d75a6f 100644 --- a/src/storage/storage.cc +++ b/src/storage/storage.cc @@ -946,8 +946,7 @@ bool Storage::ReplDataManager::FileExists(Storage *storage, const std::string &d uint64_t size; s = storage->env_->GetFileSize(file_path, &size); if (!s.ok()) return false; - std::unique_ptr src_reader; - src_reader.reset(new rocksdb::SequentialFileWrapper(src_file.get())); + auto src_reader = std::make_unique(src_file.get()); char buffer[4096]; Slice slice;