diff --git a/cppcheck/includes.txt b/cppcheck/includes.txt new file mode 100644 index 0000000..157f7ad --- /dev/null +++ b/cppcheck/includes.txt @@ -0,0 +1,8 @@ +../src/ +../external/src/ +../external/src/cryptonote/ +../external/src/libuv/ +../external/src/cppzmq/ +../external/src/libzmq/ +../external/src/llhttp/ +../external/src/randomx/src/ diff --git a/cppcheck/run.cmd b/cppcheck/run.cmd new file mode 100644 index 0000000..892c467 --- /dev/null +++ b/cppcheck/run.cmd @@ -0,0 +1,3 @@ +@echo off +"C:\Program Files\cppcheck\cppcheck.exe" --project=..\build\p2pool.vcxproj --project-configuration="Release|x64" -DZMQ_STATIC --platform=win64 --std=c++14 --enable=all --inconclusive --inline-suppr --template="{file}:{line}:{id}{inconclusive: INCONCLUSIVE} {message}" --includes-file=includes.txt --suppressions-list=suppressions.txt --output-file=errors_full.txt +findstr /V /C:"external\src" errors_full.txt > errors_filtered.txt diff --git a/cppcheck/run.sh b/cppcheck/run.sh new file mode 100644 index 0000000..844cffc --- /dev/null +++ b/cppcheck/run.sh @@ -0,0 +1,3 @@ +#!/bin/bash +cppcheck ../src -DZMQ_STATIC --platform=unix64 --std=c++14 --enable=all --inconclusive --inline-suppr --template="{file}:{line}:{id}{inconclusive: INCONCLUSIVE} {message}" -I ../src/ -I ../external/src/ -I ../external/src/cryptonote/ -I ../external/src/libuv/ -I ../external/src/cppzmq/ -I ../external/src/libzmq/ -I ../external/src/llhttp/ -I ../external/src/randomx/src/ --suppressions-list=suppressions.txt --output-file=errors_full.txt +grep -v 'external' errors_full.txt > errors_filtered.txt diff --git a/cppcheck/suppressions.txt b/cppcheck/suppressions.txt new file mode 100644 index 0000000..127f474 --- /dev/null +++ b/cppcheck/suppressions.txt @@ -0,0 +1,6 @@ +missingIncludeSystem +unusedFunction +useStlAlgorithm +functionStatic +functionConst +unmatchedSuppression diff --git a/src/block_template.cpp b/src/block_template.cpp index e6eb4d1..9fb4d3f 100644 --- a/src/block_template.cpp +++ b/src/block_template.cpp @@ -95,6 +95,7 @@ BlockTemplate::BlockTemplate(const BlockTemplate& b) *this = b; } +// cppcheck-suppress operatorEqVarError BlockTemplate& BlockTemplate::operator=(const BlockTemplate& b) { if (this == &b) { diff --git a/src/log.cpp b/src/log.cpp index bd2557c..81c9fc3 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -288,6 +288,7 @@ NOINLINE void Stream::writeCurrentTime() m_numberWidth = 4; *this << (mcs / 100); + // cppcheck-suppress redundantAssignment m_numberWidth = 1; } diff --git a/src/memory_leak_debug.cpp b/src/memory_leak_debug.cpp index 13d2fbc..13c11a9 100644 --- a/src/memory_leak_debug.cpp +++ b/src/memory_leak_debug.cpp @@ -24,7 +24,7 @@ #include #include -#include "dbghelp.h" +#include #pragma comment(lib, "Dbghelp.lib") @@ -103,10 +103,8 @@ FORCEINLINE static void remove_allocation(void* p) const size_t index = hasher(p) & (N - 1); - bool found = false; for (uint32_t prev = 0, k = first[index]; k != 0; prev = k, k = next[k]) { if (allocations[k].p == p) { - found = true; allocations[k].allocated_size = 0; if (prev) { next[prev] = next[k]; diff --git a/src/p2pool.cpp b/src/p2pool.cpp index 43904c9..6c3a69b 100644 --- a/src/p2pool.cpp +++ b/src/p2pool.cpp @@ -810,7 +810,7 @@ void p2pool::api_update_pool_stats() } uint64_t t; - const difficulty_type diff = m_sideChain->difficulty(); + const difficulty_type& diff = m_sideChain->difficulty(); const uint64_t hashrate = udiv128(diff.hi, diff.lo, m_sideChain->block_time(), &t); const uint64_t miners = m_sideChain->miner_count(); const difficulty_type total_hashes = m_sideChain->total_hashes(); diff --git a/src/p2pool_api.cpp b/src/p2pool_api.cpp index 44d5c72..dccf2dc 100644 --- a/src/p2pool_api.cpp +++ b/src/p2pool_api.cpp @@ -120,6 +120,7 @@ void p2pool_api::dump_to_file() { MutexLock lock(m_dumpDataLock); data = std::move(m_dumpData); + // cppcheck-suppress accessMoved m_dumpData.clear(); } diff --git a/src/pool_block.cpp b/src/pool_block.cpp index 0331f7f..e9e884f 100644 --- a/src/pool_block.cpp +++ b/src/pool_block.cpp @@ -72,6 +72,7 @@ PoolBlock::PoolBlock(const PoolBlock& b) operator=(b); } +// cppcheck-suppress operatorEqVarError PoolBlock& PoolBlock::operator=(const PoolBlock& b) { if (this == &b) { diff --git a/src/pool_block_parser.inl b/src/pool_block_parser.inl index bdfaf7e..5ec637c 100644 --- a/src/pool_block_parser.inl +++ b/src/pool_block_parser.inl @@ -201,6 +201,7 @@ int PoolBlock::deserialize(const uint8_t* data, size_t size, SideChain& sidechai const int sidechain_hash_offset = static_cast((data - data_begin) + outputs_blob_size_diff); READ_BUF(m_sidechainId.h, HASH_SIZE); + // cppcheck-suppress duplicateExpression if (static_cast(data - tx_extra_begin) != tx_extra_size) return __LINE__; EXPECT_BYTE(0); diff --git a/src/tcp_server.inl b/src/tcp_server.inl index 5d17aa0..2e2022e 100644 --- a/src/tcp_server.inl +++ b/src/tcp_server.inl @@ -748,7 +748,7 @@ void TCPServer::on_new_client_nolock(uv_stream_t* template TCPServer::Client::Client() { - reset(); + Client::reset(); uv_mutex_init_checked(&m_writeBuffersLock); uv_mutex_init_checked(&m_sendLock); diff --git a/src/util.h b/src/util.h index c04edcc..a894d7f 100644 --- a/src/util.h +++ b/src/util.h @@ -98,7 +98,7 @@ template FORCEINLINE constexpr size_t array_size(T(&)[N]) void make_thread_background(); -class BackgroundJobTracker +class BackgroundJobTracker : public nocopy_nomove { public: BackgroundJobTracker(); diff --git a/src/wallet.cpp b/src/wallet.cpp index d0cca63..65319d4 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -103,6 +103,7 @@ Wallet::Wallet(const Wallet& w) operator=(w); } +// cppcheck-suppress operatorEqVarError Wallet& Wallet::operator=(const Wallet& w) { if (this == &w) {