Skip to content

Commit 0c7a636

Browse files
committed
Fixed multiple warnings
1 parent e773214 commit 0c7a636

File tree

17 files changed

+52
-26
lines changed

17 files changed

+52
-26
lines changed

contracts/asserter/asserter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ static int global_variable = 45;
1111

1212
extern "C" {
1313
/// The apply method implements the dispatch of events to this contract
14-
void apply( uint64_t receiver, uint64_t code, uint64_t action ) {
14+
void apply( uint64_t /* receiver */, uint64_t code, uint64_t action ) {
1515
require_auth(code);
1616
if( code == N(asserter) ) {
1717
if( action == N(procassert) ) {

contracts/eosio.bios/eosio.bios.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace eosio {
1515

1616
void setalimits( account_name account, uint64_t ram_bytes, uint64_t net_weight, uint64_t cpu_weight ) {
1717
require_auth( _self );
18-
set_resource_limits( account, ram_bytes, net_weight, cpu_weight );
18+
set_resource_limits( account, (int64_t)ram_bytes, (int64_t)net_weight, (int64_t)cpu_weight );
1919
}
2020

2121
void setglimits( uint64_t ram, uint64_t net, uint64_t cpu ) {

contracts/eosio.system/delegate_bandwidth.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ namespace eosiosystem {
169169
tokens_out = es.convert( asset(bytes,S(0,RAM)), CORE_SYMBOL);
170170
});
171171

172-
_gstate.total_ram_bytes_reserved -= bytes;
172+
_gstate.total_ram_bytes_reserved -= static_cast<decltype(_gstate.total_ram_bytes_reserved)>(bytes); // bytes > 0 is asserted above
173173
_gstate.total_ram_stake -= tokens_out.amount;
174174

175175
//// this shouldn't happen, but just in case it does we should prevent it
@@ -190,7 +190,6 @@ namespace eosiosystem {
190190
}
191191

192192
void validate_b1_vesting( int64_t stake ) {
193-
const int64_t seconds_per_year = 60*60*24*365;
194193
const int64_t base_time = 1527811200; /// 2018-06-01
195194
const int64_t max_claimable = 100'000'000'0000ll;
196195
const int64_t claimable = int64_t(max_claimable * double(now()-base_time) / (10*seconds_per_year) );

contracts/eosio.system/voting.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ namespace eosiosystem {
100100
bytes packed_schedule = pack(producers);
101101

102102
if( set_proposed_producers( packed_schedule.data(), packed_schedule.size() ) >= 0 ) {
103-
_gstate.last_producer_schedule_size = top_producers.size();
103+
_gstate.last_producer_schedule_size = static_cast<decltype(_gstate.last_producer_schedule_size)>( top_producers.size() );
104104
}
105105
}
106106

contracts/exchange/exchange.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ namespace eosio {
112112

113113
void exchange::createx( account_name creator,
114114
asset initial_supply,
115-
uint32_t fee,
115+
uint32_t /* fee */,
116116
extended_asset base_deposit,
117117
extended_asset quote_deposit
118118
) {

contracts/multi_index_test/multi_index_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ struct limit_order {
168168
namespace multi_index_test {
169169
extern "C" {
170170
/// The apply method implements the dispatch of events to this contract
171-
void apply( uint64_t receiver, uint64_t code, uint64_t action ) {
171+
void apply( uint64_t /* receiver */, uint64_t code, uint64_t action ) {
172172
require_auth(code);
173173
eosio_assert(eosio::dispatch<multi_index_test, multi_index_test::trigger>(code, action),
174174
"Could not dispatch");

contracts/proxy/proxy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace proxy {
3333
};
3434

3535
template<typename T>
36-
void apply_transfer(uint64_t receiver, account_name code, const T& transfer) {
36+
void apply_transfer(uint64_t receiver, account_name /* code */, const T& transfer) {
3737
config code_config;
3838
const auto self = receiver;
3939
auto get_res = configs::get(code_config, self);

contracts/test_api/test_datastream.cpp

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
#include <eosiolib/eosio.hpp>
33
#include <eosiolib/datastream.hpp>
4+
#include <cmath>
45

56
#include "test_api.hpp"
67

@@ -17,6 +18,32 @@ struct testtype {
1718
}
1819
};
1920

21+
template <>
22+
struct testtype<double> {
23+
static void run(const double &v, const char *errmsg = "") {
24+
char buf[128];
25+
eosio::datastream<char *> ds(buf, sizeof(buf));
26+
ds << v;
27+
double v2;
28+
ds.seekp(0);
29+
ds >> v2;
30+
eosio_assert(std::abs(v - v2) < 1e-20, errmsg);
31+
}
32+
};
33+
34+
template <>
35+
struct testtype<float> {
36+
static void run(const float &v, const char *errmsg = "") {
37+
char buf[128];
38+
eosio::datastream<char *> ds(buf, sizeof(buf));
39+
ds << v;
40+
float v2;
41+
ds.seekp(0);
42+
ds >> v2;
43+
eosio_assert(std::abs(v - v2) < float(1e-10), errmsg);
44+
}
45+
};
46+
2047
void test_datastream::test_basic()
2148
{
2249

@@ -28,7 +55,7 @@ void test_datastream::test_basic()
2855
testtype<unsigned short>::run(12345, "uint16");
2956
testtype<int>::run(-1234567890, "int32");
3057
testtype<unsigned int>::run(3234567890u, "uint32");
31-
testtype<long long>::run(0x8000000000000000ull, "int64");
58+
testtype<long long>::run((long long)0x8000000000000000ll, "int64");
3259
testtype<unsigned long long>::run(0x7fffffffffffffffull, "uint64");
3360
testtype<float>::run(1.234f, "float");
3461
testtype<double>::run(0.333333333333333333, "double");
@@ -39,15 +66,15 @@ void test_datastream::test_basic()
3966
struct Pair {
4067
int a;
4168
double d;
42-
bool operator==(const Pair &p) const { return a == p.a && d == p.d;}
69+
bool operator==(const Pair &p) const { return a == p.a && std::abs(d - p.d) < 1e-20;}
4370
};
4471
testtype<Pair>::run({1, 1.23456}, "struct");
4572

4673
struct StaticArray {
4774
int a[2];
4875
bool operator==(const StaticArray &o) const { return a[0] == o.a[0] && a[1] == o.a[1]; }
4976
};
50-
testtype<StaticArray>::run({10,20}, "staticArray");
77+
testtype<StaticArray>::run({10,20}, "StaticArray");
5178

5279
testtype<std::string>::run("hello", "string");
5380

contracts/test_api/test_permission.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ struct test_permission_last_used_msg {
5858
EOSLIB_SERIALIZE( test_permission_last_used_msg, (account)(permission)(last_used_time) )
5959
};
6060

61-
void test_permission::test_permission_last_used(uint64_t receiver, uint64_t code, uint64_t action) {
61+
void test_permission::test_permission_last_used(uint64_t /* receiver */, uint64_t code, uint64_t action) {
6262
(void)code;
6363
(void)action;
6464
using namespace eosio;
@@ -68,7 +68,7 @@ void test_permission::test_permission_last_used(uint64_t receiver, uint64_t code
6868
eosio_assert( get_permission_last_used(params.account, params.permission) == params.last_used_time, "unexpected last used permission time" );
6969
}
7070

71-
void test_permission::test_account_creation_time(uint64_t receiver, uint64_t code, uint64_t action) {
71+
void test_permission::test_account_creation_time(uint64_t /* receiver */, uint64_t code, uint64_t action) {
7272
(void)code;
7373
(void)action;
7474
using namespace eosio;

contracts/test_api/test_transaction.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ void test_transaction::send_deferred_tx_with_dtt_action() {
274274
void test_transaction::cancel_deferred_transaction_success() {
275275
using namespace eosio;
276276
auto r = cancel_deferred( 0xffffffffffffffff ); //use the same id (0) as in send_deferred_transaction
277-
eosio_assert( r, "transaction was not found" );
277+
eosio_assert( (bool)r, "transaction was not found" );
278278
}
279279

280280
void test_transaction::cancel_deferred_transaction_not_found() {
@@ -310,9 +310,9 @@ void test_transaction::context_free_api() {
310310

311311
extern "C" { int is_feature_active(int64_t); }
312312
void test_transaction::new_feature() {
313-
eosio_assert(false == is_feature_active(N(newfeature)), "we should not have new features unless hardfork");
313+
eosio_assert(false == is_feature_active((int64_t)N(newfeature)), "we should not have new features unless hardfork");
314314
}
315315

316316
void test_transaction::active_new_feature() {
317-
activate_feature(N(newfeature));
317+
activate_feature((int64_t)N(newfeature));
318318
}

contracts/test_api_db/test_db.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ void test_db::primary_i64_general(uint64_t receiver, uint64_t code, uint64_t act
159159

160160
buffer_len = 20;
161161
len = db_get_i64(itr, value, 0);
162-
len = db_get_i64(itr, value, len);
162+
len = db_get_i64(itr, value, (uint32_t)len);
163163
value[len] = '\0';
164164
std::string sfull(value);
165165
eosio_assert(sfull == "bob's info", "primary_i64_general - db_get_i64 - full");
@@ -448,7 +448,7 @@ void test_db::test_invalid_access(uint64_t receiver, uint64_t code, uint64_t act
448448
uint64_t pk = scope;
449449

450450
int32_t itr = -1;
451-
uint64_t value;
451+
uint64_t value = 0;
452452
switch( ia.index ) {
453453
case 1:
454454
itr = db_idx64_find_primary(ia.code, scope, table, &value, pk);
@@ -536,7 +536,7 @@ void test_db::idx_double_nan_lookup_fail(uint64_t receiver, uint64_t, uint64_t)
536536
}
537537
}
538538

539-
void test_db::misaligned_secondary_key256_tests(uint64_t receiver, uint64_t, uint64_t) {
539+
void test_db::misaligned_secondary_key256_tests(uint64_t /* receiver */, uint64_t, uint64_t) {
540540
auto key = eosio::key256::make_from_word_sequence<uint64_t>(0ULL, 0ULL, 0ULL, 42ULL);
541541
char* ptr = (char*)(&key);
542542
ptr += 1;

contracts/test_api_mem/test_extended_memory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ void test_extended_memory::test_page_memory_exceeded() {
9090
}
9191

9292
void test_extended_memory::test_page_memory_negative_bytes() {
93-
eosio_assert(reinterpret_cast<int32_t>(sbrk(-1)) == -1, "Should have errored for trying to remove memory");
93+
eosio_assert(reinterpret_cast<int32_t>(sbrk((uint32_t)-1)) == -1, "Should have errored for trying to remove memory");
9494
}
9595

9696
void test_extended_memory::test_initial_buffer() {

libraries/chain/eosio_contract.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ void apply_eosio_setcode(apply_context& context) {
146146

147147
db.modify( account, [&]( auto& a ) {
148148
/** TODO: consider whether a microsecond level local timestamp is sufficient to detect code version changes*/
149-
#warning TODO: update setcode message to include the hash, then validate it in validate
149+
// TODO: update setcode message to include the hash, then validate it in validate
150150
a.last_code_update = context.control.pending_block_time();
151151
a.code_version = code_id;
152152
a.code.resize( code_size );

plugins/chain_plugin/chain_plugin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ void chain_plugin::set_program_options(options_description& cli, options_descrip
140140
"Contract account added to contract blacklist (may specify multiple times)")
141141
;
142142

143-
#warning TODO: rate limiting
143+
// TODO: rate limiting
144144
/*("per-authorized-account-transaction-msg-rate-limit-time-frame-sec", bpo::value<uint32_t>()->default_value(default_per_auth_account_time_frame_seconds),
145145
"The time frame, in seconds, that the per-authorized-account-transaction-msg-rate-limit is imposed over.")
146146
("per-authorized-account-transaction-msg-rate-limit", bpo::value<uint32_t>()->default_value(default_per_auth_account),

unittests/bootseq_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ BOOST_FIXTURE_TEST_CASE( bootseq_test, bootseq_tester ) {
332332
votepro( N(minow1), {N(p1), N(p2)} );
333333

334334

335-
#warning Complete this test
335+
// TODO: Complete this test
336336
} FC_LOG_AND_RETHROW()
337337
}
338338

unittests/resource_limits_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ BOOST_AUTO_TEST_SUITE(resource_limits_test)
140140
*/
141141

142142

143-
#warning restore weighted capacity cpu tests
143+
// TODO: restore weighted capacity cpu tests
144144
#if 0
145145
BOOST_FIXTURE_TEST_CASE(weighted_capacity_cpu, resource_limits_fixture) try {
146146
const vector<int64_t> weights = { 234, 511, 672, 800, 1213 };

unittests/wasm_tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ BOOST_FIXTURE_TEST_CASE(cpu_usage_tests, tester ) try {
589589

590590
// test weighted cpu limit
591591
BOOST_FIXTURE_TEST_CASE(weighted_cpu_limit_tests, tester ) try {
592-
#warning This test does not appear to be very robust.
592+
// TODO This test does not appear to be very robust.
593593
resource_limits_manager mgr = control->get_mutable_resource_limits_manager();
594594
create_accounts( {N(f_tests)} );
595595
create_accounts( {N(acc2)} );
@@ -1713,7 +1713,7 @@ BOOST_FIXTURE_TEST_CASE( fuzz, TESTER ) try {
17131713
} FC_LOG_AND_RETHROW()
17141714

17151715

1716-
#warning restore net_usage_tests
1716+
// TODO: restore net_usage_tests
17171717
#if 0
17181718
BOOST_FIXTURE_TEST_CASE(net_usage_tests, tester ) try {
17191719
int count = 0;

0 commit comments

Comments
 (0)