Add option to enable -Wextra for gcc/clang.

This commit is contained in:
Mike Ellery
2019-10-03 10:17:15 -07:00
committed by Manoj doshi
parent ca47583a3b
commit 82484e26f5
15 changed files with 31 additions and 23 deletions

View File

@@ -7,7 +7,7 @@ services:
env:
global:
- DOCKER_IMAGE="mellery451/rippled-ci-builder:2019-08-26"
- CMAKE_EXTRA_ARGS="-Dwerr=ON"
- CMAKE_EXTRA_ARGS="-Dwerr=ON -Dwextra=ON"
- NINJA_BUILD=true
# change this if we get more VM capacity
- MAX_TIME_MIN=80

View File

@@ -87,6 +87,9 @@ if (MSVC)
else ()
# HACK : because these need to come first, before any warning demotion
string (APPEND CMAKE_CXX_FLAGS " -Wall -Wdeprecated")
if (wextra)
string (APPEND CMAKE_CXX_FLAGS " -Wextra -Wno-unused-parameter")
endif ()
# not MSVC
target_compile_options (common
INTERFACE

View File

@@ -16,9 +16,11 @@ if (is_gcc OR is_clang)
"Include only src/ripple files when generating coverage report. \
Set to OFF to include all sources in coverage report."
ON)
option (wextra "compile with extra gcc/clang warnings enabled" ON)
else ()
set (profile OFF CACHE BOOL "gcc/clang only" FORCE)
set (coverage OFF CACHE BOOL "gcc/clang only" FORCE)
set (wextra OFF CACHE BOOL "gcc/clang only" FORCE)
endif ()
if (is_linux)
option (BUILD_SHARED_LIBS "build shared ripple libraries" OFF)

View File

@@ -433,9 +433,7 @@ Ledger::read (Keylet const& k) const
item->size()}, item->key());
if (! k.check(*sle))
return nullptr;
// need move otherwise makes a copy
// because return type is different
return std::move(sle);
return sle;
}
//------------------------------------------------------------------------------

View File

@@ -1567,7 +1567,7 @@ bool ApplicationImp::setup()
Resource::Charge loadType = Resource::feeReferenceRPC;
Resource::Consumer c;
RPC::Context context { journal ("RPCHandler"), jvCommand, *this,
loadType, getOPs (), getLedgerMaster(), c, Role::ADMIN };
loadType, getOPs (), getLedgerMaster (), c, Role::ADMIN};
Json::Value jvResult;
RPC::doCommand (context, jvResult);

View File

@@ -146,7 +146,7 @@ boost::optional<Manifest> deserializeManifest(Slice s)
m.signingKey = PublicKey(makeSlice(spk));
}
return std::move(m);
return m;
}
catch (std::exception const&)
{

View File

@@ -24,6 +24,7 @@
#include <ripple/app/ledger/LedgerMaster.h>
#include <ripple/app/main/Application.h>
#include <ripple/app/misc/HashRouter.h>
#include <ripple/basics/safe_cast.h>
#include <ripple/protocol/Feature.h>
#include <ripple/protocol/jss.h>
#include <boost/optional.hpp>
@@ -63,7 +64,7 @@ void Transaction::setStatus (TransStatus ts, std::uint32_t lseq)
TransStatus Transaction::sqlTransactionStatus(
boost::optional<std::string> const& status)
{
char const c = (status) ? (*status)[0] : txnSqlUnknown;
char const c = (status) ? (*status)[0] : safe_cast<char>(txnSqlUnknown);
switch (c)
{

View File

@@ -112,7 +112,11 @@ inline
bool
is_char(char c)
{
#ifdef __CHAR_UNSIGNED__ /* -funsigned-char */
return c >= 0 && c <= 127;
#else
return c >= 0;
#endif
}
template <class FwdIter>

View File

@@ -44,7 +44,7 @@ struct PeerReservation final
{
public:
PublicKey nodeId;
std::string description;
std::string description {};
auto
toJson() const -> Json::Value;

View File

@@ -819,7 +819,7 @@ static boost::optional <STObject> parseObject (
// Some inner object types have templates. Attempt to apply that.
data.applyTemplateFromSField (inName); // May throw
return std::move (data);
return data;
}
catch (STObject::FieldErr const&)
{

View File

@@ -55,9 +55,9 @@ struct Context
LedgerMaster& ledgerMaster;
Resource::Consumer& consumer;
Role role;
std::shared_ptr<JobQueue::Coro> coro;
InfoSub::pointer infoSub;
Headers headers;
std::shared_ptr<JobQueue::Coro> coro {};
InfoSub::pointer infoSub {};
Headers headers {};
};
} // RPC

View File

@@ -353,7 +353,7 @@ transactionPreProcessImpl (
Json::Value jvResult;
auto const [pk, sk] = keypairForSignature (params, jvResult);
if (contains_error (jvResult))
return std::move (jvResult);
return jvResult;
bool const verify = !(params.isMember (jss::offline)
&& params[jss::offline].asBool());
@@ -402,7 +402,7 @@ transactionPreProcessImpl (
ledger);
if (RPC::contains_error (err))
return std::move (err);
return err;
err = checkPayment (
params,
@@ -414,7 +414,7 @@ transactionPreProcessImpl (
verify && signingArgs.editFields());
if (RPC::contains_error(err))
return std::move (err);
return err;
}
if (signingArgs.editFields())
@@ -495,7 +495,7 @@ transactionPreProcessImpl (
err [jss::error] = parsed.error [jss::error];
err [jss::error_code] = parsed.error [jss::error_code];
err [jss::error_message] = parsed.error [jss::error_message];
return std::move (err);
return err;
}
std::shared_ptr<STTx> stpTrans;

View File

@@ -46,7 +46,7 @@ SHAMapInnerNode::clone(std::uint32_t seq) const
std::lock_guard lock(childLock);
for (int i = 0; i < 16; ++i)
p->mChildren[i] = mChildren[i];
return std::move(p);
return p;
}
std::shared_ptr<SHAMapAbstractNode>

View File

@@ -48,9 +48,9 @@ class LedgerLoad_test : public beast::unit_test::suite
struct SetupData
{
std::string const dbPath;
std::string ledgerFile;
Json::Value ledger;
Json::Value hashes;
std::string ledgerFile {};
Json::Value ledger {};
Json::Value hashes {};
};
SetupData

View File

@@ -220,8 +220,8 @@ public:
auto& app = env.app();
Resource::Charge loadType = Resource::feeReferenceRPC;
Resource::Consumer c;
RPC::Context context {env.journal, {}, app, loadType,
app.getOPs(), app.getLedgerMaster(), c, Role::USER, {}};
RPC::Context context { env.journal, {}, app, loadType,
app.getOPs(), app.getLedgerMaster(), c, Role::USER};
Json::Value params = Json::objectValue;
params[jss::command] = "ripple_path_find";
@@ -320,7 +320,7 @@ public:
Resource::Charge loadType = Resource::feeReferenceRPC;
Resource::Consumer c;
RPC::Context context {env.journal, {}, app, loadType,
app.getOPs(), app.getLedgerMaster(), c, Role::USER, {}};
app.getOPs(), app.getLedgerMaster(), c, Role::USER};
Json::Value result;
gate g;
// Test RPC::Tuning::max_src_cur source currencies.