From 5449f5bb6510fa0ce68fe11c767a8bec8f9b15ab Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Wed, 3 Aug 2022 09:05:49 -0400 Subject: [PATCH 1/2] grab bag of warning fixes --- .../resource_monitor_plugin/test/test_threshold.cpp | 2 +- unittests/eosio.token_tests.cpp | 4 ++-- unittests/state_history_tests.cpp | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/plugins/resource_monitor_plugin/test/test_threshold.cpp b/plugins/resource_monitor_plugin/test/test_threshold.cpp index 60c6130020..f0e0b3fb8e 100644 --- a/plugins/resource_monitor_plugin/test/test_threshold.cpp +++ b/plugins/resource_monitor_plugin/test/test_threshold.cpp @@ -72,7 +72,7 @@ struct threshold_fixture { set_threshold(80, warning_threshold); set_shutdown_on_exceeded(true); - for (auto i = 0; i < available.size(); i++) { + for (size_t i = 0; i < available.size(); i++) { add_file_system("/test" + std::to_string(i)); } diff --git a/unittests/eosio.token_tests.cpp b/unittests/eosio.token_tests.cpp index 29526fe173..fd909ff143 100644 --- a/unittests/eosio.token_tests.cpp +++ b/unittests/eosio.token_tests.cpp @@ -152,7 +152,7 @@ BOOST_FIXTURE_TEST_CASE( create_max_supply, eosio_token_tester ) try { share_type amount = 4611686018427387904; static_assert(sizeof(share_type) <= sizeof(asset), "asset changed so test is no longer valid"); static_assert(std::is_trivially_copyable::value, "asset is not trivially copyable"); - memcpy(&max, &amount, sizeof(share_type)); // hack in an invalid amount + memcpy((char*)&max, &amount, sizeof(share_type)); // hack in an invalid amount BOOST_CHECK_EXCEPTION( create( "alice"_n, max) , asset_type_exception, [](const asset_type_exception& e) { return expect_assert_message(e, "magnitude of asset amount must be less than 2^62"); @@ -177,7 +177,7 @@ BOOST_FIXTURE_TEST_CASE( create_max_decimals, eosio_token_tester ) try { share_type amount = 0x8ac7230489e80000L; static_assert(sizeof(share_type) <= sizeof(asset), "asset changed so test is no longer valid"); static_assert(std::is_trivially_copyable::value, "asset is not trivially copyable"); - memcpy(&max, &amount, sizeof(share_type)); // hack in an invalid amount + memcpy((char*)&max, &amount, sizeof(share_type)); // hack in an invalid amount BOOST_CHECK_EXCEPTION( create( "alice"_n, max) , asset_type_exception, [](const asset_type_exception& e) { return expect_assert_message(e, "magnitude of asset amount must be less than 2^62"); diff --git a/unittests/state_history_tests.cpp b/unittests/state_history_tests.cpp index a48f4087f0..cb9d1c4b34 100644 --- a/unittests/state_history_tests.cpp +++ b/unittests/state_history_tests.cpp @@ -46,7 +46,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(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))); } @@ -120,7 +120,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(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"); @@ -285,7 +285,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(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); @@ -490,7 +490,7 @@ BOOST_AUTO_TEST_CASE(test_deltas_resources_history) { std::multiset expected_contract_row_table_names {"abihash", "abihash", "hashobjs", "hashobjs", "hashobjs", "numobjs", "numobjs", "numobjs"}; - std::multiset expected_contract_row_table_primary_keys {6138663577826885632,14605619288908759040, 0, 1 ,2, 0, 1, 2}; + std::multiset expected_contract_row_table_primary_keys {6138663577826885632U,14605619288908759040U, 0, 1 ,2, 0, 1, 2}; std::multiset result_contract_row_table_names; std::multiset result_contract_row_table_primary_keys; for(auto &contract_row : contract_rows) { @@ -514,7 +514,7 @@ BOOST_AUTO_TEST_CASE(test_deltas_resources_history) { BOOST_REQUIRE_EQUAL(it_contract_row->rows.obj.size(), 2); contract_rows = chain.deserialize_data(it_contract_row); - for(int i=0; i < contract_rows.size(); i++) { + for(size_t i=0; i < contract_rows.size(); i++) { BOOST_REQUIRE_EQUAL(it_contract_row->rows.obj[i].first, 0); BOOST_REQUIRE_EQUAL(contract_rows[i].table.to_string(), "numobjs"); } @@ -525,7 +525,7 @@ BOOST_AUTO_TEST_CASE(test_deltas_resources_history) { BOOST_REQUIRE_EQUAL(it_contract_index_double->rows.obj.size(), 2); auto contract_index_double_elems = chain.deserialize_data(it_contract_index_double); - for(int i=0; i < contract_index_double_elems.size(); i++) { + for(size_t i=0; i < contract_index_double_elems.size(); i++) { BOOST_REQUIRE_EQUAL(it_contract_index_double->rows.obj[i].first, 0); BOOST_REQUIRE_EQUAL(contract_index_double_elems[i].table.to_string(), "numobjs.....2"); } From 507ba018110337140484fb4cb3f8ef56a352be98 Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Fri, 5 Aug 2022 11:48:01 -0400 Subject: [PATCH 2/2] revert token test's asset warning fix for now --- unittests/eosio.token_tests.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unittests/eosio.token_tests.cpp b/unittests/eosio.token_tests.cpp index fd909ff143..29526fe173 100644 --- a/unittests/eosio.token_tests.cpp +++ b/unittests/eosio.token_tests.cpp @@ -152,7 +152,7 @@ BOOST_FIXTURE_TEST_CASE( create_max_supply, eosio_token_tester ) try { share_type amount = 4611686018427387904; static_assert(sizeof(share_type) <= sizeof(asset), "asset changed so test is no longer valid"); static_assert(std::is_trivially_copyable::value, "asset is not trivially copyable"); - memcpy((char*)&max, &amount, sizeof(share_type)); // hack in an invalid amount + memcpy(&max, &amount, sizeof(share_type)); // hack in an invalid amount BOOST_CHECK_EXCEPTION( create( "alice"_n, max) , asset_type_exception, [](const asset_type_exception& e) { return expect_assert_message(e, "magnitude of asset amount must be less than 2^62"); @@ -177,7 +177,7 @@ BOOST_FIXTURE_TEST_CASE( create_max_decimals, eosio_token_tester ) try { share_type amount = 0x8ac7230489e80000L; static_assert(sizeof(share_type) <= sizeof(asset), "asset changed so test is no longer valid"); static_assert(std::is_trivially_copyable::value, "asset is not trivially copyable"); - memcpy((char*)&max, &amount, sizeof(share_type)); // hack in an invalid amount + memcpy(&max, &amount, sizeof(share_type)); // hack in an invalid amount BOOST_CHECK_EXCEPTION( create( "alice"_n, max) , asset_type_exception, [](const asset_type_exception& e) { return expect_assert_message(e, "magnitude of asset amount must be less than 2^62");