Fixed cppcheck errors

This commit is contained in:
SChernykh 2023-12-23 11:22:03 +01:00
parent 1d4aa3478d
commit df2a81d76d
6 changed files with 9 additions and 0 deletions

View file

@ -249,6 +249,7 @@ template<> struct Stream::Entry<hash>
buf[i * 2 + 0] = "0123456789abcdef"[data.h[i] >> 4];
buf[i * 2 + 1] = "0123456789abcdef"[data.h[i] & 15];
}
// cppcheck-suppress uninitvar
wrapper->writeBuf(buf, sizeof(buf));
}
};
@ -458,6 +459,7 @@ struct log::Stream::Entry<PadRight<T>>
static NOINLINE void put(PadRight<T>&& data, Stream* wrapper)
{
char buf[log::Stream::BUF_SIZE + 1];
// cppcheck-suppress uninitvar
log::Stream s(buf);
s << data.m_value;

View file

@ -176,6 +176,7 @@ void MergeMiningClient::merge_mining_get_job(uint64_t height, const hash& prev_i
m_getJobRunning = true;
char buf[log::Stream::BUF_SIZE + 1];
// cppcheck-suppress uninitvar
log::Stream s(buf);
s << "{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"method\":\"merge_mining_get_job\",\"params\":{"

View file

@ -1518,6 +1518,7 @@ void p2pool::api_update_stats_mod()
}
char last_block_found_buf[log::Stream::BUF_SIZE + 1];
// cppcheck-suppress uninitvar
log::Stream s(last_block_found_buf);
s << last_block_found_hash << '\0';
memcpy(last_block_found_buf + 4, "...", 4);

View file

@ -100,6 +100,7 @@ SideChain::SideChain(p2pool* pool, NetworkType type, const char* pool_name)
LOGINFO(1, "generating consensus ID");
char buf[log::Stream::BUF_SIZE + 1];
// cppcheck-suppress uninitvar
log::Stream s(buf);
s << "mm" << '\0'

View file

@ -213,6 +213,7 @@ NOINLINE bool difficulty_type::check_pow(const hash& pow_hash) const
std::ostream& operator<<(std::ostream& s, const difficulty_type& d)
{
char buf[log::Stream::BUF_SIZE + 1];
// cppcheck-suppress uninitvar
log::Stream s1(buf);
s1 << d << '\0';
s << buf;
@ -251,6 +252,7 @@ std::istream& operator>>(std::istream& s, difficulty_type& diff)
std::ostream& operator<<(std::ostream& s, const hash& h)
{
char buf[log::Stream::BUF_SIZE + 1];
// cppcheck-suppress uninitvar
log::Stream s1(buf);
s1 << h << '\0';
s << buf;
@ -401,6 +403,7 @@ struct BackgroundJobTracker::Impl
}
char buf[log::Stream::BUF_SIZE + 1];
// cppcheck-suppress uninitvar
log::Stream s(buf);
for (const auto& job : m_jobs) {
s << '\n' << job.first << " (" << job.second << ')';

View file

@ -210,6 +210,7 @@ bool ZMQReader::connect(const std::string& address, bool keep_monitor)
}
char buf[64];
// cppcheck-suppress uninitvar
log::Stream s(buf);
s << "inproc://p2pool-connect-mon-" << id << '\0';
++id;