Added cppcheck scripts

pull/11/head
SChernykh 2021-09-02 12:29:50 +02:00
parent 7092667301
commit bab148fbad
14 changed files with 30 additions and 6 deletions

8
cppcheck/includes.txt Normal file
View File

@ -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/

3
cppcheck/run.cmd Normal file
View File

@ -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

3
cppcheck/run.sh Normal file
View File

@ -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

View File

@ -0,0 +1,6 @@
missingIncludeSystem
unusedFunction
useStlAlgorithm
functionStatic
functionConst
unmatchedSuppression

View File

@ -95,6 +95,7 @@ BlockTemplate::BlockTemplate(const BlockTemplate& b)
*this = b;
}
// cppcheck-suppress operatorEqVarError
BlockTemplate& BlockTemplate::operator=(const BlockTemplate& b)
{
if (this == &b) {

View File

@ -288,6 +288,7 @@ NOINLINE void Stream::writeCurrentTime()
m_numberWidth = 4;
*this << (mcs / 100);
// cppcheck-suppress redundantAssignment
m_numberWidth = 1;
}

View File

@ -24,7 +24,7 @@
#include <atomic>
#include <type_traits>
#include "dbghelp.h"
#include <DbgHelp.h>
#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];

View File

@ -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();

View File

@ -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();
}

View File

@ -72,6 +72,7 @@ PoolBlock::PoolBlock(const PoolBlock& b)
operator=(b);
}
// cppcheck-suppress operatorEqVarError
PoolBlock& PoolBlock::operator=(const PoolBlock& b)
{
if (this == &b) {

View File

@ -201,6 +201,7 @@ int PoolBlock::deserialize(const uint8_t* data, size_t size, SideChain& sidechai
const int sidechain_hash_offset = static_cast<int>((data - data_begin) + outputs_blob_size_diff);
READ_BUF(m_sidechainId.h, HASH_SIZE);
// cppcheck-suppress duplicateExpression
if (static_cast<uint64_t>(data - tx_extra_begin) != tx_extra_size) return __LINE__;
EXPECT_BYTE(0);

View File

@ -748,7 +748,7 @@ void TCPServer<READ_BUF_SIZE, WRITE_BUF_SIZE>::on_new_client_nolock(uv_stream_t*
template<size_t READ_BUF_SIZE, size_t WRITE_BUF_SIZE>
TCPServer<READ_BUF_SIZE, WRITE_BUF_SIZE>::Client::Client()
{
reset();
Client::reset();
uv_mutex_init_checked(&m_writeBuffersLock);
uv_mutex_init_checked(&m_sendLock);

View File

@ -98,7 +98,7 @@ template<typename T, size_t N> FORCEINLINE constexpr size_t array_size(T(&)[N])
void make_thread_background();
class BackgroundJobTracker
class BackgroundJobTracker : public nocopy_nomove
{
public:
BackgroundJobTracker();

View File

@ -103,6 +103,7 @@ Wallet::Wallet(const Wallet& w)
operator=(w);
}
// cppcheck-suppress operatorEqVarError
Wallet& Wallet::operator=(const Wallet& w)
{
if (this == &w) {