Skip to content

Commit 446c732

Browse files
committed
expand clang-tidy checks to category/rpc
1 parent 7c1f641 commit 446c732

28 files changed

+254
-165
lines changed

category/core/hash.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ struct fnv1a_hash
3838
static constexpr working_type prime = 1099511628211ULL;
3939
unsigned char const *const _v =
4040
reinterpret_cast<unsigned char const *>(&v);
41+
// NOLINTNEXTLINE(bugprone-sizeof-expression)
4142
for (size_t n = 0; n < sizeof(T); n++) {
4243
hash ^= static_cast<working_type>(_v[n]);
4344
hash *= prime;

category/core/lru/lru_cache.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class LruCache
135135
void try_update_lru(ListNode *node)
136136
{
137137
if (node->check_lru_time()) {
138-
std::unique_lock l(mutex_);
138+
std::unique_lock const l(mutex_);
139139
STATS_EVENT_UPDATE_LRU();
140140
lru_.update_lru(node);
141141
}
@@ -146,7 +146,7 @@ class LruCache
146146
size_t sz = size();
147147
bool const evicted = (sz >= max_size_) && evict();
148148
{
149-
std::unique_lock l(mutex_);
149+
std::unique_lock const l(mutex_);
150150
STATS_EVENT_INSERT_NEW();
151151
lru_.push_front(node);
152152
}
@@ -170,7 +170,7 @@ class LruCache
170170
{
171171
ListNode *target;
172172
{
173-
std::unique_lock l(mutex_);
173+
std::unique_lock const l(mutex_);
174174
STATS_EVENT_EVICT();
175175
target = lru_.evict();
176176
}
@@ -196,9 +196,9 @@ class LruCache
196196
Key key_;
197197
std::atomic<int64_t> lru_time_{0};
198198

199-
ListNode() {}
199+
ListNode() = default;
200200

201-
ListNode(Key const &key)
201+
explicit ListNode(Key const &key)
202202
: key_(key)
203203
{
204204
}
@@ -297,7 +297,7 @@ class LruCache
297297
Value value_;
298298
ListNode *node_;
299299

300-
HashMapValue() {}
300+
HashMapValue() = default;
301301

302302
HashMapValue(Value const &value, ListNode *const node)
303303
: value_(value)

category/core/mem/batch_mem_pool.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class BatchMemPool
5353
#endif
5454

5555
public:
56-
BatchMemPool(size_t const initial, size_t const batch = 1024)
56+
explicit BatchMemPool(size_t const initial, size_t const batch = 1024)
5757
: pool_{sizeof(T), initial}
5858
{
5959
void *p = pool_.malloc();

category/execution/ethereum/block_hash_buffer.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class BlockHashChain
8585
std::deque<Proposal> proposals_;
8686

8787
public:
88-
BlockHashChain(BlockHashBufferFinalized &);
88+
explicit BlockHashChain(BlockHashBufferFinalized &);
8989

9090
void propose(
9191
bytes32_t const &, uint64_t block_number, bytes32_t const &block_id,

category/execution/ethereum/db/trie_db.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class TrieDb final : public ::monad::Db
5454
::monad::mpt::Node::SharedPtr curr_root_;
5555

5656
public:
57-
TrieDb(mpt::Db &);
57+
explicit TrieDb(mpt::Db &);
5858
~TrieDb();
5959

6060
void reset_root(::monad::mpt::Node::SharedPtr root, uint64_t block_number);

category/execution/ethereum/db/trie_rodb.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class TrieRODb final : public ::monad::Db
3737
::monad::mpt::CacheNodeCursor prefix_cursor_;
3838

3939
public:
40-
TrieRODb(mpt::RODb &db)
40+
explicit TrieRODb(mpt::RODb &db)
4141
: db_(db)
4242
, block_number_(mpt::INVALID_BLOCK_NUM)
4343
, prefix_cursor_()

category/execution/ethereum/rlp/decode.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ constexpr Result<byte_string_view> parse_string_metadata(byte_string_view &enc)
8282
else // [0xb8, 0xbf]
8383
{
8484
++i;
85-
uint8_t length_of_length = enc[0] - 0xb7;
85+
uint8_t const length_of_length = enc[0] - 0xb7;
8686

8787
if (MONAD_UNLIKELY(i + length_of_length >= enc.size())) {
8888
return DecodeError::InputTooShort;
@@ -156,6 +156,7 @@ decode_byte_string_fixed(byte_string_view &enc)
156156
if (MONAD_UNLIKELY(payload.size() != N)) {
157157
return DecodeError::ArrayLengthUnexpected;
158158
}
159+
// NOLINTNEXTLINE(bugprone-suspicious-stringview-data-usage)
159160
std::memcpy(bsf.data(), payload.data(), N);
160161
return bsf;
161162
}

category/execution/ethereum/rlp/encode2.hpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ inline byte_string const EMPTY_STRING = {0x80};
2828

2929
inline byte_string_view zeroless_view(byte_string_view const string_view)
3030
{
31-
auto b = string_view.begin();
32-
auto const e = string_view.end();
31+
auto const *b = string_view.begin();
32+
auto const *e = string_view.end();
3333
while (b < e && *b == 0) {
3434
++b;
3535
}
@@ -73,11 +73,15 @@ byte_string encode_list2(Args const &...args)
7373
if (size > 55) {
7474
auto const size_str = to_big_compact(size);
7575
MONAD_ASSERT(size_str.size() <= 8u);
76-
result += (0xf7 + static_cast<unsigned char>(size_str.size()));
76+
result +=
77+
(static_cast<unsigned char>(0xf7) +
78+
static_cast<unsigned char>(size_str.size()));
7779
result += size_str;
7880
}
7981
else {
80-
result += (0xc0 + static_cast<unsigned char>(size));
82+
result +=
83+
(static_cast<unsigned char>(0xc0) +
84+
static_cast<unsigned char>(size));
8185
}
8286
([&] { result += args; }(), ...);
8387
return result;

category/execution/ethereum/state3/account_state.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class AccountState : public AccountSubstate
7777

7878
public:
7979
explicit AccountState(std::optional<Account> &&account)
80-
: account_{std::move(account)}
80+
: account_{account}
8181
{
8282
}
8383

@@ -162,7 +162,7 @@ class OriginalAccountState final : public AccountState
162162

163163
public:
164164
explicit OriginalAccountState(std::optional<Account> &&account)
165-
: AccountState(std::move(account))
165+
: AccountState(account)
166166
{
167167
}
168168

category/execution/ethereum/state3/version_stack.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class VersionStack
2929
std::deque<std::pair<unsigned, T>> stack_{};
3030

3131
public:
32-
VersionStack(T value, unsigned version = 0)
32+
explicit VersionStack(T value, unsigned version = 0)
3333
{
3434
stack_.emplace_back(version, std::move(value));
3535
}

0 commit comments

Comments
 (0)