Skip to content
Permalink
Browse files

Fixing GCC+Clang compile warnings

  • Loading branch information...
zpalmtree committed Jul 30, 2019
1 parent 53db350 commit 1cf596f45135203a38b5612eae175955b66538e9
@@ -3,6 +3,12 @@ set(UPNPC_BUILD_SHARED OFF CACHE BOOL "Build shared library")
set(UPNPC_BUILD_TESTS OFF CACHE BOOL "Build test executables")
set(WITH_MD_LIBRARY OFF CACHE BOOL "Code Generation for static library")

# Disable warnings
if (NOT MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w -Wno-everything")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w -Wno-everything")
endif()

add_subdirectory(miniupnpc)
add_subdirectory(cryptopp)
add_subdirectory(sqlite3)
@@ -182,8 +182,6 @@ if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zi /nologo /EHsc /GS /Gd /GR /GF /fp:precise /Zc:wchar_t /Zc:forScope /errorReport:queue")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /FC /d2Zi+ /W4 /wd4127 /wd4800 /wd4996 /wd4351 /wd4100 /wd4204 /wd4324")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W -Wextra -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsign-compare -Wshadow -Wno-unused-parameter -Wno-unused-variable -Woverloaded-virtual -Wnon-virtual-dtor -Wno-missing-field-initializers -Wno-strict-aliasing")
if(MINGW)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-format")
endif()
@@ -100,7 +100,7 @@ class BlockCacheTier : public PersistentCacheTier {

std::string key_;
std::string data_;
const bool signal_ = false; // signal to request processing thread to exit
bool signal_ = false; // signal to request processing thread to exit
};

// entry point for insert thread
@@ -266,7 +266,7 @@ class ThreadedWriter : public Writer {
size_t Size() const { return sizeof(IO); }

WritableFile* file_ = nullptr; // File to write to
CacheWriteBuffer* const buf_ = nullptr; // buffer to write
CacheWriteBuffer* buf_ = nullptr; // buffer to write
uint64_t file_off_ = 0; // file offset
bool signal_ = false; // signal to exit thread loop
std::function<void()> callback_; // Callback on completion
@@ -250,7 +250,6 @@ namespace CryptoNote
need to change it manually. */
const uint8_t CURRENT_FORK_INDEX = FORK_HEIGHTS_SIZE == 0 ? 0 : SOFTWARE_SUPPORTED_FORK_INDEX;

static_assert(CURRENT_FORK_INDEX >= 0, "CURRENT FORK INDEX must be >= 0");
/* Make sure CURRENT_FORK_INDEX is a valid index, unless FORK_HEIGHTS is empty */
static_assert(
FORK_HEIGHTS_SIZE == 0 || CURRENT_FORK_INDEX < FORK_HEIGHTS_SIZE,

This file was deleted.

This file was deleted.

@@ -333,7 +333,8 @@ namespace CryptoNote
children = {newCache.get()};

logger(Logging::DEBUGGING) << "Split successfully completed";
return std::move(newCache);

return newCache;
}

void BlockchainCache::splitSpentKeyImages(BlockchainCache &newCache, uint32_t splitBlockIndex)
@@ -72,11 +72,18 @@ namespace CryptoNote
try
{
index = std::stoull(indexString);

/* Failed to parse hash, or checkpoint already exists */
if (!addCheckpoint(index, hash))
{
return false;
}
}
catch (const std::out_of_range &)
{
logger(ERROR, BRIGHT_RED) << "Invalid checkpoint file format - "
<< "height is out of range of uint64_t";
return false;
}
catch (const std::invalid_argument &)
{
@@ -85,12 +92,6 @@ namespace CryptoNote

return false;
}

/* Failed to parse hash, or checkpoint already exists */
if (!addCheckpoint(index, hash))
{
return false;
}
}

logger(INFO) << "Loaded " << points.size() << " checkpoints from " << filename;
@@ -5,7 +5,6 @@

#include "CryptoNoteFormatUtils.h"

#include "Account.h"
#include "CryptoNoteBasicImpl.h"
#include "common/CryptoNoteTools.h"
#include "serialization/BinaryInputStreamSerializer.h"
@@ -8,8 +8,6 @@
#include "Currency.h"
/////////////////////

#include <boost/algorithm/string/trim.hpp>
#include <boost/lexical_cast.hpp>
#include <cctype>
#include <common/Base58.h>
#include <common/CheckDifficulty.h>
@@ -18,12 +16,12 @@
#include <common/TransactionExtra.h>
#include <common/int-util.h>
#include <config/Constants.h>
#include <cryptonotecore/Account.h>
#include <cryptonotecore/CryptoNoteBasicImpl.h>
#include <cryptonotecore/CryptoNoteFormatUtils.h>
#include <cryptonotecore/Difficulty.h>
#include <cryptonotecore/UpgradeDetector.h>
#include <utilities/Addresses.h>
#include <utilities/String.h>

#undef ERROR

@@ -55,7 +53,7 @@ namespace CryptoNote

