Skip to content

Commit ddeff06

Browse files
committed
Fix clang-tidy issues
1 parent aba0e8b commit ddeff06

File tree

5 files changed

+26
-4
lines changed

5 files changed

+26
-4
lines changed

src/file_writer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ bytes FileWriter::read_block(uint32_t offset,
7676
return data;
7777
}
7878

79+
namespace {
80+
7981
/**
8082
* Interface for writing pieces to destination files. Subclasses
8183
* implements this for single and multi torrents.
@@ -252,6 +254,8 @@ shared_ptr<TorrentDestination> TorrentDestination::create(
252254
return make_shared<MultiTorrentDestination>(torrent, std::move(logger));
253255
}
254256

257+
} // namespace
258+
255259
void FileWriter::write_next_piece() {
256260
TorrentPiece t_piece;
257261
{

src/net.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ vector<string> get_host_ip_addresses() {
101101
return get_host_ip_addresses(asio::ip::host_name());
102102
}
103103

104+
} // namespace zit
105+
106+
namespace {
107+
104108
/**
105109
* When using asio::read_until we need to match multiple markers to handle non
106110
* standard responses.
@@ -117,7 +121,8 @@ class MatchMarkers {
117121
for (const auto& marker : m_markers) {
118122
auto m = std::search(begin, end, std::begin(marker), std::end(marker));
119123
if (m != end) {
120-
return std::make_pair(next(m, numeric_cast<long>(marker.size())), true);
124+
return std::make_pair(next(m, zit::numeric_cast<long>(marker.size())),
125+
true);
121126
}
122127
}
123128
return std::make_pair(end, false);
@@ -126,11 +131,11 @@ class MatchMarkers {
126131
private:
127132
vector<string> m_markers;
128133
};
129-
} // namespace zit
134+
} // namespace
130135

131136
// Need to explicitly mark this as a MatchCondition
132137
template <>
133-
struct asio::is_match_condition<zit::MatchMarkers> : public std::true_type {};
138+
struct asio::is_match_condition<MatchMarkers> : public std::true_type {};
134139

135140
namespace zit {
136141

src/socket_test/client.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include "common.hpp" // NOLINT(misc-include-cleaner)
2121
#include "logger.hpp"
2222

23+
namespace {
24+
2325
class Connection : public socket_test::ID {
2426
public:
2527
explicit Connection(asio::io_context& io_context)
@@ -56,6 +58,8 @@ class Connection : public socket_test::ID {
5658
asio::ip::tcp::socket m_socket;
5759
};
5860

61+
} // namespace
62+
5963
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
6064
unsigned socket_test::ID::m_counter = 0;
6165

src/socket_test/server.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include "common.hpp" // NOLINT(misc-include-cleaner)
2222
#include "logger.hpp"
2323

24+
namespace {
25+
2426
class Connection : public socket_test::ID {
2527
public:
2628
explicit Connection(asio::io_context& io_context,
@@ -66,6 +68,8 @@ class Connection : public socket_test::ID {
6668
asio::ip::tcp::socket m_socket;
6769
};
6870

71+
} // namespace
72+
6973
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
7074
unsigned socket_test::ID::m_counter = 0;
7175

src/torrent.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include <fmt/format.h>
2020
#include <spdlog/common.h>
21+
#include <asio/error.hpp>
2122
#include <asio/error_code.hpp>
2223
#include <asio/io_context.hpp>
2324

@@ -551,6 +552,8 @@ Torrent::http_tracker_request(const Url& announce_url, TrackerEvent event) {
551552
return {true, peers};
552553
}
553554

555+
namespace {
556+
554557
/**
555558
* Protocol documented here: https://libtorrent.org/udp_tracker_protocol.html
556559
*
@@ -828,6 +831,8 @@ class UDPTrackerRequest {
828831
TimePoint m_last_connection_id{ClockType::time_point::min()};
829832
};
830833

834+
} // namespace
835+
831836
std::pair<bool, std::vector<std::shared_ptr<Peer>>>
832837
Torrent::udp_tracker_request(const Url& announce_url, TrackerEvent event) {
833838
// FIXME: Replace this with a max size map, that throws out older request
@@ -1291,7 +1296,7 @@ void Torrent::reset_piece(uint32_t piece_id) {
12911296
const scoped_lock lock(m_mutex);
12921297
auto it = m_active_pieces.find(piece_id);
12931298
if (it != m_active_pieces.end()) {
1294-
it->second->reset();
1299+
(*it->second).reset();
12951300
m_client_pieces.at(piece_id) = false;
12961301
m_active_pieces.erase(it);
12971302
}

0 commit comments

Comments
 (0)