From 5d4f35c5d364eaf18af0b0e923df67874c444992 Mon Sep 17 00:00:00 2001 From: Huang-Ming Huang Date: Wed, 16 Sep 2020 10:40:46 -0500 Subject: [PATCH] warning fix --- CMakeLists.txt | 2 ++ libraries/chain/backing_store/tests/benchmark_kv.cpp | 8 ++++---- .../chain/backing_store/tests/test_kv_rocksdb.cpp | 2 +- libraries/chain/combined_database.cpp | 2 +- libraries/chain/controller.cpp | 4 ++++ libraries/chain/include/eosio/chain/controller.hpp | 2 ++ libraries/chain/include/eosio/chain/wasm_interface.hpp | 3 --- libraries/chain/webassembly/crypto.cpp | 8 ++++---- .../webassembly/runtimes/eos-vm-oc/LLVMEmitIR.cpp | 2 +- .../runtimes/eos-vm-oc/compile_trampoline.cpp | 6 +++--- .../chain/webassembly/runtimes/eos-vm-oc/executor.cpp | 2 +- .../webassembly/runtimes/eos-vm-oc/ipc_helpers.cpp | 2 +- libraries/chain_kv/include/b1/chain_kv/chain_kv.hpp | 6 +++--- libraries/chain_kv/include/b1/session/shared_bytes.hpp | 2 +- libraries/chainbase | 2 +- libraries/eos-vm | 2 +- plugins/chain_plugin/chain_plugin.cpp | 4 ++-- plugins/chain_plugin/test/test_account_query_db.cpp | 4 ++-- .../test/test_add_file_system.cpp | 2 +- .../test/test_resmon_plugin.cpp | 2 +- .../resource_monitor_plugin/test/test_threshold.cpp | 2 +- plugins/trace_api_plugin/compressed_file.cpp | 4 ++-- plugins/trace_api_plugin/store_provider.cpp | 2 +- plugins/trace_api_plugin/test/test_compressed_file.cpp | 6 +++--- plugins/trace_api_plugin/test/test_responses.cpp | 4 ++-- plugins/trace_api_plugin/test/test_trace_file.cpp | 10 +++++----- programs/eosio-tester/main.cpp | 2 +- programs/rodeos/wasm_ql_http.cpp | 2 +- unittests/db_to_kv_tests.cpp | 2 +- unittests/producer_schedule_tests.cpp | 2 +- unittests/state_history_tests.cpp | 6 +++--- unittests/whitelist_blacklist_tests.cpp | 2 +- 32 files changed, 58 insertions(+), 53 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 29ecdcc45af..2627d4cb692 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,6 +45,7 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID} if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) message(FATAL_ERROR "Clang version must be at least 5.0!") endif() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wsign-compare -Wrange-loop-analysis") endif() if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") @@ -98,6 +99,7 @@ else() set(no_whole_archive_flag "--no-whole-archive") endif() +set(Boost_USE_MULTITHREADED ON) set( Boost_USE_STATIC_LIBS ON CACHE STRING "ON or OFF" ) # Most boost deps get implictly picked up via fc, as just about everything links to fc. In addition we pick up # the pthread dependency through fc. diff --git a/libraries/chain/backing_store/tests/benchmark_kv.cpp b/libraries/chain/backing_store/tests/benchmark_kv.cpp index 12e240e72c3..5a7639f297b 100644 --- a/libraries/chain/backing_store/tests/benchmark_kv.cpp +++ b/libraries/chain/backing_store/tests/benchmark_kv.cpp @@ -186,7 +186,7 @@ measurement_t benchmark_get(const cmd_args& args, const std::unique_ptrkv_get(contract, key.c_str(), key.size(),actual_value_size); @@ -204,7 +204,7 @@ measurement_t benchmark_get_data(const cmd_args& args, const std::unique_ptrkv_get_data(0, data, args.value_size); } @@ -221,7 +221,7 @@ measurement_t benchmark_set(const cmd_args& args, const std::unique_ptrkv_set(contract, key.c_str(), key.size(), value.c_str(), value.size(), payer); } @@ -270,7 +270,7 @@ measurement_t benchmark_erase(const cmd_args& args, const std::unique_ptr& kv_context_ptr) { rusage usage_start, usage_end; getrusage(RUSAGE_SELF, &usage_start); - auto i = 0; + auto i = 0U; std::string prefix = "a"; while (i < args.num_runs) { kv_context_ptr->kv_it_create(contract, prefix.c_str(), 0); // kv_it_create creates a unique pointer. Will be destoryed at the end of the scope. diff --git a/libraries/chain/backing_store/tests/test_kv_rocksdb.cpp b/libraries/chain/backing_store/tests/test_kv_rocksdb.cpp index 71e8e1a5f88..8ebd4802299 100644 --- a/libraries/chain/backing_store/tests/test_kv_rocksdb.cpp +++ b/libraries/chain/backing_store/tests/test_kv_rocksdb.cpp @@ -541,7 +541,7 @@ BOOST_FIXTURE_TEST_CASE(test_iter_creation_too_many, kv_rocksdb_fixture) { mock_get_key_prefix = [&]() { return eosio::chain::make_prefix_key(contract, prefix.c_str(), it_key_size); }; // Creating max_iterators iterators - for (auto i = 0; i < max_iterators; ++i) { + for (auto i = 0U; i < max_iterators; ++i) { its[i] = my_kv_context->kv_it_create(contract, prefix.c_str(), it_key_size); } diff --git a/libraries/chain/combined_database.cpp b/libraries/chain/combined_database.cpp index 85eb2e6d73b..d455aee47ee 100644 --- a/libraries/chain/combined_database.cpp +++ b/libraries/chain/combined_database.cpp @@ -612,7 +612,7 @@ namespace eosio { namespace chain { static const eosio::session::shared_bytes empty_payload; unsigned_int size; read_row(size); - for (int i = 0; i < size.value; ++i) { + for (uint32_t i = 0; i < size.value; ++i) { backing_store::secondary_index_view row; read_row(row); backing_store::payer_payload pp{row.payer, nullptr, 0}; diff --git a/libraries/chain/controller.cpp b/libraries/chain/controller.cpp index 390234a1198..79eae3bc3fd 100644 --- a/libraries/chain/controller.cpp +++ b/libraries/chain/controller.cpp @@ -22,6 +22,10 @@ #include +#if defined(EOSIO_EOS_VM_RUNTIME_ENABLED) || defined(EOSIO_EOS_VM_JIT_RUNTIME_ENABLED) +#include +#endif + namespace eosio { namespace chain { using resource_limits::resource_limits_manager; diff --git a/libraries/chain/include/eosio/chain/controller.hpp b/libraries/chain/include/eosio/chain/controller.hpp index df7054f9202..2ff84af4b9c 100644 --- a/libraries/chain/include/eosio/chain/controller.hpp +++ b/libraries/chain/include/eosio/chain/controller.hpp @@ -23,6 +23,8 @@ namespace boost { namespace asio { class thread_pool; }} +namespace eosio { namespace vm { class wasm_allocator; }} + namespace eosio { namespace chain { class authorization_manager; diff --git a/libraries/chain/include/eosio/chain/wasm_interface.hpp b/libraries/chain/include/eosio/chain/wasm_interface.hpp index 8b08a4edb58..ed01f3bd1dd 100644 --- a/libraries/chain/include/eosio/chain/wasm_interface.hpp +++ b/libraries/chain/include/eosio/chain/wasm_interface.hpp @@ -3,9 +3,6 @@ #include #include #include -#if defined(EOSIO_EOS_VM_RUNTIME_ENABLED) || defined(EOSIO_EOS_VM_JIT_RUNTIME_ENABLED) -#include -#endif #include "Runtime/Linker.h" #include "Runtime/Runtime.h" diff --git a/libraries/chain/webassembly/crypto.cpp b/libraries/chain/webassembly/crypto.cpp index a0015ae82fe..890cc9ad5dc 100644 --- a/libraries/chain/webassembly/crypto.cpp +++ b/libraries/chain/webassembly/crypto.cpp @@ -16,9 +16,9 @@ namespace eosio { namespace chain { namespace webassembly { fc::raw::unpack( ds, s ); fc::raw::unpack( pubds, p ); - EOS_ASSERT(s.which() < context.db.get().num_supported_key_types, unactivated_signature_type, + EOS_ASSERT(static_cast(s.which()) < context.db.get().num_supported_key_types, unactivated_signature_type, "Unactivated signature type used during assert_recover_key"); - EOS_ASSERT(p.which() < context.db.get().num_supported_key_types, unactivated_key_type, + EOS_ASSERT(static_cast(p.which()) < context.db.get().num_supported_key_types, unactivated_key_type, "Unactivated key type used when creating assert_recover_key"); if(context.control.is_producing_block()) @@ -36,7 +36,7 @@ namespace eosio { namespace chain { namespace webassembly { datastream ds( sig.data(), sig.size() ); fc::raw::unpack(ds, s); - EOS_ASSERT(s.which() < context.db.get().num_supported_key_types, unactivated_signature_type, + EOS_ASSERT(static_cast(s.which()) < context.db.get().num_supported_key_types, unactivated_signature_type, "Unactivated signature type used during recover_key"); if(context.control.is_producing_block()) @@ -47,7 +47,7 @@ namespace eosio { namespace chain { namespace webassembly { auto recovered = fc::crypto::public_key(s, *digest, false); // the key types newer than the first 2 may be varible in length - if (s.which() >= config::genesis_num_supported_key_types ) { + if (static_cast(s.which()) >= config::genesis_num_supported_key_types ) { EOS_ASSERT(pub.size() >= 33, wasm_execution_error, "destination buffer must at least be able to hold an ECC public key"); auto packed_pubkey = fc::raw::pack(recovered); diff --git a/libraries/chain/webassembly/runtimes/eos-vm-oc/LLVMEmitIR.cpp b/libraries/chain/webassembly/runtimes/eos-vm-oc/LLVMEmitIR.cpp index 8b662fa26a9..db22c70e9c3 100644 --- a/libraries/chain/webassembly/runtimes/eos-vm-oc/LLVMEmitIR.cpp +++ b/libraries/chain/webassembly/runtimes/eos-vm-oc/LLVMEmitIR.cpp @@ -1259,7 +1259,7 @@ namespace LLVMJIT importedFunctionOffsets.push_back(ie.ordinal); } - int current_prologue = -8; + intptr_t current_prologue = -8; for(const GlobalDef& global : module.globals.defs) { if(global.type.isMutable) { diff --git a/libraries/chain/webassembly/runtimes/eos-vm-oc/compile_trampoline.cpp b/libraries/chain/webassembly/runtimes/eos-vm-oc/compile_trampoline.cpp index f1f0a2a0666..dba86418b33 100644 --- a/libraries/chain/webassembly/runtimes/eos-vm-oc/compile_trampoline.cpp +++ b/libraries/chain/webassembly/runtimes/eos-vm-oc/compile_trampoline.cpp @@ -89,15 +89,15 @@ void run_compile(wrapped_fd&& response_sock, wrapped_fd&& wasm_code) noexcept { for(const TableSegment& table_segment : module.tableSegments) { struct table_entry* table_index_0 = (struct table_entry*)(code.code.data() + code.table_offset); - if(table_segment.baseOffset.i32 > module.tables.defs[0].type.size.min) + if(static_cast(table_segment.baseOffset.i32) > module.tables.defs[0].type.size.min) return; - if(table_segment.baseOffset.i32 > module.tables.defs[0].type.size.min) + if(static_cast(table_segment.baseOffset.i32) > module.tables.defs[0].type.size.min) return; for(Uptr i = 0; i < table_segment.indices.size(); ++i) { const Uptr function_index = table_segment.indices[i]; - const long int effective_table_index = table_segment.baseOffset.i32 + i; + const uint64_t effective_table_index = table_segment.baseOffset.i32 + i; if(effective_table_index >= module.tables.defs[0].type.size.min) return; diff --git a/libraries/chain/webassembly/runtimes/eos-vm-oc/executor.cpp b/libraries/chain/webassembly/runtimes/eos-vm-oc/executor.cpp index 00d334255b7..ca32f8cd0e4 100644 --- a/libraries/chain/webassembly/runtimes/eos-vm-oc/executor.cpp +++ b/libraries/chain/webassembly/runtimes/eos-vm-oc/executor.cpp @@ -168,7 +168,7 @@ void executor::execute(const code_descriptor& code, memory& mem, apply_context& //prepare initial memory, mutable globals, and table data if(code.starting_memory_pages > 0 ) { uint64_t initial_page_offset = std::min(static_cast(code.starting_memory_pages), mem.size_of_memory_slice_mapping()/memory::stride - 1); - if(initial_page_offset < code.starting_memory_pages) { + if(initial_page_offset < static_cast(code.starting_memory_pages)) { mprotect(mem.full_page_memory_base() + initial_page_offset * eosio::chain::wasm_constraints::wasm_page_size, (code.starting_memory_pages - initial_page_offset) * eosio::chain::wasm_constraints::wasm_page_size, PROT_READ | PROT_WRITE); } diff --git a/libraries/chain/webassembly/runtimes/eos-vm-oc/ipc_helpers.cpp b/libraries/chain/webassembly/runtimes/eos-vm-oc/ipc_helpers.cpp index cc694240957..8dcb797e5ea 100644 --- a/libraries/chain/webassembly/runtimes/eos-vm-oc/ipc_helpers.cpp +++ b/libraries/chain/webassembly/runtimes/eos-vm-oc/ipc_helpers.cpp @@ -37,7 +37,7 @@ std::tuple> read_message_with_fds do { red = recvmsg(fd, &msg, 0); } while(red == -1 && errno == EINTR); - if(red < 1 || red >= sizeof(buff)) + if(red < 1 || static_cast(red) >= sizeof(buff)) return {false, message, std::move(fds)}; try { diff --git a/libraries/chain_kv/include/b1/chain_kv/chain_kv.hpp b/libraries/chain_kv/include/b1/chain_kv/chain_kv.hpp index 6e9781c94cf..a3e0b8cfaa6 100644 --- a/libraries/chain_kv/include/b1/chain_kv/chain_kv.hpp +++ b/libraries/chain_kv/include/b1/chain_kv/chain_kv.hpp @@ -192,7 +192,7 @@ namespace detail { template bool extract_key(It& key_loc, It key_end, Key& key) { - const auto distance = std::distance(key_loc, key_end); + const std::size_t distance = std::distance(key_loc, key_end); using t_type = typename value_storage::type; constexpr static auto key_size = sizeof(t_type) * N; if (distance < key_size) @@ -468,7 +468,7 @@ class undo_stack { throw exception("cannot set revision while there is an existing undo stack"); if (revision > std::numeric_limits::max()) throw exception("revision to set is too high"); - if (revision < state.revision) + if (static_cast(revision) < state.revision) throw exception("revision cannot decrease"); state.revision = revision; if (write_now) @@ -552,7 +552,7 @@ class undo_stack { // Discard all undo history prior to revision void commit(int64_t revision) { revision = std::min(revision, state.revision); - auto first_revision = state.revision - state.undo_stack.size(); + int64_t first_revision = state.revision - state.undo_stack.size(); if (first_revision < revision) { rocksdb::WriteBatch batch; state.undo_stack.erase(state.undo_stack.begin(), state.undo_stack.begin() + (revision - first_revision)); diff --git a/libraries/chain_kv/include/b1/session/shared_bytes.hpp b/libraries/chain_kv/include/b1/session/shared_bytes.hpp index b506eb3ac55..f2a3dcdd9cf 100644 --- a/libraries/chain_kv/include/b1/session/shared_bytes.hpp +++ b/libraries/chain_kv/include/b1/session/shared_bytes.hpp @@ -167,7 +167,7 @@ inline shared_bytes shared_bytes::previous() const { index = buffer.size(); } } - while (index < buffer.size()) { + while (static_cast(index) < buffer.size()) { buffer[index] = std::numeric_limits::max(); } diff --git a/libraries/chainbase b/libraries/chainbase index 87c5207f1a6..a018af79006 160000 --- a/libraries/chainbase +++ b/libraries/chainbase @@ -1 +1 @@ -Subproject commit 87c5207f1a64408d627cb779b5dbcbadc6806e6e +Subproject commit a018af7900618513a8703ae084db061b982e3f96 diff --git a/libraries/eos-vm b/libraries/eos-vm index 5f5cf516465..d42a1815266 160000 --- a/libraries/eos-vm +++ b/libraries/eos-vm @@ -1 +1 @@ -Subproject commit 5f5cf516465d6c6b9f212a99651ffe3b28760462 +Subproject commit d42a18152669c1cec69ad43e82af41c276bb4172 diff --git a/plugins/chain_plugin/chain_plugin.cpp b/plugins/chain_plugin/chain_plugin.cpp index 0c4fb50c87b..7222f89706b 100644 --- a/plugins/chain_plugin/chain_plugin.cpp +++ b/plugins/chain_plugin/chain_plugin.cpp @@ -2120,14 +2120,14 @@ void read_only::make_prefix(eosio::name table_name, eosio::name index_name, uin vector bin; bin.reserve(sizeof(uint64_t)); convert_to_key(table_name.to_uint64_t(), bin); - for( int i = 0; i < sizeof(uint64_t); ++i ) { + for( unsigned i = 0; i < sizeof(uint64_t); ++i ) { prefix[i + 1] = bin[i]; } bin.clear(); convert_to_key(index_name.to_uint64_t(), bin); int offset = sizeof(uint64_t) + 1; - for( int i = 0; i < sizeof(uint64_t ); ++i) { + for( unsigned i = 0; i < sizeof(uint64_t ); ++i) { prefix[offset + i] = bin[i]; } } diff --git a/plugins/chain_plugin/test/test_account_query_db.cpp b/plugins/chain_plugin/test/test_account_query_db.cpp index a62bdcb3a59..dee570a0911 100644 --- a/plugins/chain_plugin/test/test_account_query_db.cpp +++ b/plugins/chain_plugin/test/test_account_query_db.cpp @@ -21,7 +21,7 @@ using params = account_query_db::get_accounts_by_authorizers_params; using results = account_query_db::get_accounts_by_authorizers_result; bool find_account_name(results rst, account_name name){ - for (const auto acc : rst.accounts){ + for (const auto& acc : rst.accounts){ if (acc.account_name == name){ return true; } @@ -29,7 +29,7 @@ bool find_account_name(results rst, account_name name){ return false; } bool find_account_auth(results rst, account_name name, permission_name perm){ - for (const auto acc : rst.accounts){ + for (const auto& acc : rst.accounts){ if (acc.account_name == name && acc.permission_name == perm) return true; } diff --git a/plugins/resource_monitor_plugin/test/test_add_file_system.cpp b/plugins/resource_monitor_plugin/test/test_add_file_system.cpp index b9508aa6eac..00015b54762 100644 --- a/plugins/resource_monitor_plugin/test/test_add_file_system.cpp +++ b/plugins/resource_monitor_plugin/test/test_add_file_system.cpp @@ -67,7 +67,7 @@ struct add_file_system_fixture { set_threshold(80, 75); - for (auto k = 0; k < capacity.size(); k++) { + for (auto k = 0U; k < capacity.size(); k++) { add_file_system("/test" + std::to_string(k)); } } diff --git a/plugins/resource_monitor_plugin/test/test_resmon_plugin.cpp b/plugins/resource_monitor_plugin/test/test_resmon_plugin.cpp index 1c47e1302da..2091b98f5de 100644 --- a/plugins/resource_monitor_plugin/test/test_resmon_plugin.cpp +++ b/plugins/resource_monitor_plugin/test/test_resmon_plugin.cpp @@ -28,7 +28,7 @@ struct resmon_fixture { EOS_ASSERT(args.size() < 10, chain::plugin_exception, "number of arguments (${size}) must be less than 10", ("size", args.size())); // argv[0] is program name, no need to fill in - for (auto i=0; i(*iter) == loc ) { + if ( iter != seek_point_map.end() && std::get<0>(*iter) == static_cast(loc) ) { file.seek(std::get<1>(*iter)); return; } @@ -233,7 +233,7 @@ bool compressed_file::process( const fc::path& input_path, const fc::path& outpu auto output_buffer = std::vector(buffer_size); auto bytes_remaining_before_sync = seek_point_stride; - int next_sync_point = 0; + unsigned int next_sync_point = 0; // process a single chunk of input completely, // this may sometime loop multiple times if the compressor state combined with input data creates more than a diff --git a/plugins/trace_api_plugin/store_provider.cpp b/plugins/trace_api_plugin/store_provider.cpp index 2d7ba3e7f80..92f8811b508 100644 --- a/plugins/trace_api_plugin/store_provider.cpp +++ b/plugins/trace_api_plugin/store_provider.cpp @@ -14,7 +14,7 @@ namespace { std::string make_filename(const char* slice_prefix, const char* slice_ext, uint32_t slice_number, uint32_t slice_width) { char filename[_max_filename_size] = {}; const uint32_t slice_start = slice_number * slice_width; - const int size_written = snprintf(filename, _max_filename_size, "%s%010d-%010d%s", slice_prefix, slice_start, (slice_start + slice_width), slice_ext); + const unsigned int size_written = snprintf(filename, _max_filename_size, "%s%010d-%010d%s", slice_prefix, slice_start, (slice_start + slice_width), slice_ext); // assert that _max_filename_size is correct if ( size_written >= _max_filename_size ) { const std::string max_size_str = std::to_string(_max_filename_size - 1); // dropping null character from size diff --git a/plugins/trace_api_plugin/test/test_compressed_file.cpp b/plugins/trace_api_plugin/test/test_compressed_file.cpp index 66c9667cec1..9df0778d8e7 100644 --- a/plugins/trace_api_plugin/test/test_compressed_file.cpp +++ b/plugins/trace_api_plugin/test/test_compressed_file.cpp @@ -115,7 +115,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(random_access_test, T, test_types, temp_file_fi BOOST_TEST(compressed_file::process(uncompressed_filename, compressed_filename, 512)); // test that you can read all of the offsets from the compressed form by opening and seeking to them - for (int i = 0; i < data.size(); i++) { + for (std::size_t i = 0; i < data.size(); i++) { const auto& entry = data.at(i); auto compf = compressed_file(compressed_filename); compf.open(); @@ -165,7 +165,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(blob_access, T, test_types, temp_file_fixture) BOOST_TEST(compressed_file::process(uncompressed_filename, compressed_filename, 512)); // test that you can read all of the offsets from the compressed form through the end of the file - for (int i = 0; i < data.size(); i++) { + for (std::size_t i = 0; i < data.size(); i++) { auto actual_data = std::vector(128); auto compf = compressed_file(compressed_filename); compf.open(); @@ -201,7 +201,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(blob_access_no_seek_points, T, test_types, temp BOOST_REQUIRE_EQUAL(expected_seek_point_count, actual_seek_point_count); // test that you can read all of the offsets from the compressed form through the end of the file - for (int i = 0; i < data.size(); i++) { + for (std::size_t i = 0; i < data.size(); i++) { auto actual_data = std::vector(32); auto compf = compressed_file(compressed_filename); compf.open(); diff --git a/plugins/trace_api_plugin/test/test_responses.cpp b/plugins/trace_api_plugin/test/test_responses.cpp index 945aa4cb0f9..50673141de2 100644 --- a/plugins/trace_api_plugin/test/test_responses.cpp +++ b/plugins/trace_api_plugin/test/test_responses.cpp @@ -130,11 +130,11 @@ BOOST_AUTO_TEST_SUITE(trace_responses) { 0x00, 0x01, 0x02, 0x03 } }; - auto transaction_trace = transaction_trace_v1 { + auto transaction_trace = transaction_trace_v1 { { "0000000000000000000000000000000000000000000000000000000000000001"_h, { action_trace - }, + }}, fc::enum_type{chain::transaction_receipt_header::status_enum::executed}, 10, 5, diff --git a/plugins/trace_api_plugin/test/test_trace_file.cpp b/plugins/trace_api_plugin/test/test_trace_file.cpp index 2a9f8e6daa4..322c2d54bc6 100644 --- a/plugins/trace_api_plugin/test/test_trace_file.cpp +++ b/plugins/trace_api_plugin/test/test_trace_file.cpp @@ -220,11 +220,11 @@ namespace { struct vslice { enum mode { read_mode, write_mode}; vslice(mode m = write_mode) : _mode(m) {} - long tellp() const { + unsigned long tellp() const { return _pos; } - void seek( long loc ) { + void seek( unsigned long loc ) { if (_mode == read_mode) { if (loc > _buffer.size()) { throw std::ios_base::failure( "read vslice unable to seek to: " + std::to_string(loc) + ", end is at: " + std::to_string(_buffer.size())); @@ -268,7 +268,7 @@ namespace { std::vector _buffer; mode _mode = write_mode; - long _pos = 0l; + unsigned long _pos = 0lu; bool _flush = false; bool _sync = false; }; @@ -706,7 +706,7 @@ BOOST_AUTO_TEST_SUITE(slice_tests) sd.run_maintenance_tasks(14, {}); verify_directory_contents(tempdir.path(), files); - for (int reps = 0; reps < file_paths.size(); reps++) { + for (std::size_t reps = 0; reps < file_paths.size(); reps++) { // leading edge, // compresses one slice files.erase(std::get<1>(file_paths.at(reps))); @@ -761,7 +761,7 @@ BOOST_AUTO_TEST_SUITE(slice_tests) sd.run_maintenance_tasks(14, {}); verify_directory_contents(tempdir.path(), files); - for (int reps = 0; reps < file_paths.size() + 1; reps++) { + for (std::size_t reps = 0; reps < file_paths.size() + 1; reps++) { // leading edge, // compresses one slice IF its not past the end of our test, if (reps < file_paths.size()) { diff --git a/programs/eosio-tester/main.cpp b/programs/eosio-tester/main.cpp index 5afbdafe91e..ee9717a46e8 100644 --- a/programs/eosio-tester/main.cpp +++ b/programs/eosio-tester/main.cpp @@ -683,7 +683,7 @@ struct callbacks { } file& assert_file(int32_t file_index) { - if (file_index < 0 || file_index >= state.files.size() || !state.files[file_index].f) + if (file_index < 0 || static_cast(file_index) >= state.files.size() || !state.files[file_index].f) throw std::runtime_error("file is not opened"); return state.files[file_index]; } diff --git a/programs/rodeos/wasm_ql_http.cpp b/programs/rodeos/wasm_ql_http.cpp index 5f229357915..42d38e9c321 100644 --- a/programs/rodeos/wasm_ql_http.cpp +++ b/programs/rodeos/wasm_ql_http.cpp @@ -588,7 +588,7 @@ struct server_impl : http_server, std::enable_shared_from_this { ->run(); threads.reserve(http_config->num_threads); - for (int i = 0; i < http_config->num_threads; ++i) + for (unsigned i = 0; i < http_config->num_threads; ++i) threads.emplace_back([self = shared_from_this()] { self->ioc.run(); }); } }; // server_impl diff --git a/unittests/db_to_kv_tests.cpp b/unittests/db_to_kv_tests.cpp index bf5eb5b63aa..1b9596e9809 100644 --- a/unittests/db_to_kv_tests.cpp +++ b/unittests/db_to_kv_tests.cpp @@ -304,7 +304,7 @@ void verify_secondary_key_pair_order(const eosio::chain::backing_store::db_key_v bool type_seen = false; // keep track so we know if the type we are currently checking is after or before the incoming type unsigned int other_types_processed = 0; - unsigned int expected_type_comp = 0; + int expected_type_comp = 0; key_type current_kt = key_type::primary; // lambda to correctly identify comparisons for each type auto type_check = [&type_seen, &other_types_processed, ¤t_kt, &expected_type_comp, kt](key_type curr_kt) { diff --git a/unittests/producer_schedule_tests.cpp b/unittests/producer_schedule_tests.cpp index f4f3f2c908d..3d9499bf27f 100644 --- a/unittests/producer_schedule_tests.cpp +++ b/unittests/producer_schedule_tests.cpp @@ -630,7 +630,7 @@ BOOST_AUTO_TEST_CASE( large_authority_overflow_test ) try { const size_t pre_overflow_count = 65'537UL; // enough for weights of 0xFFFF to add up to 0xFFFFFFFF auth.keys.reserve(pre_overflow_count + 1); - for (int i = 0; i < pre_overflow_count; i++) { + for (std::size_t i = 0; i < pre_overflow_count; i++) { auto key_str = std::to_string(i) + "_bsk"; auth.keys.emplace_back(key_weight{get_public_key("alice"_n, key_str), 0xFFFFU}); } diff --git a/unittests/state_history_tests.cpp b/unittests/state_history_tests.cpp index f2a882653ff..befdbb42b9d 100644 --- a/unittests/state_history_tests.cpp +++ b/unittests/state_history_tests.cpp @@ -476,7 +476,7 @@ class table_deltas_tester : public tester { template vector deserialize_data(deltas_vector::iterator &it) { vector result; - for(int i=0; i < it->rows.obj.size(); i++) { + for(std::size_t i=0; i < it->rows.obj.size(); i++) { eosio::input_stream stream{it->rows.obj[i].second.data(), it->rows.obj[i].second.size()}; result.push_back(std::get(eosio::from_bin(stream))); } @@ -551,7 +551,7 @@ BOOST_AUTO_TEST_CASE(test_deltas_account_permission) { auto &it_permission = result.second; BOOST_REQUIRE_EQUAL(it_permission->rows.obj.size(), 2); auto accounts_permissions = chain.deserialize_data(it_permission); - for (int i = 0; i < accounts_permissions.size(); i++) { + for (std::size_t i = 0; i < accounts_permissions.size(); i++) { BOOST_REQUIRE_EQUAL(it_permission->rows.obj[i].first, true); BOOST_REQUIRE_EQUAL(accounts_permissions[i].owner.to_string(), "newacc"); BOOST_REQUIRE_EQUAL(accounts_permissions[i].name.to_string(), expected_permission_names[i]); @@ -725,7 +725,7 @@ BOOST_AUTO_TEST_CASE(test_deltas_protocol_feature_history) { auto digest_byte_array = protocol_feature.feature_digest.extract_as_byte_array(); char digest_array[digest_byte_array.size()]; - for (int i = 0; i < digest_byte_array.size(); i++) digest_array[i] = digest_byte_array[i]; + for (std::size_t i = 0; i < digest_byte_array.size(); i++) digest_array[i] = digest_byte_array[i]; eosio::chain::digest_type digest_in_delta(digest_array, digest_byte_array.size()); BOOST_REQUIRE_EQUAL(digest_in_delta, *d); diff --git a/unittests/whitelist_blacklist_tests.cpp b/unittests/whitelist_blacklist_tests.cpp index b79c92c9016..574b102d609 100644 --- a/unittests/whitelist_blacklist_tests.cpp +++ b/unittests/whitelist_blacklist_tests.cpp @@ -753,7 +753,7 @@ BOOST_AUTO_TEST_CASE( greylist_limit_tests ) { try { ("cpu_weight", 249'999'999) ); - const uint64_t reqauth_net_charge = 104; + const int64_t reqauth_net_charge = 104; auto push_reqauth = [&]( name acnt, name perm, uint32_t billed_cpu_time_us ) { signed_transaction trx; trx.actions.emplace_back( c.get_action( config::system_account_name, "reqauth"_n,