Skip to content

Commit 65190ea

Browse files
clang-tidy warnings fixes (#553)
Signed-off-by: Alexey Chernyshov <[email protected]>
1 parent 365a7c3 commit 65190ea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+248
-211
lines changed

core/cbor_blake/ipld_any.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ namespace fc {
4848

4949
static bool get(const IpldPtr &ipld, const CbCid &key, Bytes *value) {
5050
const CID cid{key};
51-
if (value) {
51+
if (value != nullptr) {
5252
if (auto r{ipld->get(cid)}) {
5353
*value = std::move(r.value());
5454
return true;

core/codec/cbor/light_reader/hamt_walk.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ namespace fc::codec::cbor::light_reader {
1818
* @param[out] value
1919
* @return
2020
*/
21+
// NOLINTNEXTLINE(readability-function-cognitive-complexity)
2122
inline bool next(BytesIn &key, BytesIn &value) {
2223
cbor::CborToken token;
2324
while (!empty()) {
24-
if (_bucket) {
25+
if (_bucket != 0) {
2526
--_bucket;
2627
if (read(token, node).listCount() != 2) {
2728
return false;
@@ -69,7 +70,7 @@ namespace fc::codec::cbor::light_reader {
6970
}
7071
}
7172
if (token.cidSize()) {
72-
const CbCid *cid;
73+
const CbCid *cid = nullptr;
7374
if (!readCborBlake(cid, token, node)) {
7475
return false;
7576
}

core/codec/cbor/light_reader/miner_actor_reader.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace fc::codec::cbor::light_reader {
3636
return kParseError;
3737
}
3838
// read miner info CID
39-
const CbCid *miner_info;
39+
const CbCid *miner_info = nullptr;
4040
if (!cbor::readCborBlake(miner_info, input)) {
4141
return kParseError;
4242
}
@@ -76,7 +76,7 @@ namespace fc::codec::cbor::light_reader {
7676
return kParseError;
7777
}
7878
// sectors
79-
const CbCid *sectors;
79+
const CbCid *sectors = nullptr;
8080
if (!cbor::readCborBlake(sectors, input)) {
8181
return kParseError;
8282
}
@@ -89,7 +89,7 @@ namespace fc::codec::cbor::light_reader {
8989
return kParseError;
9090
}
9191
// deadlines
92-
const CbCid *deadlines;
92+
const CbCid *deadlines = nullptr;
9393
if (!cbor::readCborBlake(deadlines, input)) {
9494
return kParseError;
9595
}

core/codec/cbor/light_reader/state_tree.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace fc::codec::cbor::light_reader {
2828
if (!read(token, input).asUint()) {
2929
return false;
3030
}
31-
const CbCid *cid;
31+
const CbCid *cid = nullptr;
3232
if (!cbor::readCborBlake(cid, input)) {
3333
return false;
3434
}

core/codec/cbor/light_reader/storage_power_actor_reader.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace fc::codec::cbor::light_reader {
4444
}
4545
}
4646
// claims
47-
const CbCid *claims;
47+
const CbCid *claims = nullptr;
4848
if (!cbor::readCborBlake(claims, input)) {
4949
return kParseError;
5050
}

core/common/bytes_stream.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace fc {
1515
boost::iostreams::array_source device;
1616
boost::iostreams::stream<decltype(device)> s;
1717

18-
BytesIstream(BytesIn bytes)
18+
explicit BytesIstream(BytesIn bytes)
1919
: device{common::span::bytestr(bytes.data()),
2020
static_cast<size_t>(bytes.size())},
2121
s{device} {}

core/common/libp2p/stream_read_buffer.hpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,23 @@ namespace libp2p::connection {
3131
readSome(out,
3232
out.size(),
3333
[weak{weak_from_this()}, out, n, cb{std::move(cb)}](
34-
outcome::result<size_t> _r) {
34+
outcome::result<size_t> _r) mutable {
3535
OUTCOME_CB(auto r, _r);
3636
if (auto self{weak.lock()}) {
3737
const auto _r{static_cast<ptrdiff_t>(r)};
3838
assert(_r <= out.size());
3939
if (_r == out.size()) {
4040
return cb(n);
4141
}
42-
self->readFull(out.subspan(r), n, std::move(cb));
42+
self->readFull(
43+
out.subspan(gsl::narrow<int64_t>(r)), n, std::move(cb));
4344
}
4445
});
4546
}
4647

4748
void read(BytesOut out, size_t n, ReadCallbackFunc cb) override {
4849
assert(out.size() >= static_cast<ptrdiff_t>(n));
49-
readFull(out.first(n), n, std::move(cb));
50+
readFull(out.first(gsl::narrow<int64_t>(n)), n, std::move(cb));
5051
}
5152

5253
void readSome(BytesOut out, size_t n, ReadCallbackFunc cb) override {
@@ -56,15 +57,16 @@ namespace libp2p::connection {
5657
}
5758
if (size() != 0) {
5859
n = std::min(n, size());
59-
std::copy_n(buffer->begin() + begin, n, out.begin());
60+
std::copy_n(
61+
buffer->begin() + gsl::narrow<int64_t>(begin), n, out.begin());
6062
begin += n;
6163
return cb(n);
6264
}
6365
stream->readSome(
6466
*buffer,
6567
buffer->size(),
6668
[weak{weak_from_this()}, out, n, cb{std::move(cb)}, buffer{buffer}](
67-
outcome::result<size_t> _r) {
69+
outcome::result<size_t> _r) mutable {
6870
OUTCOME_CB(auto r, _r);
6971
if (auto self{weak.lock()}) {
7072
self->begin = 0;

core/common/outcome_fmt.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct fmt::formatter<std::error_code, char, void> {
2222
const auto *it{ctx.begin()};
2323
if (it != ctx.end() && *it == '#') {
2424
alt = true;
25-
++it;
25+
std::advance(it, 1);
2626
}
2727
return it;
2828
}

core/const.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ namespace fc {
1414
using primitives::StoragePower;
1515
using primitives::TokenAmount;
1616

17+
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
1718
extern bool kFakeWinningPost;
1819
constexpr std::string_view kFakeWinningPostStr{"valid proof"};
1920

core/storage/car/cids_index/cids_index.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ namespace fc::storage::cids_index {
4242
/** fixed-size key */
4343
CbCid key;
4444
/** 40bit offset, up to 1TB */
45-
boost::endian::big_uint40_buf_t offset;
45+
boost::endian::big_uint40_buf_t offset{};
4646
/** 24bit(+6bit) size, up to 1GB */
4747
/** size64=0 means this row is meta */
48-
boost::endian::big_uint24_buf_t max_size64;
48+
boost::endian::big_uint24_buf_t max_size64{};
4949

5050
inline bool isMeta() const {
5151
return max_size64.value() == 0;
@@ -89,7 +89,9 @@ namespace fc::storage::cids_index {
8989
struct MergeRange {
9090
std::istream *file{};
9191
std::vector<Row> rows;
92-
size_t current{(size_t)-1}, begin{}, end{};
92+
size_t current = -1;
93+
size_t begin{};
94+
size_t end{};
9395

9496
inline auto &front() const {
9597
assert(current < rows.size());

0 commit comments

Comments
 (0)