Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: cpp-check warnings on build #2403

Merged
merged 1 commit into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CMakeModules/cppcheck.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ else ()
# exclude graphql generated
-i ${PROJECT_SOURCE_DIR}/libraries/core_libs/network/graphql/gen/
# messy files
--suppress=unmatchedSuppression:${PROJECT_SOURCE_DIR}/*/vector_ref.h
--suppress=unmatchedSuppression:${PROJECT_SOURCE_DIR}/*/Common.h
--suppress=cstyleCast:${PROJECT_SOURCE_DIR}/*/vector_ref.h
--suppress=cstyleCast:${PROJECT_SOURCE_DIR}/*/Common.h

#not an issue here
--suppress=virtualCallInConstructor:${PROJECT_SOURCE_DIR}/*/final_chain.cpp
# Only show found errors
"--quiet"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,7 @@ void TransactionPacketHandler::periodicSendTransactions(SharedTransactions &&tra
std::vector<std::pair<dev::p2p::NodeID, SharedTransactions>> peers_with_transactions_to_send;

auto peers = peers_state_->getAllPeers();
std::string transactions_to_log;
std::string peers_to_log;
for (auto const &trx : transactions) {
transactions_to_log += trx->getHash().abridged();
}
for (const auto &peer : peers) {
// Confirm that status messages were exchanged otherwise message might be ignored and node would
// incorrectly markTransactionAsKnown
Expand All @@ -150,6 +146,9 @@ void TransactionPacketHandler::periodicSendTransactions(SharedTransactions &&tra
}
const auto peers_to_send_count = peers_with_transactions_to_send.size();
if (peers_to_send_count > 0) {
auto transactions_to_log =
std::accumulate(transactions.begin(), transactions.end(), std::string{},
[](const auto &r, const auto &trx) { return r + trx->getHash().abridged(); });
LOG(log_tr_) << "Sending Transactions " << transactions_to_log << " to " << peers_to_log;
// Sending it in same order favours some peers over others, always start with a different position
uint32_t start_with = rand() % peers_to_send_count;
Expand Down