bool Currency::generateGenesisBlock()
{
genesisBlockTemplate = boost::value_initialized<BlockTemplate>();
genesisBlockTemplate = BlockTemplate{};

std::string genesisCoinbaseTxHex = CryptoNote::parameters::GENESIS_COINBASE_TX_HEX;
BinaryArray minerTxBlob;
@@ -289,8 +287,8 @@ namespace CryptoNote
uint64_t summaryAmounts = 0;
for (size_t no = 0; no < outAmounts.size(); no++)
{
Crypto::KeyDerivation derivation = boost::value_initialized<Crypto::KeyDerivation>();
Crypto::PublicKey outEphemeralPubKey = boost::value_initialized<Crypto::PublicKey>();
Crypto::KeyDerivation derivation;
Crypto::PublicKey outEphemeralPubKey;

bool r = Crypto::generate_key_derivation(minerAddress.viewPublicKey, txkey.secretKey, derivation);

@@ -425,11 +423,6 @@ namespace CryptoNote
return true;
}

std::string Currency::accountAddressAsString(const AccountBase &account) const
{
return Utilities::getAccountAddressAsStr(m_publicAddressBase58Prefix, account.getAccountKeys().address);
}

std::string Currency::accountAddressAsString(const AccountPublicAddress &accountPublicAddress) const
{
return Utilities::getAccountAddressAsStr(m_publicAddressBase58Prefix, accountPublicAddress);
@@ -478,7 +471,7 @@ namespace CryptoNote
bool Currency::parseAmount(const std::string &str, uint64_t &amount) const
{
std::string strAmount = str;
boost::algorithm::trim(strAmount);
Utilities::trim(strAmount);

size_t pointIndex = strAmount.find_first_of('.');
size_t fractionSize;
@@ -886,7 +879,7 @@ namespace CryptoNote
Transaction CurrencyBuilder::generateGenesisTransaction()
{
CryptoNote::Transaction tx;
CryptoNote::AccountPublicAddress ac = boost::value_initialized<CryptoNote::AccountPublicAddress>();
CryptoNote::AccountPublicAddress ac;
m_currency.constructMinerTx(1, 0, 0, 0, 0, 0, ac, tx); // zero fee in genesis
return tx;
}
@@ -19,8 +19,6 @@

namespace CryptoNote
{
class AccountBase;

class Currency
{
public:
@@ -350,8 +348,6 @@ namespace CryptoNote
uint8_t &amountPowerOfTen,
uint32_t height) const;

std::string accountAddressAsString(const AccountBase &account) const;

std::string accountAddressAsString(const AccountPublicAddress &accountPublicAddress) const;

bool parseAccountAddressString(const std::string &str, AccountPublicAddress &addr) const;
@@ -15,7 +15,7 @@ uint64_t nextDifficultyV3(std::vector<uint64_t> timestamps, std::vector<uint64_t

uint64_t adjustForDifficultyReset(const uint64_t nextDifficulty, const uint64_t blockIndex);

static float calculateDifficultyResetMultiplier(
float calculateDifficultyResetMultiplier(
const uint64_t blockIndex,
const uint64_t resetHeight,
const uint64_t resetWindow,
@@ -45,5 +45,6 @@ std::unique_ptr<BlockchainStorage::IBlockchainStorageInternal>
std::move(blocks.begin() + splitIndex, blocks.end(), std::back_inserter(newStorage->blocks));
blocks.resize(splitIndex);
blocks.shrink_to_fit();
return std::move(newStorage);

return newStorage;
}
@@ -67,7 +67,7 @@ namespace CryptoNote
blocks.pop_back();
}

return std::move(newStorage);
return newStorage;
}

} // namespace CryptoNote
@@ -3,7 +3,6 @@
//
// Please see the included LICENSE file for more information.

#include "Account.h"
#include "ITransaction.h"
#include "TransactionApiExtra.h"
#include "TransactionUtils.h"
@@ -8,7 +8,6 @@
#include "CryptoNoteFormatUtils.h"
#include "common/TransactionExtra.h"
#include "crypto/crypto.h"
#include "cryptonotecore/Account.h"

#include <unordered_set>

@@ -280,6 +280,8 @@ std::string Error::getErrorMessage() const
}
/* No default case so the compiler warns us if we missed one */
}

throw std::invalid_argument("Invalid error code given");
}

ErrorCode Error::getErrorCode() const
@@ -41,6 +41,8 @@ namespace Logger
return "Fatal";
}
}

throw std::invalid_argument("Invalid log level given");
}

LogLevel stringToLogLevel(std::string level)
@@ -95,6 +97,8 @@ namespace Logger
return "Daemon";
}
}

throw std::invalid_argument("Invalid log category given");
}

void Logger::log(const std::string message, const LogLevel level, const std::vector<LogCategory> categories) const
@@ -22,7 +22,20 @@
#include <algorithm>
#include <boost/foreach.hpp>
#include <boost/utility/value_init.hpp>


// clang-format off
// see https://github.com/boostorg/random/issues/49
#if BOOST_VERSION == 106900
#ifndef BOOST_PENDING_INTEGER_LOG2_HPP
#define BOOST_PENDING_INTEGER_LOG2_HPP
#include <boost/integer/integer_log2.hpp>
#endif /* BOOST_PENDING_INTEGER_LOG2_HPP */
#endif /* BOOST_VERSION */

#include <boost/uuid/random_generator.hpp>
// clang-format on

#include <boost/uuid/uuid_io.hpp>
#include <config/CryptoNoteConfig.h>
#include <crypto/random.h>

0 comments on commit 1cf596f

Please sign in to comment.
You can’t perform that action at this time.