Fixed cppcheck issues

This commit is contained in:
SChernykh 2022-12-22 13:33:44 +01:00
parent a61966ed61
commit dffc8bcea0
7 changed files with 14 additions and 5 deletions

View file

@ -1,3 +1,4 @@
unmatchedSuppression
missingIncludeSystem
unusedFunction
useStlAlgorithm

View file

@ -145,7 +145,7 @@ struct BlockCache::Impl : public nocopy_nomove
#else
// Not implemented on other platforms
void flush() {}
void flush() { m_data = nullptr; }
#endif
uint8_t* m_data = nullptr;
@ -155,6 +155,7 @@ BlockCache::BlockCache()
: m_impl(new Impl())
, m_flushRunning(0)
, m_storeIndex(0)
, m_loadingStarted(0)
{
}
@ -188,6 +189,11 @@ void BlockCache::load_all(SideChain& side_chain, P2PServer& server)
return;
}
// Can be only called once
if (m_loadingStarted.exchange(1)) {
return;
}
LOGINFO(1, "loading cached blocks");
PoolBlock block;
@ -212,7 +218,7 @@ void BlockCache::load_all(SideChain& side_chain, P2PServer& server)
void BlockCache::flush()
{
if (m_flushRunning.exchange(1) == 0) {
if (m_flushRunning.exchange(1)) {
m_impl->flush();
m_flushRunning.store(0);
}

View file

@ -38,6 +38,7 @@ private:
Impl* m_impl;
std::atomic<uint32_t> m_flushRunning;
std::atomic<uint32_t> m_storeIndex;
std::atomic<uint32_t> m_loadingStarted;
};
} // namespace p2pool

View file

@ -321,6 +321,7 @@ static Worker worker;
NOINLINE Writer::Writer(Severity severity) : Stream(m_stackBuf)
{
m_stackBuf[BUF_SIZE] = '\0';
m_buf[0] = static_cast<char>(severity);
m_pos = 3;

View file

@ -35,7 +35,7 @@ class p2pool_api;
class ZMQReader;
struct PoolBlock;
class p2pool : public MinerCallbackHandler
class p2pool : public MinerCallbackHandler, public nocopy_nomove
{
public:
p2pool(int argc, char* argv[]);

View file

@ -2024,7 +2024,7 @@ bool SideChain::load_config(const std::string& filename)
return true;
}
bool SideChain::check_config()
bool SideChain::check_config() const
{
if (m_poolName.empty()) {
LOGERR(1, "name can't be empty");

View file

@ -99,7 +99,7 @@ private:
void prune_old_blocks();
bool load_config(const std::string& filename);
bool check_config();
bool check_config() const;
mutable uv_rwlock_t m_sidechainLock;
std::atomic<PoolBlock*> m_chainTip;