From 3fdadf3eb54c7ab650582cda6c83bb8813f8ce8c Mon Sep 17 00:00:00 2001 From: SChernykh Date: Tue, 23 May 2023 20:11:00 +0200 Subject: [PATCH] Fixed cppcheck errors --- src/log.cpp | 4 ++-- src/p2p_server.cpp | 4 ++-- src/side_chain.cpp | 2 +- src/tcp_server.cpp | 2 +- src/zmq_reader.cpp | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/log.cpp b/src/log.cpp index d2c9aab..07591fd 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -290,9 +290,9 @@ private: static FORCEINLINE void strip_colors(char* buf, uint32_t& size) { - char* p_read = buf; + const char* p_read = buf; char* p_write = buf; - char* buf_end = buf + size; + const char* buf_end = buf + size; bool is_color = false; diff --git a/src/p2p_server.cpp b/src/p2p_server.cpp index 7a52512..869c836 100644 --- a/src/p2p_server.cpp +++ b/src/p2p_server.cpp @@ -1714,7 +1714,7 @@ void P2PServer::P2PClient::send_handshake_solution(const uint8_t (&challenge)[CH return; } - uint64_t* value = reinterpret_cast(work->solution.h); + const uint64_t* value = reinterpret_cast(work->solution.h); uint64_t high; umul128(value[HASH_SIZE / sizeof(uint64_t) - 1], CHALLENGE_DIFFICULTY, &high); @@ -1861,7 +1861,7 @@ bool P2PServer::P2PClient::on_handshake_solution(const uint8_t* buf) // Check that incoming connection provided enough PoW if (m_isIncoming) { - uint64_t* value = reinterpret_cast(solution.h); + const uint64_t* value = reinterpret_cast(solution.h); uint64_t high; umul128(value[HASH_SIZE / sizeof(uint64_t) - 1], CHALLENGE_DIFFICULTY, &high); diff --git a/src/side_chain.cpp b/src/side_chain.cpp index e831e49..c3d2549 100644 --- a/src/side_chain.cpp +++ b/src/side_chain.cpp @@ -940,7 +940,7 @@ void SideChain::print_status(bool obtain_sidechain_lock) const blocks_in_window.emplace(uncle_id); auto it = m_blocksById.find(uncle_id); if (it != m_blocksById.end()) { - PoolBlock* uncle = it->second; + const PoolBlock* uncle = it->second; if (tip_height - uncle->m_sidechainHeight < window_size) { ++total_uncles_in_window; if (uncle->m_minerWallet == w) { diff --git a/src/tcp_server.cpp b/src/tcp_server.cpp index b1dfa69..2181475 100644 --- a/src/tcp_server.cpp +++ b/src/tcp_server.cpp @@ -1119,7 +1119,7 @@ bool TCPServer::Client::on_proxy_handshake(char* data, uint32_t size) case Socks5ProxyState::ConnectRequestSent: if (m_numRead >= 4) { - uint8_t* p = reinterpret_cast(m_readBuf); + const uint8_t* p = reinterpret_cast(m_readBuf); if ((p[0] != 5) && (p[1] != 0) && p[2] != 0) { LOGWARN(5, "SOCKS5 proxy returned an invalid reply to CONNECT"); return false; diff --git a/src/zmq_reader.cpp b/src/zmq_reader.cpp index 9868d21..3ffac89 100644 --- a/src/zmq_reader.cpp +++ b/src/zmq_reader.cpp @@ -188,7 +188,7 @@ bool ZMQReader::connect(const std::string& address) void ZMQReader::parse(char* data, size_t size) { char* value = data; - char* end = data + size; + const char* end = data + size; while ((value < end) && (*value != ':')) { ++value;