Skip to content

Commit

Permalink
Fixed cppcheck errors
Browse files Browse the repository at this point in the history
  • Loading branch information
SChernykh committed Nov 30, 2024
1 parent 7b1b526 commit d7cd9d2
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/console_commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ void ConsoleCommands::stdinReadCallback(uv_stream_t* stream, ssize_t nread, cons
}


void ConsoleCommands::process_input(std::string& command, char* data, uint32_t size)
void ConsoleCommands::process_input(std::string& command, const char* data, uint32_t size)
{
command.append(data, size);

Expand Down
4 changes: 2 additions & 2 deletions src/console_commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ConsoleCommands : public TCPServer
size_t size() const override { return sizeof(ConsoleClient); }

bool on_connect() override { return true; };
bool on_read(char* data, uint32_t size) override { static_cast<ConsoleCommands*>(m_owner)->process_input(m_command, data, size); return true; };
bool on_read(const char* data, uint32_t size) override { static_cast<ConsoleCommands*>(m_owner)->process_input(m_command, data, size); return true; };

char m_consoleReadBuf[1024] = {};

Expand All @@ -66,7 +66,7 @@ class ConsoleCommands : public TCPServer
static void allocCallback(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf);
static void stdinReadCallback(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf);

void process_input(std::string& command, char* data, uint32_t size);
void process_input(std::string& command, const char* data, uint32_t size);
};

} // namespace p2pool
2 changes: 1 addition & 1 deletion src/merge_mining_client_tari.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ bool MergeMiningClientTari::TariClient::on_connect()
return true;
}

bool MergeMiningClientTari::TariClient::on_read(char* data, uint32_t size)
bool MergeMiningClientTari::TariClient::on_read(const char* data, uint32_t size)
{
MergeMiningClientTari::TariServer* server = static_cast<MergeMiningClientTari::TariServer*>(m_owner);
if (!server) {
Expand Down
2 changes: 1 addition & 1 deletion src/merge_mining_client_tari.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class MergeMiningClientTari : public IMergeMiningClient, public nocopy_nomove

void reset() override;
[[nodiscard]] bool on_connect() override;
[[nodiscard]] bool on_read(char* data, uint32_t size) override;
[[nodiscard]] bool on_read(const char* data, uint32_t size) override;

char m_buf[BUF_SIZE];
std::vector<uint8_t> m_pendingData;
Expand Down
2 changes: 1 addition & 1 deletion src/p2p_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1496,7 +1496,7 @@ bool P2PServer::P2PClient::on_connect()
return send_handshake_challenge();
}

bool P2PServer::P2PClient::on_read(char* data, uint32_t size)
bool P2PServer::P2PClient::on_read(const char* data, uint32_t size)
{
P2PServer* server = static_cast<P2PServer*>(m_owner);
if (!server) {
Expand Down
2 changes: 1 addition & 1 deletion src/p2p_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class P2PServer : public TCPServer

void reset() override;
[[nodiscard]] bool on_connect() override;
[[nodiscard]] bool on_read(char* data, uint32_t size) override;
[[nodiscard]] bool on_read(const char* data, uint32_t size) override;
void on_read_failed(int err) override;
void on_disconnected() override;

Expand Down
4 changes: 2 additions & 2 deletions src/stratum_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,7 @@ bool StratumServer::StratumClient::on_connect()
return true;
}

bool StratumServer::StratumClient::on_read(char* data, uint32_t size)
bool StratumServer::StratumClient::on_read(const char* data, uint32_t size)
{
#ifdef WITH_TLS
if (!m_tlsChecked) {
Expand All @@ -1186,7 +1186,7 @@ bool StratumServer::StratumClient::on_read(char* data, uint32_t size)
}
#endif

auto on_parse = [this](char* data, uint32_t size) {
auto on_parse = [this](const char* data, uint32_t size) {
if (static_cast<size_t>(m_stratumReadBufBytes) + size > STRATUM_BUF_SIZE) {
LOGWARN(4, "client " << static_cast<const char*>(m_addrString) << " sent too long Stratum message");
ban(DEFAULT_BAN_TIME);
Expand Down
2 changes: 1 addition & 1 deletion src/stratum_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class StratumServer : public TCPServer

void reset() override;
[[nodiscard]] bool on_connect() override;
[[nodiscard]] bool on_read(char* data, uint32_t size) override;
[[nodiscard]] bool on_read(const char* data, uint32_t size) override;

[[nodiscard]] bool process_request(char* data, uint32_t size);
[[nodiscard]] bool process_login(rapidjson::Document& doc, uint32_t id);
Expand Down
2 changes: 1 addition & 1 deletion src/tcp_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ void TCPServer::Client::on_read(uv_stream_t* stream, ssize_t nread, const uv_buf
}
}

bool TCPServer::Client::on_proxy_handshake(char* data, uint32_t size)
bool TCPServer::Client::on_proxy_handshake(const char* data, uint32_t size)
{
if ((data != m_readBuf + m_numRead) || (data + size > m_readBuf + m_readBufSize)) {
LOGERR(1, "peer " << static_cast<char*>(m_addrString) << " invalid data pointer or size in on_read()");
Expand Down
4 changes: 2 additions & 2 deletions src/tcp_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ class TCPServer : public nocopy_nomove

virtual void reset();
[[nodiscard]] virtual bool on_connect() = 0;
[[nodiscard]] virtual bool on_read(char* data, uint32_t size) = 0;
[[nodiscard]] bool on_proxy_handshake(char* data, uint32_t size);
[[nodiscard]] virtual bool on_read(const char* data, uint32_t size) = 0;
[[nodiscard]] bool on_proxy_handshake(const char* data, uint32_t size);
virtual void on_read_failed(int /*err*/) {}
virtual void on_disconnected() {}

Expand Down
2 changes: 1 addition & 1 deletion src/tls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ bool ServerTls::init()
return true;
}

bool ServerTls::on_read_internal(char* data, uint32_t size, ReadCallback::Base&& read_callback, WriteCallback::Base&& write_callback)
bool ServerTls::on_read_internal(const char* data, uint32_t size, ReadCallback::Base&& read_callback, WriteCallback::Base&& write_callback)
{
SSL* ssl = m_ssl.get();
if (!ssl) {
Expand Down
4 changes: 2 additions & 2 deletions src/tls.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ServerTls
[[nodiscard]] bool init();

template<typename T, typename U>
[[nodiscard]] FORCEINLINE bool on_read(char* data, uint32_t size, T&& read_callback, U&& write_callback)
[[nodiscard]] FORCEINLINE bool on_read(const char* data, uint32_t size, T&& read_callback, U&& write_callback)
{
return on_read_internal(data, size, ReadCallback::Derived<T>(std::move(read_callback)), WriteCallback::Derived<U>(std::move(write_callback)));
}
Expand All @@ -60,7 +60,7 @@ class ServerTls
typedef Callback<bool, char*, uint32_t> ReadCallback;
typedef Callback<bool, const uint8_t*, size_t> WriteCallback;

[[nodiscard]] bool on_read_internal(char* data, uint32_t size, ReadCallback::Base&& read_callback, WriteCallback::Base&& write_callback);
[[nodiscard]] bool on_read_internal(const char* data, uint32_t size, ReadCallback::Base&& read_callback, WriteCallback::Base&& write_callback);
[[nodiscard]] bool on_write_internal(const uint8_t* data, size_t size, WriteCallback::Base&& write_callback);

private:
Expand Down

0 comments on commit d7cd9d2

Please sign in to comment.