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

Commit

Permalink
Merge pull request #9681 from EOSIO/huangminghuang/warning-fix
Browse files Browse the repository at this point in the history
warning fix
  • Loading branch information
huangminghuang authored Nov 19, 2020
2 parents 49ce128 + 5d4f35c commit 0e6c6f4
Show file tree
Hide file tree
Showing 32 changed files with 58 additions and 53 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions libraries/chain/backing_store/tests/benchmark_kv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ measurement_t benchmark_get(const cmd_args& args, const std::unique_ptr<kv_conte
rusage usage_start, usage_end;

getrusage(RUSAGE_SELF, &usage_start);
for (auto i = 0; i < num_loops; ++i) {
for (auto i = 0U; i < num_loops; ++i) {
for (auto& key: workset) {
uint32_t actual_value_size;
kv_context_ptr->kv_get(contract, key.c_str(), key.size(),actual_value_size);
Expand All @@ -204,7 +204,7 @@ measurement_t benchmark_get_data(const cmd_args& args, const std::unique_ptr<kv_
rusage usage_start, usage_end;

getrusage(RUSAGE_SELF, &usage_start);
for (auto i = 0; i < num_loops; ++i) {
for (auto i = 0U; i < num_loops; ++i) {
for (auto& key: workset) {
kv_context_ptr->kv_get_data(0, data, args.value_size);
}
Expand All @@ -221,7 +221,7 @@ measurement_t benchmark_set(const cmd_args& args, const std::unique_ptr<kv_conte
rusage usage_start, usage_end;

getrusage(RUSAGE_SELF, &usage_start);
for (auto i = 0; i < num_loops; ++i) {
for (auto i = 0U; i < num_loops; ++i) {
for (auto& key: workset) {
kv_context_ptr->kv_set(contract, key.c_str(), key.size(), value.c_str(), value.size(), payer);
}
Expand Down Expand Up @@ -270,7 +270,7 @@ measurement_t benchmark_erase(const cmd_args& args, const std::unique_ptr<kv_con
measurement_t benchmark_it_create(const cmd_args& args, const std::unique_ptr<kv_context>& 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.
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/backing_store/tests/test_kv_rocksdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/combined_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,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<index_t> row;
read_row(row);
backing_store::payer_payload pp{row.payer, nullptr, 0};
Expand Down
4 changes: 4 additions & 0 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@

#include <new>

#if defined(EOSIO_EOS_VM_RUNTIME_ENABLED) || defined(EOSIO_EOS_VM_JIT_RUNTIME_ENABLED)
#include <eosio/vm/allocator.hpp>
#endif

namespace eosio { namespace chain {

using resource_limits::resource_limits_manager;
Expand Down
2 changes: 2 additions & 0 deletions libraries/chain/include/eosio/chain/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions libraries/chain/include/eosio/chain/wasm_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
#include <eosio/chain/types.hpp>
#include <eosio/chain/whitelisted_intrinsics.hpp>
#include <eosio/chain/exceptions.hpp>
#if defined(EOSIO_EOS_VM_RUNTIME_ENABLED) || defined(EOSIO_EOS_VM_JIT_RUNTIME_ENABLED)
#include <eosio/vm/allocator.hpp>
#endif
#include "Runtime/Linker.h"
#include "Runtime/Runtime.h"

Expand Down
8 changes: 4 additions & 4 deletions libraries/chain/webassembly/crypto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<protocol_state_object>().num_supported_key_types, unactivated_signature_type,
EOS_ASSERT(static_cast<unsigned>(s.which()) < context.db.get<protocol_state_object>().num_supported_key_types, unactivated_signature_type,
"Unactivated signature type used during assert_recover_key");
EOS_ASSERT(p.which() < context.db.get<protocol_state_object>().num_supported_key_types, unactivated_key_type,
EOS_ASSERT(static_cast<unsigned>(p.which()) < context.db.get<protocol_state_object>().num_supported_key_types, unactivated_key_type,
"Unactivated key type used when creating assert_recover_key");

if(context.control.is_producing_block())
Expand All @@ -36,7 +36,7 @@ namespace eosio { namespace chain { namespace webassembly {
datastream<const char*> ds( sig.data(), sig.size() );
fc::raw::unpack(ds, s);

EOS_ASSERT(s.which() < context.db.get<protocol_state_object>().num_supported_key_types, unactivated_signature_type,
EOS_ASSERT(static_cast<unsigned>(s.which()) < context.db.get<protocol_state_object>().num_supported_key_types, unactivated_signature_type,
"Unactivated signature type used during recover_key");

if(context.control.is_producing_block())
Expand All @@ -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<unsigned>(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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint64_t>(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<uint64_t>(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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::size_t>(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<uint64_t>(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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ std::tuple<bool, eosvmoc_message, std::vector<wrapped_fd>> 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<unsigned>(red) >= sizeof(buff))
return {false, message, std::move(fds)};

try {
Expand Down
6 changes: 3 additions & 3 deletions libraries/chain_kv/include/b1/chain_kv/chain_kv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ namespace detail {

template<typename It, typename Key, std::size_t N>
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<Key>::type;
constexpr static auto key_size = sizeof(t_type) * N;
if (distance < key_size)
Expand Down Expand Up @@ -468,7 +468,7 @@ class undo_stack {
throw exception("cannot set revision while there is an existing undo stack");
if (revision > std::numeric_limits<int64_t>::max())
throw exception("revision to set is too high");
if (revision < state.revision)
if (static_cast<int64_t>(revision) < state.revision)
throw exception("revision cannot decrease");
state.revision = revision;
if (write_now)
Expand Down Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain_kv/include/b1/session/shared_bytes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ inline shared_bytes shared_bytes::previous() const {
index = buffer.size();
}
}
while (index < buffer.size()) {
while (static_cast<std::size_t>(index) < buffer.size()) {
buffer[index] = std::numeric_limits<unsigned char>::max();
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/chainbase
4 changes: 2 additions & 2 deletions plugins/chain_plugin/chain_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2126,14 +2126,14 @@ void read_only::make_prefix(eosio::name table_name, eosio::name index_name, uin
vector<char> 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];
}
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/chain_plugin/test/test_account_query_db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ 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;
}
}
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<args.size(); ++i) {
for (auto i=0U; i<args.size(); ++i) {
argv[i+1] = args[i].c_str();
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/resource_monitor_plugin/test/test_threshold.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 (auto i = 0U; i < available.size(); i++) {
add_file_system("/test" + std::to_string(i));
}

Expand Down
4 changes: 2 additions & 2 deletions plugins/trace_api_plugin/compressed_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ struct compressed_file_impl {
});

// special case when there is a seek point that is exact
if ( iter != seek_point_map.end() && std::get<0>(*iter) == loc ) {
if ( iter != seek_point_map.end() && std::get<0>(*iter) == static_cast<unsigned long>(loc) ) {
file.seek(std::get<1>(*iter));
return;
}
Expand Down Expand Up @@ -233,7 +233,7 @@ bool compressed_file::process( const fc::path& input_path, const fc::path& outpu
auto output_buffer = std::vector<uint8_t>(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
Expand Down
2 changes: 1 addition & 1 deletion plugins/trace_api_plugin/store_provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions plugins/trace_api_plugin/test/test_compressed_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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<T>(128);
auto compf = compressed_file(compressed_filename);
compf.open();
Expand Down Expand Up @@ -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<T>(32);
auto compf = compressed_file(compressed_filename);
compf.open();
Expand Down
4 changes: 2 additions & 2 deletions plugins/trace_api_plugin/test/test_responses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint8_t, chain::transaction_receipt_header::status_enum>{chain::transaction_receipt_header::status_enum::executed},
10,
5,
Expand Down
10 changes: 5 additions & 5 deletions plugins/trace_api_plugin/test/test_trace_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down Expand Up @@ -268,7 +268,7 @@ namespace {

std::vector<char> _buffer;
mode _mode = write_mode;
long _pos = 0l;
unsigned long _pos = 0lu;
bool _flush = false;
bool _sync = false;
};
Expand Down Expand Up @@ -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)));
Expand Down Expand Up @@ -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()) {
Expand Down
2 changes: 1 addition & 1 deletion programs/eosio-tester/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t>(file_index) >= state.files.size() || !state.files[file_index].f)
throw std::runtime_error("file is not opened");
return state.files[file_index];
}
Expand Down
Loading

0 comments on commit 0e6c6f4

Please sign in to comment.