Skip to content

Commit

Permalink
Fix modernize-make-unique warning reported by clang-tidy (#1113)
Browse files Browse the repository at this point in the history
  • Loading branch information
dl239 authored Nov 14, 2022
1 parent 96e9f37 commit da7e369
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/server/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<ReplicationThread>(new ReplicationThread(host, master_listen_port, this));
replication_thread_ = std::make_unique<ReplicationThread>(host, master_listen_port, this);
auto s = replication_thread_->Start([this]() { PrepareRestoreDB(); },
[this]() {
this->is_loading_ = false;
Expand Down
3 changes: 1 addition & 2 deletions src/storage/storage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<rocksdb::SequentialFileWrapper> src_reader;
src_reader.reset(new rocksdb::SequentialFileWrapper(src_file.get()));
auto src_reader = std::make_unique<rocksdb::SequentialFileWrapper>(src_file.get());

char buffer[4096];
Slice slice;
Expand Down

0 comments on commit da7e369

Please sign in to comment.