Merge pull request #17 from peerplays-network/fc/cleaner-build-log

Remove as much warnings from build log as possible
This commit is contained in:
serkixenos 2021-01-27 13:33:51 +01:00 committed by GitHub
commit 4888839219
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 89 additions and 47 deletions

View file

@ -115,7 +115,9 @@ namespace fc {
memcpy(&bi, ve.data(), fc::min<size_t>(ve.size(),sizeof(bi)) ); memcpy(&bi, ve.data(), fc::min<size_t>(ve.size(),sizeof(bi)) );
} }
else else
memset( &bi, char(0), sizeof(bi) ); for (size_t i = 0; i < bi.size(); i++) {
bi.data[i] = 0;
}
} }

View file

@ -4,5 +4,5 @@ namespace fc {
/* provides access to the OpenSSL random number generator */ /* provides access to the OpenSSL random number generator */
void rand_bytes(char* buf, int count); void rand_bytes(char* buf, int count);
void rand_pseudo_bytes(char* buf, int count); //void rand_pseudo_bytes(char* buf, int count);
} // namespace fc } // namespace fc

View file

@ -1,6 +1,7 @@
#pragma once #pragma once
#include <fc/utility.hpp> #include <fc/utility.hpp>
#include <assert.h> #include <assert.h>
#include <string.h>
namespace fc { namespace fc {
@ -23,12 +24,13 @@ namespace fc {
public: public:
typedef T value_type; typedef T value_type;
optional():_valid(false){} optional():_valid(false){ memset(_value, 0, sizeof(_value)); }
~optional(){ reset(); } ~optional(){ reset(); }
optional( optional& o ) optional( optional& o )
:_valid(false) :_valid(false)
{ {
memset(_value, 0, sizeof(_value));
if( o._valid ) new (ptr()) T( *o ); if( o._valid ) new (ptr()) T( *o );
_valid = o._valid; _valid = o._valid;
} }
@ -36,6 +38,7 @@ namespace fc {
optional( const optional& o ) optional( const optional& o )
:_valid(false) :_valid(false)
{ {
memset(_value, 0, sizeof(_value));
if( o._valid ) new (ptr()) T( *o ); if( o._valid ) new (ptr()) T( *o );
_valid = o._valid; _valid = o._valid;
} }
@ -43,6 +46,7 @@ namespace fc {
optional( optional&& o ) optional( optional&& o )
:_valid(false) :_valid(false)
{ {
memset(_value, 0, sizeof(_value));
if( o._valid ) new (ptr()) T( fc::move(*o) ); if( o._valid ) new (ptr()) T( fc::move(*o) );
_valid = o._valid; _valid = o._valid;
o.reset(); o.reset();
@ -52,6 +56,7 @@ namespace fc {
optional( const optional<U>& o ) optional( const optional<U>& o )
:_valid(false) :_valid(false)
{ {
memset(_value, 0, sizeof(_value));
if( o._valid ) new (ptr()) T( *o ); if( o._valid ) new (ptr()) T( *o );
_valid = o._valid; _valid = o._valid;
} }
@ -60,6 +65,7 @@ namespace fc {
optional( optional<U>& o ) optional( optional<U>& o )
:_valid(false) :_valid(false)
{ {
memset(_value, 0, sizeof(_value));
if( o._valid ) if( o._valid )
{ {
new (ptr()) T( *o ); new (ptr()) T( *o );
@ -71,6 +77,7 @@ namespace fc {
optional( optional<U>&& o ) optional( optional<U>&& o )
:_valid(false) :_valid(false)
{ {
memset(_value, 0, sizeof(_value));
if( o._valid ) new (ptr()) T( fc::move(*o) ); if( o._valid ) new (ptr()) T( fc::move(*o) );
_valid = o._valid; _valid = o._valid;
o.reset(); o.reset();
@ -80,6 +87,7 @@ namespace fc {
optional( U&& u ) optional( U&& u )
:_valid(true) :_valid(true)
{ {
memset(_value, 0, sizeof(_value));
new ((char*)ptr()) T( fc::forward<U>(u) ); new ((char*)ptr()) T( fc::forward<U>(u) );
} }

View file

@ -1497,7 +1497,10 @@ tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_nex
{ {
mz_uint8 *p = r->m_tables[0].m_code_size; mz_uint i; mz_uint8 *p = r->m_tables[0].m_code_size; mz_uint i;
r->m_table_sizes[0] = 288; r->m_table_sizes[1] = 32; TINFL_MEMSET(r->m_tables[1].m_code_size, 5, 32); r->m_table_sizes[0] = 288; r->m_table_sizes[1] = 32; TINFL_MEMSET(r->m_tables[1].m_code_size, 5, 32);
for ( i = 0; i <= 143; ++i) *p++ = 8; for ( ; i <= 255; ++i) *p++ = 9; for ( ; i <= 279; ++i) *p++ = 7; for ( ; i <= 287; ++i) *p++ = 8; for ( i = 0; i <= 143; ++i) *p++ = 8;
for ( ; i <= 255; ++i) *p++ = 9;
for ( ; i <= 279; ++i) *p++ = 7;
for ( ; i <= 287; ++i) *p++ = 8;
} }
else else
{ {
@ -2281,7 +2284,11 @@ static MZ_FORCEINLINE void tdefl_find_match(tdefl_compressor *d, mz_uint lookahe
if (TDEFL_READ_UNALIGNED_WORD(&d->m_dict[probe_pos + match_len - 1]) == c01) break; if (TDEFL_READ_UNALIGNED_WORD(&d->m_dict[probe_pos + match_len - 1]) == c01) break;
TDEFL_PROBE; TDEFL_PROBE; TDEFL_PROBE; TDEFL_PROBE; TDEFL_PROBE; TDEFL_PROBE;
} }
if (!dist) break; q = (const mz_uint16*)(d->m_dict + probe_pos); if (TDEFL_READ_UNALIGNED_WORD(q) != s01) continue; p = s; probe_len = 32; if (!dist) break;
q = (const mz_uint16*)(d->m_dict + probe_pos);
if (TDEFL_READ_UNALIGNED_WORD(q) != s01) continue;
p = s;
probe_len = 32;
do { } while ( (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && do { } while ( (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) &&
(TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (--probe_len > 0) ); (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (--probe_len > 0) );
if (!probe_len) if (!probe_len)
@ -2848,7 +2855,7 @@ void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h,
#include <stdio.h> #include <stdio.h>
#include <sys/stat.h> #include <sys/stat.h>
#if defined(_MSC_VER) #if defined(_MSC_VER)
static FILE *mz_fopen(const char *pFilename, const char *pMode) static FILE *mz_fopen(const char *pFilename, const char *pMode)
{ {
FILE* pFile = NULL; FILE* pFile = NULL;

View file

@ -30,6 +30,7 @@ struct aes_encoder::impl
aes_encoder::aes_encoder() aes_encoder::aes_encoder()
{ {
static int init = init_openssl(); static int init = init_openssl();
(void)init;
} }
aes_encoder::~aes_encoder() aes_encoder::~aes_encoder()
@ -70,7 +71,9 @@ uint32_t aes_encoder::encode( const char* plaintxt, uint32_t plaintext_len, char
FC_THROW_EXCEPTION( aes_exception, "error during aes 256 cbc encryption update", FC_THROW_EXCEPTION( aes_exception, "error during aes 256 cbc encryption update",
("s", ERR_error_string( ERR_get_error(), nullptr) ) ); ("s", ERR_error_string( ERR_get_error(), nullptr) ) );
} }
FC_ASSERT( ciphertext_len == plaintext_len, "", ("ciphertext_len",ciphertext_len)("plaintext_len",plaintext_len) ); int64_t ciphertext_len_i64 = ciphertext_len;
int64_t plaintext_len_i64 = plaintext_len;
FC_ASSERT( ciphertext_len_i64 == plaintext_len_i64, "", ("ciphertext_len",ciphertext_len)("plaintext_len",plaintext_len) );
return ciphertext_len; return ciphertext_len;
} }
#if 0 #if 0
@ -98,6 +101,7 @@ struct aes_decoder::impl
aes_decoder::aes_decoder() aes_decoder::aes_decoder()
{ {
static int init = init_openssl(); static int init = init_openssl();
(void)init;
} }
void aes_decoder::init( const fc::sha256& key, const fc::uint128& init_value ) void aes_decoder::init( const fc::sha256& key, const fc::uint128& init_value )
@ -137,7 +141,9 @@ uint32_t aes_decoder::decode( const char* ciphertxt, uint32_t ciphertxt_len, cha
FC_THROW_EXCEPTION( aes_exception, "error during aes 256 cbc decryption update", FC_THROW_EXCEPTION( aes_exception, "error during aes 256 cbc decryption update",
("s", ERR_error_string( ERR_get_error(), nullptr) ) ); ("s", ERR_error_string( ERR_get_error(), nullptr) ) );
} }
FC_ASSERT( ciphertxt_len == plaintext_len, "", ("ciphertxt_len",ciphertxt_len)("plaintext_len",plaintext_len) ); int64_t ciphertxt_len_i64 = ciphertxt_len;
int64_t plaintext_len_i64 = plaintext_len;
FC_ASSERT( ciphertxt_len_i64 == plaintext_len_i64, "", ("ciphertxt_len",ciphertxt_len)("plaintext_len",plaintext_len) );
return plaintext_len; return plaintext_len;
} }
#if 0 #if 0

View file

@ -85,8 +85,10 @@ namespace fc { namespace ecc {
ssl_bignum order; ssl_bignum order;
FC_ASSERT( EC_GROUP_get_order( group, order, ctx ) ); FC_ASSERT( EC_GROUP_get_order( group, order, ctx ) );
private_key_secret bin; private_key_secret bin;
FC_ASSERT( BN_num_bytes( order ) == bin.data_size() ); size_t order_BN_num_bytes = BN_num_bytes( order );
FC_ASSERT( BN_bn2bin( order, (unsigned char*) bin.data() ) == bin.data_size() ); FC_ASSERT( order_BN_num_bytes == bin.data_size() );
size_t order_BN_bn2bin = BN_bn2bin( order, (unsigned char*) bin.data() );
FC_ASSERT( order_BN_bn2bin == bin.data_size() );
return bin; return bin;
} }
@ -104,8 +106,10 @@ namespace fc { namespace ecc {
FC_ASSERT( EC_GROUP_get_order( group, order, ctx ) ); FC_ASSERT( EC_GROUP_get_order( group, order, ctx ) );
BN_rshift1( order, order ); BN_rshift1( order, order );
private_key_secret bin; private_key_secret bin;
FC_ASSERT( BN_num_bytes( order ) == bin.data_size() ); size_t order_BN_num_bytes = BN_num_bytes( order );
FC_ASSERT( BN_bn2bin( order, (unsigned char*) bin.data() ) == bin.data_size() ); FC_ASSERT( order_BN_num_bytes == bin.data_size() );
size_t order_BN_bn2bin = BN_bn2bin( order, (unsigned char*) bin.data() );
FC_ASSERT( order_BN_bn2bin == bin.data_size() );
return bin; return bin;
} }

View file

@ -32,6 +32,7 @@ namespace fc { namespace ecc {
static const secp256k1_context_t* ctx = _get_context(); static const secp256k1_context_t* ctx = _get_context();
static int init_o = init_openssl(); static int init_o = init_openssl();
(void)ctx; (void)ctx;
(void)init_o;
} }
class public_key_impl class public_key_impl

View file

@ -91,6 +91,8 @@ namespace fc {
if( ve.size() ) if( ve.size() )
memcpy(&bi, ve.data(), fc::min<size_t>(ve.size(),sizeof(bi)) ); memcpy(&bi, ve.data(), fc::min<size_t>(ve.size(),sizeof(bi)) );
else else
memset( &bi, char(0), sizeof(bi) ); for (size_t i = 0; i < bi.data_size(); i++) {
bi.data()[i] = 0;
}
} }
} }

View file

@ -9,19 +9,21 @@ namespace fc {
void rand_bytes(char* buf, int count) void rand_bytes(char* buf, int count)
{ {
static int init = init_openssl(); static int init = init_openssl();
(void)init;
int result = RAND_bytes((unsigned char*)buf, count); int result = RAND_bytes((unsigned char*)buf, count);
if (result != 1) if (result != 1)
FC_THROW("Error calling OpenSSL's RAND_bytes(): ${code}", ("code", (uint32_t)ERR_get_error())); FC_THROW("Error calling OpenSSL's RAND_bytes(): ${code}", ("code", (uint32_t)ERR_get_error()));
} }
void rand_pseudo_bytes(char* buf, int count) //void rand_pseudo_bytes(char* buf, int count)
{ //{
static int init = init_openssl(); // static int init = init_openssl();
// (void)init;
int result = RAND_pseudo_bytes((unsigned char*)buf, count); //
if (result == -1) // int result = RAND_pseudo_bytes((unsigned char*)buf, count);
FC_THROW("Error calling OpenSSL's RAND_pseudo_bytes(): ${code}", ("code", (uint32_t)ERR_get_error())); // if (result == -1)
} // FC_THROW("Error calling OpenSSL's RAND_pseudo_bytes(): ${code}", ("code", (uint32_t)ERR_get_error()));
//}
} // namespace fc } // namespace fc

View file

@ -106,7 +106,9 @@ bool operator == ( const ripemd160& h1, const ripemd160& h2 ) {
void from_variant( const variant& v, ripemd160& bi, uint32_t max_depth ) void from_variant( const variant& v, ripemd160& bi, uint32_t max_depth )
{ {
std::vector<char> ve = v.as< std::vector<char> >( max_depth ); std::vector<char> ve = v.as< std::vector<char> >( max_depth );
memset( &bi, char(0), sizeof(bi) ); for (size_t i = 0; i < bi.data_size(); i++) {
bi.data()[i] = 0;
}
if( ve.size() ) if( ve.size() )
memcpy( &bi, ve.data(), fc::min<size_t>(ve.size(),sizeof(bi)) ); memcpy( &bi, ve.data(), fc::min<size_t>(ve.size(),sizeof(bi)) );
} }

View file

@ -90,7 +90,9 @@ bool operator == ( const sha1& h1, const sha1& h2 ) {
void from_variant( const variant& v, sha1& bi, uint32_t max_depth ) void from_variant( const variant& v, sha1& bi, uint32_t max_depth )
{ {
std::vector<char> ve = v.as< std::vector<char> >( max_depth ); std::vector<char> ve = v.as< std::vector<char> >( max_depth );
memset( &bi, char(0), sizeof(bi) ); for (size_t i = 0; i < bi.data_size(); i++) {
bi.data()[i] = 0;
}
if( ve.size() ) if( ve.size() )
memcpy( &bi, ve.data(), fc::min<size_t>(ve.size(),sizeof(bi)) ); memcpy( &bi, ve.data(), fc::min<size_t>(ve.size(),sizeof(bi)) );
} }

View file

@ -86,7 +86,9 @@ namespace fc {
void from_variant( const variant& v, sha224& bi, uint32_t max_depth ) void from_variant( const variant& v, sha224& bi, uint32_t max_depth )
{ {
std::vector<char> ve = v.as< std::vector<char> >( max_depth ); std::vector<char> ve = v.as< std::vector<char> >( max_depth );
memset( &bi, char(0), sizeof(bi) ); for (size_t i = 0; i < bi.data_size(); i++) {
bi.data()[i] = 0;
}
if( ve.size() ) if( ve.size() )
memcpy( &bi, ve.data(), fc::min<size_t>(ve.size(),sizeof(bi)) ); memcpy( &bi, ve.data(), fc::min<size_t>(ve.size(),sizeof(bi)) );
} }

View file

@ -200,7 +200,9 @@ namespace fc {
void from_variant( const variant& v, sha256& bi, uint32_t max_depth ) void from_variant( const variant& v, sha256& bi, uint32_t max_depth )
{ {
std::vector<char> ve = v.as< std::vector<char> >( max_depth ); std::vector<char> ve = v.as< std::vector<char> >( max_depth );
memset( &bi, char(0), sizeof(bi) ); for (size_t i = 0; i < bi.data_size(); i++) {
bi.data()[i] = 0;
}
if( ve.size() ) if( ve.size() )
memcpy( &bi, ve.data(), fc::min<size_t>(ve.size(),sizeof(bi)) ); memcpy( &bi, ve.data(), fc::min<size_t>(ve.size(),sizeof(bi)) );
} }

View file

@ -92,7 +92,9 @@ namespace fc {
void from_variant( const variant& v, sha512& bi, uint32_t max_depth ) void from_variant( const variant& v, sha512& bi, uint32_t max_depth )
{ {
std::vector<char> ve = v.as< std::vector<char> >( max_depth ); std::vector<char> ve = v.as< std::vector<char> >( max_depth );
memset( &bi, char(0), sizeof(bi) ); for (size_t i = 0; i < bi.data_size(); i++) {
bi.data()[i] = 0;
}
if( ve.size() ) if( ve.size() )
memcpy( &bi, ve.data(), fc::min<size_t>(ve.size(),sizeof(bi)) ); memcpy( &bi, ve.data(), fc::min<size_t>(ve.size(),sizeof(bi)) );
} }

View file

@ -182,7 +182,7 @@ namespace fc
} }
} }
} // try } // try
catch (fc::canceled_exception) catch (fc::canceled_exception&)
{ {
throw; throw;
} }

View file

@ -13,18 +13,18 @@ namespace fc {
{} {}
mutex::~mutex() { mutex::~mutex() {
if( m_blist ) // if( m_blist )
{ // {
context* c = m_blist; // context* c = m_blist;
fc::thread::current().debug("~mutex"); // fc::thread::current().debug("~mutex");
#if 0 //#if 0
while( c ) { // while( c ) {
// elog( "still blocking on context %p (%s)", m_blist, (m_blist->cur_task ? m_blist->cur_task->get_desc() : "no current task") ); // // elog( "still blocking on context %p (%s)", m_blist, (m_blist->cur_task ? m_blist->cur_task->get_desc() : "no current task") );
c = c->next_blocked_mutex; // c = c->next_blocked_mutex;
} // }
#endif //#endif
BOOST_ASSERT( false && "Attempt to free mutex while others are blocking on lock." ); // BOOST_ASSERT( false && "Attempt to free mutex while others are blocking on lock." );
} // }
} }
/** /**

View file

@ -13,7 +13,7 @@ namespace fc {
bool is_utf8( const std::string& str ) bool is_utf8( const std::string& str )
{ {
auto itr = utf8::find_invalid(str.begin(), str.end()); //auto itr = utf8::find_invalid(str.begin(), str.end());
return utf8::is_valid( str.begin(), str.end() ); return utf8::is_valid( str.begin(), str.end() );
} }

View file

@ -86,7 +86,7 @@ static void test_58( const std::string& test, const std::string& expected )
try { try {
len = fc::from_base58( enc1, buffer, 10 ); len = fc::from_base58( enc1, buffer, 10 );
BOOST_CHECK( len <= 10 ); BOOST_CHECK( len <= 10 );
} catch ( fc::exception expected ) {} } catch ( fc::exception& expected ) {}
} }
} }

View file

@ -33,11 +33,11 @@ BOOST_AUTO_TEST_CASE(rand_test)
check_randomness( buffer, sizeof(buffer) ); check_randomness( buffer, sizeof(buffer) );
} }
BOOST_AUTO_TEST_CASE(pseudo_rand_test) //BOOST_AUTO_TEST_CASE(pseudo_rand_test)
{ //{
char buffer[10013]; // char buffer[10013];
fc::rand_pseudo_bytes( buffer, sizeof(buffer) ); // fc::rand_pseudo_bytes( buffer, sizeof(buffer) );
check_randomness( buffer, sizeof(buffer) ); // check_randomness( buffer, sizeof(buffer) );
} //}
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()