提交 98bf1aaf 编写于 作者: D Daniel Larimer

fix warnings in many contracts

上级 e734fef2
......@@ -111,7 +111,7 @@ macro(compile_wast)
list(APPEND WASM_COMMAND -Wno-everything)
else()
list(APPEND WASM_COMMAND -Weverything -Wno-c++98-compat -Wno-old-style-cast -Wno-vla -Wno-vla-extension -Wno-c++98-compat-pedantic
-Wno-missing-prototypes -Wno-missing-variable-declarations -Wno-packed)
-Wno-missing-prototypes -Wno-missing-variable-declarations -Wno-packed -Wno-padded -Wno-c99-extensions)
endif()
foreach(folder ${ARG_INCLUDE_FOLDERS})
......
......@@ -34,12 +34,13 @@ namespace eosiosystem {
struct producer_votes {
account_name owner;
uint64_t padding = 0;
uint128_t total_votes;
uint64_t primary_key()const { return owner; }
uint128_t by_votes()const { return total_votes; }
EOSLIB_SERIALIZE( producer_votes, (owner)(total_votes) );
EOSLIB_SERIALIZE( producer_votes, (owner)(total_votes) )
};
typedef eosio::multi_index< N(producervote), producer_votes,
indexed_by<N(prototalvote), const_mem_fun<producer_votes, uint128_t, &producer_votes::by_votes> >
......@@ -54,7 +55,7 @@ namespace eosiosystem {
uint64_t primary_key()const { return owner; }
EOSLIB_SERIALIZE( account_votes, (owner)(proxy)(last_update)(staked)(producers) );
EOSLIB_SERIALIZE( account_votes, (owner)(proxy)(last_update)(staked)(producers) )
};
typedef eosio::multi_index< N(accountvotes), account_votes> account_votes_index_type;
......@@ -64,7 +65,7 @@ namespace eosiosystem {
eosio::bytes packed_key; /// a packed public key object
uint64_t primary_key()const { return owner; }
EOSLIB_SERIALIZE( producer_config, (owner)(packed_key) );
EOSLIB_SERIALIZE( producer_config, (owner)(packed_key) )
};
typedef eosio::multi_index< N(producercfg), producer_config> producer_config_index_type;
......@@ -76,7 +77,7 @@ namespace eosiosystem {
uint64_t primary_key()const { return owner; }
EOSLIB_SERIALIZE( total_resources, (owner)(total_net_weight)(total_cpu_weight)(total_ram) );
EOSLIB_SERIALIZE( total_resources, (owner)(total_net_weight)(total_cpu_weight)(total_ram) )
};
......@@ -102,7 +103,7 @@ namespace eosiosystem {
EOSLIB_SERIALIZE( delegated_bandwidth, (from)(to)(net_weight)(cpu_weight)
(start_pending_net_withdraw)(pending_net_withdraw)(deferred_net_withdraw_handler)
(start_pending_cpu_withdraw)(pending_cpu_withdraw)(deferred_cpu_withdraw_handler) );
(start_pending_cpu_withdraw)(pending_cpu_withdraw)(deferred_cpu_withdraw_handler) )
};
......@@ -120,13 +121,13 @@ namespace eosiosystem {
account_name producer;
bytes producer_key;
EOSLIB_SERIALIZE( regproducer, (producer)(producer_key) );
EOSLIB_SERIALIZE( regproducer, (producer)(producer_key) )
};
ACTION( SystemAccount, regproxy ) {
account_name proxy_to_register;
EOSLIB_SERIALIZE( regproxy, (proxy_to_register) );
EOSLIB_SERIALIZE( regproxy, (proxy_to_register) )
};
ACTION( SystemAccount, delegatebw ) {
......@@ -151,7 +152,7 @@ namespace eosiosystem {
ACTION( SystemAccount, nonce ) {
eosio::string value;
EOSLIB_SERIALIZE( nonce, (value) );
EOSLIB_SERIALIZE( nonce, (value) )
};
/// new id options:
......@@ -319,7 +320,7 @@ namespace eosiosystem {
});
currency::inline_transfer( sv.voter, SystemAccount, sv.amount, "stake for voting" );
};
}
ACTION( SystemAccount, voteproducer ) {
account_name voter;
......
......@@ -99,7 +99,7 @@ class datastream {
* @brief Gets the position within the current stream
* @return p the position within the current stream
*/
inline size_t tellp()const { return _pos - _start; }
inline size_t tellp()const { return size_t(_pos - _start); }
/**
* Returns the number of remaining bytes that can be read/skipped
......
......@@ -304,8 +304,6 @@ int32_t update_str( account_name scope, table_name table, account_name bta, char
* @param scope - the account scope that will be read, must exist in the transaction scopes list
* @param code - identifies the code that controls write-access to the data
* @param table - the ID/name of the table within the scope/code context to query
* @param key - location of the record key
* @param keylen - length of the record key
* @param value - location to copy the front record value
* @param valuelen - maximum length of the record value to read
* @return the number of bytes read or -1 if key was not found
......@@ -316,8 +314,6 @@ int32_t update_str( account_name scope, table_name table, account_name bta, char
* @param scope - the account scope that will be read, must exist in the transaction scopes list
* @param code - identifies the code that controls write-access to the data
* @param table - the ID/name of the table within the scope/code context to query
* @param key - location of the record key
* @param keylen - length of the record key
* @param value - location to copy the back record value
* @param valuelen - maximum length of the record value to read
* @return the number of bytes read or -1 if key was not found
......
此差异已折叠。
......@@ -47,7 +47,7 @@ namespace eosio {
return nullptr;
}
const uint32_t new_heap_size = remaining > _new_heap_size ? _new_heap_size : remaining;
const uint32_t new_heap_size = uint32_t(remaining) > _new_heap_size ? _new_heap_size : uint32_t(remaining);
char* new_memory_start = static_cast<char*>(sbrk(new_heap_size));
// if we can expand the current memory, keep working with it
if (current_memory->expand_memory(new_memory_start, new_heap_size))
......@@ -281,12 +281,11 @@ namespace eosio {
return nullptr;
}
const int32_t diff = size - *orig_ptr_size;
if (diff < 0)
if( *orig_ptr_size > size )
{
// use a buffer_ptr to allocate the memory to free
char* const new_ptr = ptr + size + _size_marker;
buffer_ptr excess_to_free(new_ptr, -diff, _heap + _heap_size);
buffer_ptr excess_to_free(new_ptr, *orig_ptr_size - size, _heap + _heap_size);
excess_to_free.mark_free();
return ptr;
......@@ -295,11 +294,11 @@ namespace eosio {
else if (orig_buffer_end == &_heap[_offset])
{
orig_buffer.size(size);
_offset += diff;
_offset += size - *orig_ptr_size;
return ptr;
}
if (-diff == 0)
if (size == *orig_ptr_size )
return ptr;
if (!orig_buffer.merge_contiguous_if_available(size))
......@@ -416,7 +415,7 @@ namespace eosio {
bool merge_contiguous(uint32_t needed_size, bool all_or_nothing)
{
// do not bother if there isn't contiguious space to allocate
if (all_or_nothing && _heap_end - _ptr < needed_size)
if( all_or_nothing && uint32_t(_heap_end - _ptr) < needed_size )
return false;
uint32_t possible_size = _size;
......@@ -470,7 +469,7 @@ namespace eosio {
uint32_t _heaps_actual_size;
uint32_t _active_heap;
uint32_t _active_free_heap;
static const uint32_t _alloc_memory_mask = 1 << 31;
static const uint32_t _alloc_memory_mask = uint32_t(1) << 31;
};
memory_manager memory_heap;
......
......@@ -168,7 +168,7 @@ class multi_index
const multi_index& __idx;
int __primary_itr;
int __iters[sizeof...(Indicies)];
int __iters[sizeof...(Indicies)+(sizeof...(Indicies)==0)];
};
uint64_t _code;
......@@ -214,10 +214,11 @@ class multi_index
return *cacheitr;
auto size = db_get_i64( itr, nullptr, 0 );
eosio_assert( size >= 0, "error reading iterator" );
char tmp[size];
db_get_i64( itr, tmp, size );
db_get_i64( itr, tmp, uint32_t(size) );
datastream<const char*> ds(tmp,size);
datastream<const char*> ds(tmp,uint32_t(size));
auto result = _items_index.emplace( *this, [&]( auto& i ) {
T& val = static_cast<T&>(i);
......@@ -239,7 +240,6 @@ class multi_index
public:
multi_index( uint64_t code, uint64_t scope ):_code(code),_scope(scope){}
~multi_index() { }
uint64_t get_code()const { return _code; }
uint64_t get_scope()const { return _scope; }
......
......@@ -44,7 +44,7 @@ namespace eosio {
* @param num to be printed
*/
inline void print( int num ) {
printi(num);
printi(uint64_t(num));
}
/**
......
......@@ -16,7 +16,7 @@ extern "C" {
* @{
*/
void set_resource_limits( account_name account, int64_t ram_bytes, int64_t net_weight, int64_t cpu_weight, int64_t ignored);
void set_resource_limits( account_name account, uint64_t ram_bytes, uint64_t net_weight, uint64_t cpu_weight, int64_t ignored);
void set_active_producers( char *producer_data, size_t producer_data_size );
......
......@@ -38,7 +38,7 @@ namespace eosio {
if ( read < 0 ) {
return def;
}
return unpack<T>( temp + sizeof(SingletonName), read );
return unpack<T>( temp + sizeof(SingletonName), size_t(read) );
}
static T get_or_create( scope_name scope = Code, const T& def = T() ) {
......
......@@ -23,7 +23,7 @@ namespace eosio {
auto read = load_i64( DefaultScope, scope , TableName, temp, sizeof(temp) );
eosio_assert( read > 0, "key does not exist" );
datastream<const char*> ds(temp, read);
datastream<const char*> ds(temp, uint32_t(read) );
T result;
ds >> result;
return result;
......@@ -39,7 +39,7 @@ namespace eosio {
return def;
}
datastream<const char*> ds(temp, read);
datastream<const char*> ds(temp, uint32_t(read) );
T result;
ds >> result;
return result;
......@@ -54,7 +54,7 @@ namespace eosio {
return def;
}
datastream<const char*> ds(temp, read);
datastream<const char*> ds(temp, uint32_t(read) );
T result;
ds >> result;
return result;
......
......@@ -39,7 +39,7 @@ namespace eosio {
for( uint32_t i = 0; i <= 12; ++i ) {
uint64_t c = 0;
if( i < len && i <= 12 ) c = char_to_symbol( str[i] );
if( i < len && i <= 12 ) c = uint64_t(char_to_symbol( str[i] ));
if( i < 12 ) {
c &= 0x1f;
......
......@@ -102,7 +102,7 @@ struct signed_int {
template<typename DataStream>
friend DataStream& operator << ( DataStream& ds, const signed_int& v ){
uint32_t val = (v.value<<1) ^ (v.value>>31);
uint32_t val = uint32_t((v.value<<1) ^ (v.value>>31));
do {
uint8_t b = uint8_t(val) & 0x7f;
val >>= 7;
......
......@@ -5,6 +5,7 @@ using namespace eosio;
struct limit_order {
uint64_t id;
uint64_t padding = 0;
uint128_t price;
uint64_t expiration;
account_name owner;
......@@ -32,6 +33,7 @@ extern "C" {
});
orders.update( order, payer, [&]( auto& o ) {
o.expiration = 4;
});
const auto* o = orders.find( 1 );
......@@ -41,9 +43,11 @@ extern "C" {
auto expidx = orders.get_index<N(byexp)>();
for( const auto& item : orders ) {
(void)item.id;
}
for( const auto& item : expidx ) {
(void)item.id;
}
auto lower = expidx.lower_bound(4);
......
......@@ -193,7 +193,7 @@ namespace stltest {
prints("f() called\n");
}
static void on(const message& msg) {
static void on( const message& ) {
/* manual initialization of global variable
new(&std::__start_std_streams)std::ios_base::Init;
*/
......@@ -244,7 +244,7 @@ namespace stltest {
std::map<int, long> m;
m.emplace(0, 1);
auto mit = m.lower_bound(2);
m.lower_bound(2);
std::set<long> st;
st.insert(0);
......@@ -257,7 +257,7 @@ namespace stltest {
//hs.insert(0);
sort(dq.begin(), dq.end());
auto lit = find_if(l.begin(), l.end(), [](uint32_t f) { return f < 10; });
find_if(l.begin(), l.end(), [](uint32_t f) { return f < 10; });
prints("STL test done.\n");
//std::cout << "STL test done." << std::endl;
}
......
......@@ -18,33 +18,33 @@ namespace testsystem {
};
struct set_account_limits : dispatchable<N(setalimits)> {
account_name account;
int64_t ram_bytes;
int64_t net_weight;
int64_t cpu_weight;
account_name account;
uint64_t ram_bytes = 0;
uint64_t net_weight = 0;
uint64_t cpu_weight = 0;
static void process(const set_account_limits& act) {
set_resource_limits(act.account, act.ram_bytes, act.net_weight, act.cpu_weight, 0);
}
EOSLIB_SERIALIZE( set_account_limits, (account)(ram_bytes)(net_weight)(cpu_weight) );
EOSLIB_SERIALIZE( set_account_limits, (account)(ram_bytes)(net_weight)(cpu_weight) )
};
struct set_global_limits : dispatchable<N(setglimits)> {
int64_t cpu_usec_per_period;
static void process(const set_global_limits& act) {
static void process(const set_global_limits& ) {
// TODO: support this
}
EOSLIB_SERIALIZE( set_global_limits, (cpu_usec_per_period) );
EOSLIB_SERIALIZE( set_global_limits, (cpu_usec_per_period) )
};
struct producer_key {
account_name account;
std::string public_key;
EOSLIB_SERIALIZE( producer_key, (account)(public_key) );
EOSLIB_SERIALIZE( producer_key, (account)(public_key) )
};
struct set_producers : dispatchable<N(setprods)> {
......@@ -57,7 +57,7 @@ namespace testsystem {
set_active_producers(buffer, sizeof(buffer));
}
EOSLIB_SERIALIZE( set_producers, (version)(producers) );
EOSLIB_SERIALIZE( set_producers, (version)(producers) )
};
struct require_auth : dispatchable<N(reqauth)> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册