diff --git a/libraries/chain/include/eosio/chain/apply_context.hpp b/libraries/chain/include/eosio/chain/apply_context.hpp index 1bb8e0e4cf8..58b1d5bd367 100644 --- a/libraries/chain/include/eosio/chain/apply_context.hpp +++ b/libraries/chain/include/eosio/chain/apply_context.hpp @@ -62,7 +62,7 @@ class apply_context { const T& get( int iterator ) { EOS_ASSERT( iterator != -1, invalid_table_iterator, "invalid iterator" ); EOS_ASSERT( iterator >= 0, table_operation_not_permitted, "dereference of end iterator" ); - EOS_ASSERT( iterator < _iterator_to_object.size(), invalid_table_iterator, "iterator out of range" ); + EOS_ASSERT( (size_t)iterator < _iterator_to_object.size(), invalid_table_iterator, "iterator out of range" ); auto result = _iterator_to_object[iterator]; EOS_ASSERT( result, table_operation_not_permitted, "dereference of deleted object" ); return *result; @@ -71,7 +71,7 @@ class apply_context { void remove( int iterator ) { EOS_ASSERT( iterator != -1, invalid_table_iterator, "invalid iterator" ); EOS_ASSERT( iterator >= 0, table_operation_not_permitted, "cannot call remove on end iterators" ); - EOS_ASSERT( iterator < _iterator_to_object.size(), invalid_table_iterator, "iterator out of range" ); + EOS_ASSERT( (size_t)iterator < _iterator_to_object.size(), invalid_table_iterator, "iterator out of range" ); auto obj_ptr = _iterator_to_object[iterator]; if( !obj_ptr ) return; _iterator_to_object[iterator] = nullptr; diff --git a/libraries/chain/include/eosio/chain/wasm_eosio_injection.hpp b/libraries/chain/include/eosio/chain/wasm_eosio_injection.hpp index f5ebf01c1f7..f3de70f5e69 100644 --- a/libraries/chain/include/eosio/chain/wasm_eosio_injection.hpp +++ b/libraries/chain/include/eosio/chain/wasm_eosio_injection.hpp @@ -37,7 +37,7 @@ namespace eosio { namespace chain { namespace wasm_injections { static void build_type_slots( Module& mod ) { // add the module types to the type_slots map - for ( int i=0; i < mod.types.size(); i++ ) { + for ( size_t i=0; i < mod.types.size(); i++ ) { std::vector type_slot_list = { static_cast(mod.types[i]->ret) }; for ( auto param : mod.types[i]->parameters ) type_slot_list.push_back( static_cast(param) ); @@ -78,7 +78,7 @@ namespace eosio { namespace chain { namespace wasm_injections { injected_index_mapping.emplace( index, actual_index ); // shift all exported functions by 1 - for ( int i=0; i < module.exports.size(); i++ ) { + for ( size_t i=0; i < module.exports.size(); i++ ) { if ( module.exports[i].kind == IR::ObjectKind::function ) { module.exports[i].index++; } diff --git a/libraries/chain/wasm_interface.cpp b/libraries/chain/wasm_interface.cpp index 28de213c1c2..b6d8d517408 100644 --- a/libraries/chain/wasm_interface.cpp +++ b/libraries/chain/wasm_interface.cpp @@ -1266,7 +1266,7 @@ class memory_api : public context_aware_api { :context_aware_api(ctx,true){} char* memcpy( array_ptr dest, array_ptr src, size_t length) { - EOS_ASSERT((std::abs((ptrdiff_t)dest.value - (ptrdiff_t)src.value)) >= length, + EOS_ASSERT((size_t)(std::abs((ptrdiff_t)dest.value - (ptrdiff_t)src.value)) >= length, overlapping_memory_error, "memcpy can only accept non-aliasing pointers"); return (char *)::memcpy(dest, src, length); } diff --git a/libraries/testing/tester.cpp b/libraries/testing/tester.cpp index 5cb8cb38c58..f56358e54eb 100644 --- a/libraries/testing/tester.cpp +++ b/libraries/testing/tester.cpp @@ -797,7 +797,7 @@ namespace eosio { namespace testing { return other.sync_with(*this); auto sync_dbs = [](base_tester& a, base_tester& b) { - for( int i = 1; i <= a.control->head_block_num(); ++i ) { + for( uint32_t i = 1; i <= a.control->head_block_num(); ++i ) { auto block = a.control->fetch_block_by_number(i); if( block ) { //&& !b.control->is_known_block(block->id()) ) { auto bs = b.control->create_block_state_future( block ); diff --git a/plugins/chain_plugin/chain_plugin.cpp b/plugins/chain_plugin/chain_plugin.cpp index 6df172b7c8f..c15e1f16c00 100644 --- a/plugins/chain_plugin/chain_plugin.cpp +++ b/plugins/chain_plugin/chain_plugin.cpp @@ -880,7 +880,7 @@ bool chain_plugin::import_reversible_blocks( const fc::path& reversible_dir, reversible_blocks.open( reversible_blocks_file.generic_string().c_str(), std::ios::in | std::ios::binary ); reversible_blocks.seekg( 0, std::ios::end ); - uint64_t end_pos = reversible_blocks.tellg(); + auto end_pos = reversible_blocks.tellg(); reversible_blocks.seekg( 0 ); uint32_t num = 0; @@ -1585,7 +1585,7 @@ static void push_recurse(read_write* rw, int index, const std::shared_ptremplace_back( r ); } - int next_index = index + 1; + size_t next_index = index + 1; if (next_index < params->size()) { push_recurse(rw, next_index, params, results, next ); } else { diff --git a/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp b/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp index 712a35a2d0f..f64260283ef 100644 --- a/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp +++ b/plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp @@ -98,7 +98,7 @@ struct txn_test_gen_plugin_impl { chain_plugin& cp = app().get_plugin(); const int overlap = 20; - int end = std::min(index + overlap, trxs->size()); + size_t end = std::min(index + overlap, trxs->size()); _remain = end - index; for (int i = index; i < end; ++i) { cp.accept_transaction( packed_transaction(trxs->at(i)), [=](const fc::static_variant& result){ diff --git a/programs/cleos/main.cpp b/programs/cleos/main.cpp index 9150a7fcafb..2fb76cdb945 100644 --- a/programs/cleos/main.cpp +++ b/programs/cleos/main.cpp @@ -1850,7 +1850,7 @@ void get_account( const string& accountName, const string& coresym, bool json_fo auto& prods = obj["producers"].get_array(); std::cout << "producers:"; if ( !prods.empty() ) { - for ( int i = 0; i < prods.size(); ++i ) { + for ( size_t i = 0; i < prods.size(); ++i ) { if ( i%3 == 0 ) { std::cout << std::endl << indent; } diff --git a/programs/eosio-launcher/main.cpp b/programs/eosio-launcher/main.cpp index aca800eb604..66b40819b9d 100644 --- a/programs/eosio-launcher/main.cpp +++ b/programs/eosio-launcher/main.cpp @@ -850,7 +850,7 @@ launcher_def::bind_nodes () { cerr << "Unable to allocate producers due to insufficient prod_nodes = " << prod_nodes << "\n"; exit (10); } - int non_bios = prod_nodes - 1; + size_t non_bios = prod_nodes - 1; int per_node = producers / non_bios; int extra = producers % non_bios; unsigned int i = 0; diff --git a/unittests/api_tests.cpp b/unittests/api_tests.cpp index 909dd061160..ac870af39ac 100644 --- a/unittests/api_tests.cpp +++ b/unittests/api_tests.cpp @@ -201,7 +201,7 @@ transaction_trace_ptr CallAction(TESTER& test, T ac, const vector& auto pl = vector{{scope[0], config::active_name}}; if (scope.size() > 1) - for (int i = 1; i < scope.size(); i++) + for (size_t i = 1; i < scope.size(); i++) pl.push_back({scope[i], config::active_name}); action act(pl, ac); diff --git a/unittests/forked_tests.cpp b/unittests/forked_tests.cpp index 7cfa50f26f9..3b85ea5a614 100644 --- a/unittests/forked_tests.cpp +++ b/unittests/forked_tests.cpp @@ -125,7 +125,7 @@ BOOST_AUTO_TEST_CASE( fork_with_bad_block ) try { BOOST_TEST_CONTEXT("Testing Fork: " << i) { const auto& fork = forks.at(i); // push the fork to the original node - for (int fidx = 0; fidx < fork.blocks.size() - 1; fidx++) { + for (size_t fidx = 0; fidx < fork.blocks.size() - 1; fidx++) { const auto& b = fork.blocks.at(fidx); // push the block only if its not known already if (!bios.control->fetch_block_by_id(b->id())) { @@ -342,7 +342,7 @@ BOOST_AUTO_TEST_CASE( prune_remove_branch ) try { BOOST_REQUIRE_EQUAL(73, c2.control->head_block_num()); // push fork from c2 => c - int p = fork_num; + size_t p = fork_num; while ( p < c2.control->head_block_num()) { auto fb = c2.control->fetch_block_by_number(++p); c.push_block(fb); diff --git a/unittests/message_buffer_tests.cpp b/unittests/message_buffer_tests.cpp index 7209bda8ce4..a591b5de8ed 100644 --- a/unittests/message_buffer_tests.cpp +++ b/unittests/message_buffer_tests.cpp @@ -227,7 +227,7 @@ BOOST_AUTO_TEST_CASE(message_buffer_write_ptr_to_end) BOOST_CHECK_EQUAL(mb.write_index().second, 0); char* write_ptr = mb.write_ptr(); - for (char ind = 0; ind < small; ind++) { + for (uint32_t ind = 0; ind < small; ind++) { *write_ptr = ind; write_ptr++; } diff --git a/unittests/misc_tests.cpp b/unittests/misc_tests.cpp index dcc4560b0f0..5da55591e61 100644 --- a/unittests/misc_tests.cpp +++ b/unittests/misc_tests.cpp @@ -542,7 +542,7 @@ BOOST_AUTO_TEST_CASE(alphabetic_sort) tmp.push_back(str); } - for(int i = 0; i < words.size(); ++i ) { + for(size_t i = 0; i < words.size(); ++i ) { BOOST_TEST(tmp[i] == words[i]); } diff --git a/unittests/resource_limits_test.cpp b/unittests/resource_limits_test.cpp index 69e62915bfb..3bcd8582e4d 100644 --- a/unittests/resource_limits_test.cpp +++ b/unittests/resource_limits_test.cpp @@ -216,7 +216,7 @@ BOOST_AUTO_TEST_SUITE(resource_limits_test) const uint64_t increment = 1000; const uint64_t expected_iterations = config::default_max_block_cpu_usage / increment; - for (int idx = 0; idx < expected_iterations; idx++) { + for (uint64_t idx = 0; idx < expected_iterations; idx++) { add_transaction_usage({account}, increment, 0, 0); } @@ -233,7 +233,7 @@ BOOST_AUTO_TEST_SUITE(resource_limits_test) const uint64_t increment = 1000; const uint64_t expected_iterations = config::default_max_block_net_usage / increment; - for (int idx = 0; idx < expected_iterations; idx++) { + for (uint64_t idx = 0; idx < expected_iterations; idx++) { add_transaction_usage({account}, 0, increment, 0); } @@ -252,7 +252,7 @@ BOOST_AUTO_TEST_SUITE(resource_limits_test) set_account_limits(account, limit, -1, -1 ); process_account_limit_updates(); - for (int idx = 0; idx < expected_iterations - 1; idx++) { + for (uint64_t idx = 0; idx < expected_iterations - 1; idx++) { add_pending_ram_usage(account, increment); verify_account_ram_usage(account); } diff --git a/unittests/special_accounts_tests.cpp b/unittests/special_accounts_tests.cpp index 58e9444b58a..20cd4bcc98d 100644 --- a/unittests/special_accounts_tests.cpp +++ b/unittests/special_accounts_tests.cpp @@ -62,7 +62,7 @@ BOOST_FIXTURE_TEST_CASE(accounts_exists, tester) } std::vector diff; - for (int i = 0; i < std::max(active_auth.size(), active_producers.producers.size()); ++i) { + for (size_t i = 0; i < std::max(active_auth.size(), active_producers.producers.size()); ++i) { account_name n1 = i < active_auth.size() ? active_auth[i] : (account_name)0; account_name n2 = i < active_producers.producers.size() ? active_producers.producers[i].producer_name : (account_name)0; if (n1 != n2) diff.push_back((uint64_t)n2 - (uint64_t)n1);