mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-12-22 19:39:22 +00:00
Updated cppcheck workflow on Linux
This commit is contained in:
parent
d84bef8f14
commit
cb147773b5
21 changed files with 30 additions and 30 deletions
16
.github/workflows/cppcheck.yml
vendored
16
.github/workflows/cppcheck.yml
vendored
|
@ -12,14 +12,22 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Install cppcheck
|
|
||||||
run: sudo apt update && sudo apt install cppcheck
|
|
||||||
|
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
|
|
||||||
|
- name: Checkout cppcheck
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
repository: danmar/cppcheck
|
||||||
|
path: cppcheck-main
|
||||||
|
|
||||||
|
- name: Build cppcheck
|
||||||
|
run: |
|
||||||
|
cd cppcheck-main
|
||||||
|
make -j$(nproc) cppcheck
|
||||||
|
|
||||||
- name: Run cppcheck
|
- name: Run cppcheck
|
||||||
run: |
|
run: |
|
||||||
cd cppcheck
|
cd cppcheck
|
||||||
|
@ -27,7 +35,7 @@ jobs:
|
||||||
|
|
||||||
cppcheck-windows:
|
cppcheck-windows:
|
||||||
|
|
||||||
runs-on: windows-2022
|
runs-on: windows-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
../src/
|
../src/
|
||||||
../external/src/
|
../external/src/
|
||||||
../external/src/cryptonote/
|
../external/src/cryptonote/
|
||||||
../external/src/libuv/
|
../external/src/libuv/include/
|
||||||
../external/src/cppzmq/
|
../external/src/cppzmq/
|
||||||
../external/src/libzmq/
|
../external/src/libzmq/include/
|
||||||
../external/src/llhttp/
|
../external/src/llhttp/
|
||||||
../external/src/RandomX/src/
|
../external/src/RandomX/src/
|
||||||
../external/src/rapidjson/include
|
../external/src/rapidjson/include
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
@echo off
|
@echo off
|
||||||
"..\cppcheck-main\bin\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
|
"..\cppcheck-main\bin\cppcheck.exe" --project=..\build\p2pool.vcxproj --project-configuration="Release|x64" -DSIZE_MAX=UINT64_MAX -DRAPIDJSON_ENDIAN=RAPIDJSON_LITTLEENDIAN --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
|
findstr /V /C:"external\src" errors_full.txt > errors_filtered.txt
|
||||||
for /f %%i in ("errors_filtered.txt") do set size=%%~zi
|
for /f %%i in ("errors_filtered.txt") do set size=%%~zi
|
||||||
if %size% gtr 0 (
|
if %size% gtr 0 (
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/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/ -I ../external/src/rapidjson/include -I ../external/src/robin-hood-hashing/src/include --suppressions-list=suppressions.txt --output-file=errors_full.txt
|
../cppcheck-main/cppcheck ../src -DSIZE_MAX=UINT64_MAX -DRAPIDJSON_ENDIAN=RAPIDJSON_LITTLEENDIAN --platform=unix64 --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
|
||||||
grep -v 'external' errors_full.txt | grep -v 'unmatchedSuppression' > errors_filtered.txt
|
grep -v 'external' errors_full.txt > errors_filtered.txt
|
||||||
if [ -s errors_filtered.txt ]; then
|
if [ -s errors_filtered.txt ]; then
|
||||||
cat errors_filtered.txt
|
cat errors_filtered.txt
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
missingIncludeSystem
|
missingIncludeSystem
|
||||||
unusedFunction
|
unusedFunction
|
||||||
useStlAlgorithm
|
useStlAlgorithm
|
||||||
functionStatic
|
|
||||||
functionConst
|
|
||||||
unmatchedSuppression
|
|
||||||
|
|
|
@ -55,7 +55,6 @@ public:
|
||||||
|
|
||||||
void submit_sidechain_block(uint32_t template_id, uint32_t nonce, uint32_t extra_nonce);
|
void submit_sidechain_block(uint32_t template_id, uint32_t nonce, uint32_t extra_nonce);
|
||||||
|
|
||||||
FORCEINLINE uint64_t final_reward() const { return m_finalReward; }
|
|
||||||
FORCEINLINE const std::vector<MinerShare>& shares() const { return m_shares; }
|
FORCEINLINE const std::vector<MinerShare>& shares() const { return m_shares; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -238,6 +238,7 @@ private:
|
||||||
struct DerivationEntry
|
struct DerivationEntry
|
||||||
{
|
{
|
||||||
hash derivation;
|
hash derivation;
|
||||||
|
// cppcheck-suppress unusedStructMember
|
||||||
uint8_t view_tag;
|
uint8_t view_tag;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,7 @@ private:
|
||||||
static void on_alloc(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf);
|
static void on_alloc(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf);
|
||||||
static void on_read(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf);
|
static void on_read(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf);
|
||||||
void on_read(const char* data, size_t size);
|
void on_read(const char* data, size_t size);
|
||||||
|
// cppcheck-suppress functionConst
|
||||||
void close();
|
void close();
|
||||||
static void on_close(uv_handle_t* handle);
|
static void on_close(uv_handle_t* handle);
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,7 @@ NOINLINE void keccak(const uint8_t* in, int inlen, uint8_t* md, int mdlen)
|
||||||
temp[rsiz - 1] |= 0x80;
|
temp[rsiz - 1] |= 0x80;
|
||||||
|
|
||||||
for (int i = 0; i < rsizw; i++) {
|
for (int i = 0; i < rsizw; i++) {
|
||||||
st[i] ^= ((uint64_t*)temp)[i];
|
st[i] ^= reinterpret_cast<uint64_t*>(temp)[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
keccakf(st);
|
keccakf(st);
|
||||||
|
|
|
@ -276,7 +276,6 @@ static Worker worker;
|
||||||
|
|
||||||
#endif // P2POOL_LOG_DISABLE
|
#endif // P2POOL_LOG_DISABLE
|
||||||
|
|
||||||
// cppcheck-suppress uninitMemberVar
|
|
||||||
NOINLINE Writer::Writer(Severity severity) : Stream(m_stackBuf)
|
NOINLINE Writer::Writer(Severity severity) : Stream(m_stackBuf)
|
||||||
{
|
{
|
||||||
m_buf[0] = static_cast<char>(severity);
|
m_buf[0] = static_cast<char>(severity);
|
||||||
|
|
|
@ -378,7 +378,6 @@ template<> struct log::Stream::Entry<XMRAmount>
|
||||||
|
|
||||||
template<> struct log::Stream::Entry<NetworkType>
|
template<> struct log::Stream::Entry<NetworkType>
|
||||||
{
|
{
|
||||||
// cppcheck-suppress constParameter
|
|
||||||
static NOINLINE void put(NetworkType value, Stream* wrapper)
|
static NOINLINE void put(NetworkType value, Stream* wrapper)
|
||||||
{
|
{
|
||||||
switch (value) {
|
switch (value) {
|
||||||
|
|
|
@ -236,7 +236,9 @@ NOINLINE void operator delete(void* p, size_t) noexcept { p2pool::free_hook(p);
|
||||||
NOINLINE void operator delete[](void* p, size_t) noexcept { p2pool::free_hook(p); }
|
NOINLINE void operator delete[](void* p, size_t) noexcept { p2pool::free_hook(p); }
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
// cppcheck-suppress functionStatic
|
||||||
void memory_tracking_start() {}
|
void memory_tracking_start() {}
|
||||||
|
// cppcheck-suppress functionStatic
|
||||||
void memory_tracking_stop() {}
|
void memory_tracking_stop() {}
|
||||||
|
|
||||||
namespace p2pool {
|
namespace p2pool {
|
||||||
|
|
|
@ -151,6 +151,7 @@ void P2PServer::clear_cached_blocks()
|
||||||
|
|
||||||
WriteLock lock(m_cachedBlocksLock);
|
WriteLock lock(m_cachedBlocksLock);
|
||||||
|
|
||||||
|
// cppcheck-suppress identicalConditionAfterEarlyExit
|
||||||
if (!m_cachedBlocks) {
|
if (!m_cachedBlocks) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,12 +131,10 @@ void p2pool_api::dump_to_file()
|
||||||
{
|
{
|
||||||
MutexLock lock(m_dumpDataLock);
|
MutexLock lock(m_dumpDataLock);
|
||||||
data = std::move(m_dumpData);
|
data = std::move(m_dumpData);
|
||||||
// cppcheck-suppress accessMoved
|
|
||||||
m_dumpData.clear();
|
m_dumpData.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& it : data) {
|
for (auto& it : data) {
|
||||||
// cppcheck-suppress uninitvar
|
|
||||||
DumpFileWork* work = new DumpFileWork{ {}, {}, {}, it.first, std::move(it.second) };
|
DumpFileWork* work = new DumpFileWork{ {}, {}, {}, it.first, std::move(it.second) };
|
||||||
work->open_req.data = work;
|
work->open_req.data = work;
|
||||||
work->write_req.data = work;
|
work->write_req.data = work;
|
||||||
|
|
|
@ -34,6 +34,7 @@ public:
|
||||||
LOCAL,
|
LOCAL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// cppcheck-suppress functionConst
|
||||||
void on_stop();
|
void on_stop();
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
|
@ -187,7 +187,6 @@ 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);
|
const int sidechain_hash_offset = static_cast<int>((data - data_begin) + outputs_blob_size_diff);
|
||||||
READ_BUF(m_sidechainId.h, HASH_SIZE);
|
READ_BUF(m_sidechainId.h, HASH_SIZE);
|
||||||
|
|
||||||
// cppcheck-suppress duplicateExpression
|
|
||||||
if (static_cast<uint64_t>(data - tx_extra_begin) != tx_extra_size) return __LINE__;
|
if (static_cast<uint64_t>(data - tx_extra_begin) != tx_extra_size) return __LINE__;
|
||||||
|
|
||||||
EXPECT_BYTE(0);
|
EXPECT_BYTE(0);
|
||||||
|
|
|
@ -180,7 +180,6 @@ void RandomX_Hasher::set_seed(const hash& seed)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// cppcheck-suppress unreadVariable
|
|
||||||
ON_SCOPE_LEAVE([this]() { uv_rwlock_wrunlock(&m_cacheLock); });
|
ON_SCOPE_LEAVE([this]() { uv_rwlock_wrunlock(&m_cacheLock); });
|
||||||
|
|
||||||
if (m_stopped.load()) {
|
if (m_stopped.load()) {
|
||||||
|
@ -327,7 +326,6 @@ bool RandomX_Hasher::calculate(const void* data, size_t size, uint64_t /*height*
|
||||||
{
|
{
|
||||||
// First try to use the dataset if it's ready
|
// First try to use the dataset if it's ready
|
||||||
if (uv_rwlock_tryrdlock(&m_datasetLock) == 0) {
|
if (uv_rwlock_tryrdlock(&m_datasetLock) == 0) {
|
||||||
// cppcheck-suppress unreadVariable
|
|
||||||
ON_SCOPE_LEAVE([this]() { uv_rwlock_rdunlock(&m_datasetLock); });
|
ON_SCOPE_LEAVE([this]() { uv_rwlock_rdunlock(&m_datasetLock); });
|
||||||
|
|
||||||
if (m_stopped.load()) {
|
if (m_stopped.load()) {
|
||||||
|
|
|
@ -172,7 +172,7 @@ SideChain::~SideChain()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SideChain::fill_sidechain_data(PoolBlock& block, Wallet* w, const hash& txkeySec, std::vector<MinerShare>& shares) const
|
void SideChain::fill_sidechain_data(PoolBlock& block, const Wallet* w, const hash& txkeySec, std::vector<MinerShare>& shares) const
|
||||||
{
|
{
|
||||||
ReadLock lock(m_sidechainLock);
|
ReadLock lock(m_sidechainLock);
|
||||||
|
|
||||||
|
@ -228,11 +228,8 @@ void SideChain::fill_sidechain_data(PoolBlock& block, Wallet* w, const hash& txk
|
||||||
bool same_chain = false;
|
bool same_chain = false;
|
||||||
do {
|
do {
|
||||||
tmp = tip;
|
tmp = tip;
|
||||||
while (tmp->m_sidechainHeight > uncle->m_sidechainHeight) {
|
while (tmp && (tmp->m_sidechainHeight > uncle->m_sidechainHeight)) {
|
||||||
tmp = get_parent(tmp);
|
tmp = get_parent(tmp);
|
||||||
if (!tmp) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!tmp || (tmp->m_sidechainHeight < uncle->m_sidechainHeight)) {
|
if (!tmp || (tmp->m_sidechainHeight < uncle->m_sidechainHeight)) {
|
||||||
break;
|
break;
|
||||||
|
@ -1530,7 +1527,7 @@ bool SideChain::is_longer_chain(const PoolBlock* block, const PoolBlock* candida
|
||||||
// If these two blocks are on the same chain, they must have a common ancestor
|
// If these two blocks are on the same chain, they must have a common ancestor
|
||||||
|
|
||||||
const PoolBlock* block_ancestor = block;
|
const PoolBlock* block_ancestor = block;
|
||||||
while (block_ancestor->m_sidechainHeight > candidate->m_sidechainHeight) {
|
while (block_ancestor && (block_ancestor->m_sidechainHeight > candidate->m_sidechainHeight)) {
|
||||||
const hash& id = block_ancestor->m_parent;
|
const hash& id = block_ancestor->m_parent;
|
||||||
block_ancestor = get_parent(block_ancestor);
|
block_ancestor = get_parent(block_ancestor);
|
||||||
if (!block_ancestor) {
|
if (!block_ancestor) {
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
SideChain(p2pool* pool, NetworkType type, const char* pool_name = nullptr);
|
SideChain(p2pool* pool, NetworkType type, const char* pool_name = nullptr);
|
||||||
~SideChain();
|
~SideChain();
|
||||||
|
|
||||||
void fill_sidechain_data(PoolBlock& block, Wallet* w, const hash& txkeySec, std::vector<MinerShare>& shares) const;
|
void fill_sidechain_data(PoolBlock& block, const Wallet* w, const hash& txkeySec, std::vector<MinerShare>& shares) const;
|
||||||
|
|
||||||
bool block_seen(const PoolBlock& block);
|
bool block_seen(const PoolBlock& block);
|
||||||
void unsee_block(const PoolBlock& block);
|
void unsee_block(const PoolBlock& block);
|
||||||
|
|
|
@ -72,6 +72,7 @@ TCPServer<READ_BUF_SIZE, WRITE_BUF_SIZE>::TCPServer(allocate_client_callback all
|
||||||
}
|
}
|
||||||
|
|
||||||
template<size_t READ_BUF_SIZE, size_t WRITE_BUF_SIZE>
|
template<size_t READ_BUF_SIZE, size_t WRITE_BUF_SIZE>
|
||||||
|
// cppcheck-suppress functionStatic
|
||||||
TCPServer<READ_BUF_SIZE, WRITE_BUF_SIZE>::~TCPServer()
|
TCPServer<READ_BUF_SIZE, WRITE_BUF_SIZE>::~TCPServer()
|
||||||
{
|
{
|
||||||
if (m_finished.load() == 0) {
|
if (m_finished.load() == 0) {
|
||||||
|
|
|
@ -89,7 +89,6 @@ Wallet::Wallet(const Wallet& w)
|
||||||
operator=(w);
|
operator=(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
// cppcheck-suppress operatorEqVarError
|
|
||||||
Wallet& Wallet::operator=(const Wallet& w)
|
Wallet& Wallet::operator=(const Wallet& w)
|
||||||
{
|
{
|
||||||
if (this == &w) {
|
if (this == &w) {
|
||||||
|
@ -119,7 +118,7 @@ bool Wallet::decode(const char* address)
|
||||||
|
|
||||||
static_assert(last_block_size_index >= 0, "Check ADDRESS_LENGTH");
|
static_assert(last_block_size_index >= 0, "Check ADDRESS_LENGTH");
|
||||||
|
|
||||||
uint8_t data[static_cast<size_t>(num_full_blocks) * sizeof(uint64_t) + last_block_size_index];
|
uint8_t data[static_cast<size_t>(num_full_blocks) * sizeof(uint64_t) + last_block_size_index] = {};
|
||||||
int data_index = 0;
|
int data_index = 0;
|
||||||
|
|
||||||
for (int i = 0; i <= num_full_blocks; ++i) {
|
for (int i = 0; i <= num_full_blocks; ++i) {
|
||||||
|
|
Loading…
Reference in a new issue