From f98d2e652a3e3ba1d61fb415743cec3316404e11 Mon Sep 17 00:00:00 2001 From: SChernykh <15806605+SChernykh@users.noreply.github.com> Date: Sat, 23 Dec 2023 11:22:03 +0100 Subject: [PATCH] Fixed cppcheck errors --- src/log.h | 2 ++ src/p2pool.cpp | 1 + src/side_chain.cpp | 1 + src/util.cpp | 3 +++ src/zmq_reader.cpp | 1 + 5 files changed, 8 insertions(+) diff --git a/src/log.h b/src/log.h index c8977e4..3653341 100644 --- a/src/log.h +++ b/src/log.h @@ -249,6 +249,7 @@ template<> struct Stream::Entry 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> static NOINLINE void put(PadRight&& data, Stream* wrapper) { char buf[log::Stream::BUF_SIZE + 1]; + // cppcheck-suppress uninitvar log::Stream s(buf); s << data.m_value; diff --git a/src/p2pool.cpp b/src/p2pool.cpp index 6f79998..d825469 100644 --- a/src/p2pool.cpp +++ b/src/p2pool.cpp @@ -1393,6 +1393,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); diff --git a/src/side_chain.cpp b/src/side_chain.cpp index 17b9f8d..8caecc8 100644 --- a/src/side_chain.cpp +++ b/src/side_chain.cpp @@ -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 << s_networkType << '\0' diff --git a/src/util.cpp b/src/util.cpp index bf5210d..77d389d 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -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 << ')'; diff --git a/src/zmq_reader.cpp b/src/zmq_reader.cpp index 981725c..7016f57 100644 --- a/src/zmq_reader.cpp +++ b/src/zmq_reader.cpp @@ -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;