You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kvrocks.apache.org by tw...@apache.org on 2022/11/15 03:35:34 UTC
[incubator-kvrocks] branch unstable updated: Fix modernize-use-auto warning reported by clang-tidy (#1111)
This is an automated email from the ASF dual-hosted git repository.
twice pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/incubator-kvrocks.git
The following commit(s) were added to refs/heads/unstable by this push:
new 7fb3d644 Fix modernize-use-auto warning reported by clang-tidy (#1111)
7fb3d644 is described below
commit 7fb3d64479e47d19b7e894b8aff4c4046b277c90
Author: Maxim Smolskiy <mi...@mail.ru>
AuthorDate: Tue Nov 15 06:35:28 2022 +0300
Fix modernize-use-auto warning reported by clang-tidy (#1111)
---
.clang-tidy | 2 +-
src/commands/redis_cmd.cc | 3 +--
src/storage/batch_extractor.cc | 8 ++++----
src/types/redis_bitmap.cc | 10 +++++-----
4 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/.clang-tidy b/.clang-tidy
index 4cdc81d1..1742da13 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, goog [...]
-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, perfor [...]
+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, perfor [...]
CheckOptions:
- key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
diff --git a/src/commands/redis_cmd.cc b/src/commands/redis_cmd.cc
index 652b7908..c79229c1 100644
--- a/src/commands/redis_cmd.cc
+++ b/src/commands/redis_cmd.cc
@@ -4713,8 +4713,7 @@ class CommandFetchFile : public Commander {
// Sleep if the speed of sending file is more than replication speed limit
auto end = std::chrono::high_resolution_clock::now();
uint64_t duration = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
- uint64_t shortest =
- static_cast<uint64_t>(static_cast<double>(file_size) / max_replication_bytes * (1000 * 1000));
+ auto shortest = static_cast<uint64_t>(static_cast<double>(file_size) / max_replication_bytes * (1000 * 1000));
if (max_replication_bytes > 0 && duration < shortest) {
LOG(INFO) << "[replication] Need to sleep " << (shortest - duration) / 1000
<< " ms since of sending files too quickly";
diff --git a/src/storage/batch_extractor.cc b/src/storage/batch_extractor.cc
index 833617eb..8d893db9 100644
--- a/src/storage/batch_extractor.cc
+++ b/src/storage/batch_extractor.cc
@@ -70,7 +70,7 @@ rocksdb::Status WriteBatchExtractor::PutCF(uint32_t column_family_id, const Slic
if (!parse_result) {
return rocksdb::Status::InvalidArgument(parse_result.Msg());
}
- RedisCommand cmd = static_cast<RedisCommand>(*parse_result);
+ auto cmd = static_cast<RedisCommand>(*parse_result);
if (cmd == kRedisCmdExpire) {
command_args = {"EXPIREAT", user_key, std::to_string(metadata.expire)};
resp_commands_[ns].emplace_back(Redis::Command2RESP(command_args));
@@ -103,7 +103,7 @@ rocksdb::Status WriteBatchExtractor::PutCF(uint32_t column_family_id, const Slic
if (!parse_result) {
return rocksdb::Status::InvalidArgument(parse_result.Msg());
}
- RedisCommand cmd = static_cast<RedisCommand>(*parse_result);
+ auto cmd = static_cast<RedisCommand>(*parse_result);
switch (cmd) {
case kRedisCmdLSet:
if (args->size() < 2) {
@@ -149,7 +149,7 @@ rocksdb::Status WriteBatchExtractor::PutCF(uint32_t column_family_id, const Slic
if (!parse_result) {
return rocksdb::Status::InvalidArgument(parse_result.Msg());
}
- RedisCommand cmd = static_cast<RedisCommand>(*parse_result);
+ auto cmd = static_cast<RedisCommand>(*parse_result);
switch (cmd) {
case kRedisCmdSetBit: {
if (args->size() < 2) {
@@ -240,7 +240,7 @@ rocksdb::Status WriteBatchExtractor::DeleteCF(uint32_t column_family_id, const S
if (!parse_result) {
return rocksdb::Status::InvalidArgument(parse_result.Msg());
}
- RedisCommand cmd = static_cast<RedisCommand>(*parse_result);
+ auto cmd = static_cast<RedisCommand>(*parse_result);
switch (cmd) {
case kRedisCmdLTrim:
if (first_seen_) {
diff --git a/src/types/redis_bitmap.cc b/src/types/redis_bitmap.cc
index 9544a747..8d800dd2 100644
--- a/src/types/redis_bitmap.cc
+++ b/src/types/redis_bitmap.cc
@@ -247,8 +247,8 @@ rocksdb::Status Bitmap::BitCount(const Slice &user_key, int64_t start, int64_t s
if (stop > static_cast<int64_t>(metadata.size)) stop = metadata.size;
if (start < 0 || stop <= 0 || start >= stop) return rocksdb::Status::OK();
- uint32_t u_start = static_cast<uint32_t>(start);
- uint32_t u_stop = static_cast<uint32_t>(stop);
+ auto u_start = static_cast<uint32_t>(start);
+ auto u_stop = static_cast<uint32_t>(stop);
LatestSnapShot ss(db_);
rocksdb::ReadOptions read_options;
@@ -297,8 +297,8 @@ rocksdb::Status Bitmap::BitPos(const Slice &user_key, bool bit, int64_t start, i
*pos = -1;
return rocksdb::Status::OK();
}
- uint32_t u_start = static_cast<uint32_t>(start);
- uint32_t u_stop = static_cast<uint32_t>(stop);
+ auto u_start = static_cast<uint32_t>(start);
+ auto u_stop = static_cast<uint32_t>(stop);
auto bitPosInByte = [](char byte, bool bit) -> int {
for (int i = 0; i < 8; i++) {
@@ -430,7 +430,7 @@ rocksdb::Status Bitmap::BitOp(BitOpFlags op_flag, const std::string &op_name, co
#ifndef USE_ALIGNED_ACCESS
if (frag_minlen >= sizeof(uint64_t) * 4 && frag_numkeys <= 16) {
- uint64_t *lres = reinterpret_cast<uint64_t *>(frag_res.get());
+ auto *lres = reinterpret_cast<uint64_t *>(frag_res.get());
const uint64_t *lp[16];
for (i = 0; i < frag_numkeys; i++) {
lp[i] = reinterpret_cast<const uint64_t *>(fragments[i].data());