Fixed cppcheck errors

This commit is contained in:
SChernykh 2023-12-23 11:22:03 +01:00
parent bc36be1e58
commit f98d2e652a
5 changed files with 8 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 + 0] = "0123456789abcdef"[data.h[i] >> 4];
buf[i * 2 + 1] = "0123456789abcdef"[data.h[i] & 15]; buf[i * 2 + 1] = "0123456789abcdef"[data.h[i] & 15];
} }
// cppcheck-suppress uninitvar
wrapper->writeBuf(buf, sizeof(buf)); wrapper->writeBuf(buf, sizeof(buf));
} }
}; };
@ -458,6 +459,7 @@ struct log::Stream::Entry<PadRight<T>>
static NOINLINE void put(PadRight<T>&& data, Stream* wrapper) static NOINLINE void put(PadRight<T>&& data, Stream* wrapper)
{ {
char buf[log::Stream::BUF_SIZE + 1]; char buf[log::Stream::BUF_SIZE + 1];
// cppcheck-suppress uninitvar
log::Stream s(buf); log::Stream s(buf);
s << data.m_value; s << data.m_value;

View file

@ -1393,6 +1393,7 @@ void p2pool::api_update_stats_mod()
} }
char last_block_found_buf[log::Stream::BUF_SIZE + 1]; char last_block_found_buf[log::Stream::BUF_SIZE + 1];
// cppcheck-suppress uninitvar
log::Stream s(last_block_found_buf); log::Stream s(last_block_found_buf);
s << last_block_found_hash << '\0'; s << last_block_found_hash << '\0';
memcpy(last_block_found_buf + 4, "...", 4); 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"); LOGINFO(1, "generating consensus ID");
char buf[log::Stream::BUF_SIZE + 1]; char buf[log::Stream::BUF_SIZE + 1];
// cppcheck-suppress uninitvar
log::Stream s(buf); log::Stream s(buf);
s << s_networkType << '\0' s << s_networkType << '\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) std::ostream& operator<<(std::ostream& s, const difficulty_type& d)
{ {
char buf[log::Stream::BUF_SIZE + 1]; char buf[log::Stream::BUF_SIZE + 1];
// cppcheck-suppress uninitvar
log::Stream s1(buf); log::Stream s1(buf);
s1 << d << '\0'; s1 << d << '\0';
s << buf; s << buf;
@ -251,6 +252,7 @@ std::istream& operator>>(std::istream& s, difficulty_type& diff)
std::ostream& operator<<(std::ostream& s, const hash& h) std::ostream& operator<<(std::ostream& s, const hash& h)
{ {
char buf[log::Stream::BUF_SIZE + 1]; char buf[log::Stream::BUF_SIZE + 1];
// cppcheck-suppress uninitvar
log::Stream s1(buf); log::Stream s1(buf);
s1 << h << '\0'; s1 << h << '\0';
s << buf; s << buf;
@ -401,6 +403,7 @@ struct BackgroundJobTracker::Impl
} }
char buf[log::Stream::BUF_SIZE + 1]; char buf[log::Stream::BUF_SIZE + 1];
// cppcheck-suppress uninitvar
log::Stream s(buf); log::Stream s(buf);
for (const auto& job : m_jobs) { for (const auto& job : m_jobs) {
s << '\n' << job.first << " (" << job.second << ')'; 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]; char buf[64];
// cppcheck-suppress uninitvar
log::Stream s(buf); log::Stream s(buf);
s << "inproc://p2pool-connect-mon-" << id << '\0'; s << "inproc://p2pool-connect-mon-" << id << '\0';
++id; ++id;