mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-28 23:15:52 +00:00
Buglets found by static code inspection, including a whopper in divRound.
This commit is contained in:
@@ -271,7 +271,7 @@ STAmount STAmount::divRound(const STAmount& num, const STAmount& den,
|
||||
--denOffset;
|
||||
}
|
||||
|
||||
bool resultNegative = num.mIsNegative != num.mIsNegative;
|
||||
bool resultNegative = num.mIsNegative != den.mIsNegative;
|
||||
// Compute (numerator * 10^17) / denominator
|
||||
CBigNum v;
|
||||
if ((BN_add_word64(&v, numVal) != 1) || (BN_mul_word64(&v, tenTo17) != 1))
|
||||
|
||||
@@ -54,7 +54,7 @@ protected:
|
||||
public:
|
||||
|
||||
FeatureTable(uint32 majorityTime, int majorityFraction)
|
||||
: mMajorityTime(majorityTime), mMajorityFraction(majorityFraction), mFirstReport(0)
|
||||
: mMajorityTime(majorityTime), mMajorityFraction(majorityFraction), mFirstReport(0), mLastReport(0)
|
||||
{ ; }
|
||||
|
||||
bool vetoFeature(const uint256& feature);
|
||||
|
||||
@@ -44,7 +44,8 @@ static int initFields()
|
||||
static const int f = initFields();
|
||||
|
||||
|
||||
SField::SField(SerializedTypeID tid, int fv) : fieldCode(FIELD_CODE(tid, fv)), fieldType(tid), fieldValue(fv)
|
||||
SField::SField(SerializedTypeID tid, int fv) : fieldCode(FIELD_CODE(tid, fv)), fieldType(tid), fieldValue(fv),
|
||||
fieldMeta(sMD_Default), fieldNum(++num), signingField(true)
|
||||
{ // call with the map mutex
|
||||
fieldName = lexical_cast_i(tid) + "/" + lexical_cast_i(fv);
|
||||
codeToField[fieldCode] = this;
|
||||
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
fieldNum = ++num;
|
||||
}
|
||||
|
||||
SField(int fc) : fieldCode(fc), fieldType(STI_UNKNOWN), fieldValue(0), fieldMeta(sMD_Never)
|
||||
SField(int fc) : fieldCode(fc), fieldType(STI_UNKNOWN), fieldValue(0), fieldMeta(sMD_Never), signingField(true)
|
||||
{
|
||||
boost::mutex::scoped_lock sl(mapMutex);
|
||||
fieldNum = ++num;
|
||||
|
||||
@@ -669,7 +669,6 @@ Ledger::pointer Ledger::getSQL1(SqliteStatement *stmt)
|
||||
uint32 closingTime, prevClosingTime, ledgerSeq;
|
||||
int closeResolution;
|
||||
unsigned closeFlags;
|
||||
std::string hash;
|
||||
|
||||
ledgerHash.SetHexExact(stmt->peekString(0));
|
||||
prevHash.SetHexExact(stmt->peekString(1));
|
||||
|
||||
@@ -58,7 +58,7 @@ protected:
|
||||
int mSeq;
|
||||
|
||||
LedgerEntrySet(Ledger::ref ledger, const std::map<uint256, LedgerEntrySetEntry> &e,
|
||||
const TransactionMetaSet& s, int m) : mLedger(ledger), mEntries(e), mSet(s), mSeq(m) { ; }
|
||||
const TransactionMetaSet& s, int m) : mLedger(ledger), mEntries(e), mSet(s), mParams(tapNONE), mSeq(m) { ; }
|
||||
|
||||
SLE::pointer getForMod(const uint256& node, Ledger::ref ledger,
|
||||
boost::unordered_map<uint256, SLE::pointer>& newMods);
|
||||
|
||||
@@ -35,7 +35,7 @@ void InfoSub::onSendEmpty()
|
||||
NetworkOPs::NetworkOPs(boost::asio::io_service& io_service, LedgerMaster* pLedgerMaster) :
|
||||
mMode(omDISCONNECTED), mNeedNetworkLedger(false), mProposing(false), mValidating(false),
|
||||
mNetTimer(io_service), mLedgerMaster(pLedgerMaster), mCloseTimeOffset(0), mLastCloseProposers(0),
|
||||
mLastCloseConvergeTime(1000 * LEDGER_IDLE_INTERVAL), mLastValidationTime(0),
|
||||
mLastCloseConvergeTime(1000 * LEDGER_IDLE_INTERVAL), mLastCloseTime(0), mLastValidationTime(0),
|
||||
mFetchPack("FetchPack", 2048, 20), mLastFetchPack(0), mFetchSeq(static_cast<uint32>(-1)),
|
||||
mLastLoadBase(256), mLastLoadFactor(256)
|
||||
{
|
||||
@@ -1167,7 +1167,7 @@ std::vector<NetworkOPs::txnMetaLedgerType> NetworkOPs::getAccountTxsB(
|
||||
rawTxn.resize(txnSize);
|
||||
|
||||
int metaSize = 2048;
|
||||
std::vector<unsigned char> rawMeta(2048);
|
||||
std::vector<unsigned char> rawMeta(metaSize);
|
||||
metaSize = db->getBinary("TxnMeta", &rawMeta[0], rawMeta.size());
|
||||
if (metaSize > rawMeta.size())
|
||||
{
|
||||
@@ -1646,7 +1646,7 @@ void NetworkOPs::unsubAccount(uint64 uSeq, const boost::unordered_set<RippleAddr
|
||||
subInfoMapType::iterator simIterator = subMap.find(naAccountID.getAccountID());
|
||||
|
||||
|
||||
if (simIterator == mSubAccount.end())
|
||||
if (simIterator == subMap.end())
|
||||
{
|
||||
// Not found. Done.
|
||||
nothing();
|
||||
|
||||
@@ -7,13 +7,12 @@ AccountItem::pointer Offer::makeItem(const uint160& ,SerializedLedgerEntry::ref
|
||||
return(AccountItem::pointer(offer));
|
||||
}
|
||||
|
||||
Offer::Offer(SerializedLedgerEntry::pointer ledgerEntry) : AccountItem(ledgerEntry)
|
||||
{
|
||||
mAccount=mLedgerEntry->getFieldAccount(sfAccount);
|
||||
mTakerGets = mLedgerEntry->getFieldAmount(sfTakerGets);
|
||||
mTakerPays = mLedgerEntry->getFieldAmount(sfTakerPays);
|
||||
mSeq = mLedgerEntry->getFieldU32(sfSequence);
|
||||
}
|
||||
Offer::Offer(SerializedLedgerEntry::pointer ledgerEntry) : AccountItem(ledgerEntry),
|
||||
mAccount(mLedgerEntry->getFieldAccount(sfAccount)),
|
||||
mTakerGets(mLedgerEntry->getFieldAmount(sfTakerGets)),
|
||||
mTakerPays(mLedgerEntry->getFieldAmount(sfTakerPays)),
|
||||
mSeq(mLedgerEntry->getFieldU32(sfSequence))
|
||||
{ ; }
|
||||
|
||||
Json::Value Offer::getJson(int)
|
||||
{
|
||||
|
||||
@@ -39,6 +39,7 @@ bool ParameterNode::setValue(const std::string& name, const Json::Value& value,
|
||||
error = Json::objectValue;
|
||||
error["error"] = "Node has no children";
|
||||
error["name"] = it->second->getName();
|
||||
return false;
|
||||
}
|
||||
|
||||
return n->setValue(name.substr(dot + 1), value, error);
|
||||
@@ -74,7 +75,6 @@ bool ParameterNode::addNode(const std::string& name, Parameter::ref node)
|
||||
if (!n)
|
||||
return false;
|
||||
}
|
||||
|
||||
return n->addNode(name.substr(dot + 1), node);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,10 +66,10 @@ int iAdminGet(const Json::Value& jvRequest, const std::string& strRemoteIp)
|
||||
return iRole;
|
||||
}
|
||||
|
||||
RPCHandler::RPCHandler(NetworkOPs* netOps) : mNetOps(netOps)
|
||||
RPCHandler::RPCHandler(NetworkOPs* netOps) : mNetOps(netOps), mRole(FORBID)
|
||||
{ ; }
|
||||
|
||||
RPCHandler::RPCHandler(NetworkOPs* netOps, InfoSub::pointer infoSub) : mNetOps(netOps), mInfoSub(infoSub)
|
||||
RPCHandler::RPCHandler(NetworkOPs* netOps, InfoSub::pointer infoSub) : mNetOps(netOps), mInfoSub(infoSub), mRole(FORBID)
|
||||
{ ; }
|
||||
|
||||
Json::Value RPCHandler::transactionSign(Json::Value jvRequest, bool bSubmit)
|
||||
|
||||
@@ -62,7 +62,7 @@ Transaction::Transaction(
|
||||
uint32 uSeq,
|
||||
const STAmount& saFee,
|
||||
uint32 uSourceTag) :
|
||||
mAccountFrom(naSourceAccount), mFromPubKey(naPublicKey), mStatus(NEW), mResult(temUNCERTAIN)
|
||||
mAccountFrom(naSourceAccount), mFromPubKey(naPublicKey), mInLedger(0), mStatus(NEW), mResult(temUNCERTAIN)
|
||||
{
|
||||
assert(mFromPubKey.isValid());
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ protected:
|
||||
|
||||
public:
|
||||
|
||||
TXQueue() { ; }
|
||||
TXQueue() : mRunning(false) { ; }
|
||||
|
||||
// Return: true = must dispatch signature checker thread
|
||||
bool addEntryForSigCheck(TXQEntry::ref);
|
||||
|
||||
Reference in New Issue
Block a user