Skip to content

Commit

Permalink
Fixed cppcheck errors
Browse files Browse the repository at this point in the history
  • Loading branch information
SChernykh committed Dec 23, 2023
1 parent bc36be1 commit f98d2e6
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
};
Expand Down Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions src/p2pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/side_chain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
3 changes: 3 additions & 0 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 << ')';
Expand Down
1 change: 1 addition & 0 deletions src/zmq_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f98d2e6

Please sign in to comment.