Skip to content

Commit

Permalink
fix more warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
canepat committed Jan 24, 2024
1 parent e754660 commit 97acfde
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 120 deletions.
4 changes: 2 additions & 2 deletions cmd/dev/check_changes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ int main(int argc, char* argv[]) {
auto calculated_it{calculated_storage_changes.cbegin()};
auto db_it{db_storage_changes.cbegin()};
for (; calculated_it != calculated_storage_changes.cend() && db_it != db_storage_changes.cend(); ++calculated_it, ++db_it) {
auto calculated_change{*calculated_it};
auto stored_change{*db_it};
const auto& calculated_change{*calculated_it};
const auto& stored_change{*db_it};
if (calculated_change != stored_change) {
std::cout << "Mismatch number " << mismatch_count + 1 << ") is:\n- calculated change:\n";
print_storage_changes(calculated_change.first, calculated_change.second);
Expand Down
4 changes: 2 additions & 2 deletions cmd/dev/check_pow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ int main(int argc, char* argv[]) {

app.add_flag("--debug", options.debug, "May print some debug/trace info.");

CLI11_PARSE(app, argc, argv);
CLI11_PARSE(app, argc, argv)

if (options.debug) {
log::set_verbosity(log::Level::kDebug);
Expand Down Expand Up @@ -142,7 +142,7 @@ int main(int argc, char* argv[]) {
std::cout << "\n Pow Verification error on block " << block_num << " : \n"
<< "Error: " << ec << "\n"
<< "Final hash " << to_hex(f) << " expected below " << to_hex(b) << "\n"
<< "Mix hash " << to_hex(m) << " expected mix " << to_hex(m) << std::endl;
<< "Mix hash " << to_hex(m) << " expected mix " << to_hex(m) << "\n";
break;
}

Expand Down
3 changes: 1 addition & 2 deletions cmd/dev/check_tx_lookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <silkworm/infra/common/directories.hpp>
#include <silkworm/infra/common/log.hpp>
#include <silkworm/infra/concurrency/signal_handler.hpp>
#include <silkworm/node/db/access_layer.hpp>
#include <silkworm/node/db/etl/collector.hpp>
#include <silkworm/node/db/stages.hpp>

Expand All @@ -41,7 +40,7 @@ int main(int argc, char* argv[]) {
->capture_default_str()
->check(CLI::Range(1u, UINT32_MAX));

CLI11_PARSE(app, argc, argv);
CLI11_PARSE(app, argc, argv)

auto data_dir{DataDirectory::from_chaindata(chaindata)};
data_dir.deploy();
Expand Down
142 changes: 63 additions & 79 deletions cmd/dev/db_toolbox.cpp

Large diffs are not rendered by default.

21 changes: 10 additions & 11 deletions cmd/dev/genesistool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ void to_byte_array(fs::path& in, fs::path& out) {
// Write bytes to output file
std::string var_name{in.filename().replace_extension("").string()};
std::ofstream out_stream{out.string()};
out_stream << "/* Generated from " << in.filename().string() << " using silkworm's genesistool*/" << std::endl;
out_stream << "#include \"" + var_name + ".hpp\"" << std::endl;
out_stream << "constexpr char " << var_name << "_data_internal[] = {" << std::endl;
out_stream << "/* Generated from " << in.filename().string() << " using silkworm's genesistool*/\n";
out_stream << "#include \"" + var_name + ".hpp\"\n";
out_stream << "constexpr char " << var_name << "_data_internal[] = {\n";

auto max{bytes.size()};
auto count{1u};
Expand All @@ -71,11 +71,11 @@ void to_byte_array(fs::path& in, fs::path& out) {
<< ((count % 16 == 0) ? "\n" : " ");
++count;
}
out_stream << "};" << std::endl;
out_stream << "namespace silkworm {" << std::endl;
out_stream << "};\n";
out_stream << "namespace silkworm {\n";
out_stream << "constinit const std::string_view " << var_name << "_json{&" << var_name
<< "_data_internal[0], sizeof(" << var_name << "_data_internal)};" << std::endl;
out_stream << "}" << std::endl;
<< "_data_internal[0], sizeof(" << var_name << "_data_internal)};\n";
out_stream << "}\n";
out_stream.close();
}

Expand All @@ -95,7 +95,7 @@ int main(int argc, char* argv[]) {

app_main.add_flag("-w,--overwrite", overwrite, "Whether to overwrite existing files");

CLI11_PARSE(app_main, argc, argv);
CLI11_PARSE(app_main, argc, argv)

// Get genesis files in input directory
static const std::regex genesis_pattern{R"(^genesis_(.*)?\.json$)", std::regex_constants::icase};
Expand All @@ -111,7 +111,7 @@ int main(int argc, char* argv[]) {
}
}
if (input_entries.empty()) {
std::cerr << "\nNo files matching genesis pattern in input directory" << std::endl;
std::cerr << "\nNo files matching genesis pattern in input directory" << "\n";
return -1;
}

Expand All @@ -121,8 +121,7 @@ int main(int argc, char* argv[]) {
output_file_path.replace_extension(".cpp");
bool exists{fs::exists(output_file_path)};
bool skip{exists && !overwrite};
std::cout << input_file_path.string() << (skip ? " Skipped (exists)" : " -> " + output_file_path.string())
<< std::endl;
std::cout << input_file_path.string() << (skip ? " Skipped (exists)" : " -> " + output_file_path.string()) << "\n";
if (exists && !skip) {
fs::remove(output_file_path);
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/dev/kzg_g2_uncompress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,5 @@ int main() {
print_blst_fp(out.z.fp[0]);
std::cout << ",\n ";
print_blst_fp(out.z.fp[1]);
std::cout << "}}" << std::endl;
std::cout << "}}\n";
}
12 changes: 6 additions & 6 deletions cmd/dev/scan_txs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ int main(int argc, char* argv[]) {
uint64_t to{UINT64_MAX};
app.add_option("--to", to, "check up to block number (exclusive)");

CLI11_PARSE(app, argc, argv);
CLI11_PARSE(app, argc, argv)

if (from > to) {
std::cerr << "--from (" << from << ") must be less than or equal to --to (" << to << ").\n";
return -1;
}

int retvar{0};
int rv{0};

// Note: If Erigon is actively syncing its database (syncing), it is important not to create
// long-running database reads transactions even though that may make your processing faster.
Expand Down Expand Up @@ -111,7 +111,7 @@ int main(int argc, char* argv[]) {

// Report and reset counters
if ((block_num % 50000) == 0) {
std::cout << block_num << "," << nTxs << "," << nErrors << std::endl;
std::cout << block_num << "," << nTxs << "," << nErrors << "\n";
nTxs = nErrors = 0;

} else if ((block_num % 100) == 0) {
Expand All @@ -125,9 +125,9 @@ int main(int argc, char* argv[]) {
}

} catch (std::exception& ex) {
std::cout << ex.what() << std::endl;
retvar = -1;
std::cout << ex.what() << "\n";
rv = -1;
}

return retvar;
return rv;
}
2 changes: 1 addition & 1 deletion cmd/dev/snapshots.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ struct DownloadSettings : public bittorrent::BitTorrentSettings {
};

//! The Snapshots tools
enum class SnapshotTool {
enum class SnapshotTool : uint8_t {
count_bodies,
count_headers,
create_index,
Expand Down
10 changes: 1 addition & 9 deletions silkworm/rpc/core/call_many.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,14 @@
#include <boost/asio/compose.hpp>
#include <boost/asio/post.hpp>
#include <boost/asio/use_awaitable.hpp>
#include <evmc/hex.hpp>
#include <evmc/instructions.h>
#include <evmone/execution_state.hpp>
#include <evmone/instructions.hpp>
#include <intx/intx.hpp>

#include <silkworm/infra/common/ensure.hpp>
#include <silkworm/infra/common/log.hpp>
#include <silkworm/rpc/common/clock_time.hpp>
#include <silkworm/rpc/common/util.hpp>
#include <silkworm/rpc/core/blocks.hpp>
#include <silkworm/rpc/core/cached_chain.hpp>
#include <silkworm/rpc/core/evm_executor.hpp>
#include <silkworm/rpc/core/override_state.hpp>
#include <silkworm/rpc/core/rawdb/chain.hpp>
#include <silkworm/rpc/core/remote_state.hpp>
#include <silkworm/rpc/ethdb/kv/cached_database.hpp>
#include <silkworm/rpc/json/types.hpp>

Expand Down Expand Up @@ -78,7 +70,7 @@ CallManyResult CallExecutor::executes_all_bundles(const silkworm::ChainConfig& c
for (const auto& bundle : bundles) {
const auto& block_override = bundle.block_override;

// creates a block copy where ovverides few values
// creates a block copy where overrides few values
auto block_with_hash_shared_copy = std::make_shared<BlockWithHash>();
*block_with_hash_shared_copy = *block_with_hash;

Expand Down
8 changes: 4 additions & 4 deletions silkworm/rpc/ethdb/cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Task<SplittedKeyValue> SplitCursor::next() {
}

bool SplitCursor::match_key(const silkworm::ByteView& key) {
if (key.length() == 0) {
if (key.empty()) {
return false;
}
if (match_bytes_ == 0) {
Expand All @@ -65,7 +65,7 @@ bool SplitCursor::match_key(const silkworm::ByteView& key) {
SplittedKeyValue SplitCursor::split_key_value(const KeyValue& kv) {
const silkworm::Bytes& key = kv.key;

if (key.length() == 0) {
if (key.empty()) {
return SplittedKeyValue{};
}
if (!match_key(key)) {
Expand Down Expand Up @@ -115,7 +115,7 @@ Task<SplittedKeyValue> SplitCursorDupSort::next_dup() {
}

bool SplitCursorDupSort::match_key(const silkworm::ByteView& key) {
if (key.length() == 0) {
if (key.empty()) {
return false;
}
if (match_bytes_ == 0) {
Expand All @@ -133,7 +133,7 @@ bool SplitCursorDupSort::match_key(const silkworm::ByteView& key) {
SplittedKeyValue SplitCursorDupSort::split_key_value(const KeyValue& kv) {
const silkworm::Bytes& key = kv.key;

if (key.length() == 0) {
if (key.empty()) {
return SplittedKeyValue{};
}
if (!match_key(key)) {
Expand Down
3 changes: 0 additions & 3 deletions silkworm/rpc/json/call_bundle_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
#include <evmc/evmc.hpp>
#include <intx/intx.hpp>

#include <silkworm/rpc/json/call_bundle.hpp>
#include <silkworm/rpc/json/types.hpp>

namespace silkworm::rpc {

TEST_CASE("serialize empty call_bundle", "[rpc][to_json]") {
Expand Down

0 comments on commit 97acfde

Please sign in to comment.