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)) );
}
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 */
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

View file

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

View file

@ -30,6 +30,7 @@ struct aes_encoder::impl
aes_encoder::aes_encoder()
{
static int init = init_openssl();
(void)init;
}
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",
("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;
}
#if 0
@ -98,6 +101,7 @@ struct aes_decoder::impl
aes_decoder::aes_decoder()
{
static int init = init_openssl();
(void)init;
}
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",
("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;
}
#if 0

View file

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

View file

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

View file

@ -91,6 +91,8 @@ namespace fc {
if( ve.size() )
memcpy(&bi, ve.data(), fc::min<size_t>(ve.size(),sizeof(bi)) );
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)
{
static int init = init_openssl();
(void)init;
int result = RAND_bytes((unsigned char*)buf, count);
if (result != 1)
FC_THROW("Error calling OpenSSL's RAND_bytes(): ${code}", ("code", (uint32_t)ERR_get_error()));
}
void rand_pseudo_bytes(char* buf, int count)
{
static int init = init_openssl();
int result = RAND_pseudo_bytes((unsigned char*)buf, count);
if (result == -1)
FC_THROW("Error calling OpenSSL's RAND_pseudo_bytes(): ${code}", ("code", (uint32_t)ERR_get_error()));
}
//void rand_pseudo_bytes(char* buf, int count)
//{
// static int init = init_openssl();
// (void)init;
//
// int result = RAND_pseudo_bytes((unsigned char*)buf, count);
// if (result == -1)
// FC_THROW("Error calling OpenSSL's RAND_pseudo_bytes(): ${code}", ("code", (uint32_t)ERR_get_error()));
//}
} // 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 )
{
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() )
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 )
{
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() )
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 )
{
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() )
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 )
{
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() )
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 )
{
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() )
memcpy( &bi, ve.data(), fc::min<size_t>(ve.size(),sizeof(bi)) );
}

View file

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

View file

@ -13,18 +13,18 @@ namespace fc {
{}
mutex::~mutex() {
if( m_blist )
{
context* c = m_blist;
fc::thread::current().debug("~mutex");
#if 0
while( c ) {
// 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;
}
#endif
BOOST_ASSERT( false && "Attempt to free mutex while others are blocking on lock." );
}
// if( m_blist )
// {
// context* c = m_blist;
// fc::thread::current().debug("~mutex");
//#if 0
// while( c ) {
// // 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;
// }
//#endif
// 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 )
{
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() );
}

View file

@ -86,7 +86,7 @@ static void test_58( const std::string& test, const std::string& expected )
try {
len = fc::from_base58( enc1, buffer, 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) );
}
BOOST_AUTO_TEST_CASE(pseudo_rand_test)
{
char buffer[10013];
fc::rand_pseudo_bytes( buffer, sizeof(buffer) );
check_randomness( buffer, sizeof(buffer) );
}
//BOOST_AUTO_TEST_CASE(pseudo_rand_test)
//{
// char buffer[10013];
// fc::rand_pseudo_bytes( buffer, sizeof(buffer) );
// check_randomness( buffer, sizeof(buffer) );
//}
BOOST_AUTO_TEST_SUITE_END()