Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Fix numerous signed unsigned mismatch warnings. #6655

Merged
merged 2 commits into from
Feb 11, 2019
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
4 changes: 2 additions & 2 deletions libraries/chain/include/eosio/chain/apply_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
jgiszczak marked this conversation as resolved.
Show resolved Hide resolved
EOS_ASSERT( result, table_operation_not_permitted, "dereference of deleted object" );
return *result;
Expand All @@ -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];
jgiszczak marked this conversation as resolved.
Show resolved Hide resolved
if( !obj_ptr ) return;
_iterator_to_object[iterator] = nullptr;
Expand Down
4 changes: 2 additions & 2 deletions libraries/chain/include/eosio/chain/wasm_eosio_injection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint16_t> type_slot_list = { static_cast<uint16_t>(mod.types[i]->ret) };
jgiszczak marked this conversation as resolved.
Show resolved Hide resolved
for ( auto param : mod.types[i]->parameters )
type_slot_list.push_back( static_cast<uint16_t>(param) );
Expand Down Expand Up @@ -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 ) {
jgiszczak marked this conversation as resolved.
Show resolved Hide resolved
module.exports[i].index++;
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/wasm_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1266,7 +1266,7 @@ class memory_api : public context_aware_api {
:context_aware_api(ctx,true){}

char* memcpy( array_ptr<char> dest, array_ptr<const char> 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,
jgiszczak marked this conversation as resolved.
Show resolved Hide resolved
overlapping_memory_error, "memcpy can only accept non-aliasing pointers");
return (char *)::memcpy(dest, src, length);
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/testing/tester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
jgiszczak marked this conversation as resolved.
Show resolved Hide resolved
if( block ) { //&& !b.control->is_known_block(block->id()) ) {
auto bs = b.control->create_block_state_future( block );
Expand Down
4 changes: 2 additions & 2 deletions plugins/chain_plugin/chain_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
jgiszczak marked this conversation as resolved.
Show resolved Hide resolved

uint32_t num = 0;
Expand Down Expand Up @@ -1585,7 +1585,7 @@ static void push_recurse(read_write* rw, int index, const std::shared_ptr<read_w
results->emplace_back( r );
}

int next_index = index + 1;
size_t next_index = index + 1;
if (next_index < params->size()) {
jgiszczak marked this conversation as resolved.
Show resolved Hide resolved
push_recurse(rw, next_index, params, results, next );
} else {
Expand Down
2 changes: 1 addition & 1 deletion plugins/txn_test_gen_plugin/txn_test_gen_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ struct txn_test_gen_plugin_impl {
chain_plugin& cp = app().get_plugin<chain_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;
jgiszczak marked this conversation as resolved.
Show resolved Hide resolved
for (int i = index; i < end; ++i) {
cp.accept_transaction( packed_transaction(trxs->at(i)), [=](const fc::static_variant<fc::exception_ptr, transaction_trace_ptr>& result){
Expand Down
2 changes: 1 addition & 1 deletion programs/cleos/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
jgiszczak marked this conversation as resolved.
Show resolved Hide resolved
std::cout << std::endl << indent;
}
Expand Down
2 changes: 1 addition & 1 deletion programs/eosio-launcher/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
jgiszczak marked this conversation as resolved.
Show resolved Hide resolved
int extra = producers % non_bios;
unsigned int i = 0;
Expand Down
2 changes: 1 addition & 1 deletion unittests/api_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ transaction_trace_ptr CallAction(TESTER& test, T ac, const vector<account_name>&

auto pl = vector<permission_level>{{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});
jgiszczak marked this conversation as resolved.
Show resolved Hide resolved

action act(pl, ac);
Expand Down
4 changes: 2 additions & 2 deletions unittests/forked_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
jgiszczak marked this conversation as resolved.
Show resolved Hide resolved
// push the block only if its not known already
if (!bios.control->fetch_block_by_id(b->id())) {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion unittests/message_buffer_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
Expand Down
2 changes: 1 addition & 1 deletion unittests/misc_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
jgiszczak marked this conversation as resolved.
Show resolved Hide resolved
}

Expand Down
6 changes: 3 additions & 3 deletions unittests/resource_limits_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
jgiszczak marked this conversation as resolved.
Show resolved Hide resolved
}

Expand All @@ -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);
jgiszczak marked this conversation as resolved.
Show resolved Hide resolved
}

Expand All @@ -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);
jgiszczak marked this conversation as resolved.
Show resolved Hide resolved
verify_account_ram_usage(account);
}
Expand Down
2 changes: 1 addition & 1 deletion unittests/special_accounts_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ BOOST_FIXTURE_TEST_CASE(accounts_exists, tester)
}

std::vector<account_name> 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;
jgiszczak marked this conversation as resolved.
Show resolved Hide resolved
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);
Expand Down