fix clang-tidy

This commit is contained in:
Mayukha Vadari
2026-03-24 16:12:37 -07:00
parent c0895c6e2e
commit dcdc5e1b52
17 changed files with 50 additions and 46 deletions

View File

@@ -335,7 +335,7 @@ verifyDepositPreauth(
if (credentialsPresent && credentials::removeExpired(view, tx.getFieldV256(sfCredentialIDs), j))
return tecEXPIRED;
if (dst.exists() && (dst->getFlags() & lsfDepositAuth))
if (dst.exists() && ((dst->getFlags() & lsfDepositAuth) != 0u))
{
if (src != dst)
{

View File

@@ -83,7 +83,7 @@ transferRate(ReadView const& view, MPTID const& issuanceID)
// which represents 50% of 1,000,000,000
if (auto const sle = view.read(keylet::mptIssuance(issuanceID));
sle && sle->isFieldPresent(sfTransferFee))
return Rate{1'000'000'000u + 10'000 * sle->getFieldU16(sfTransferFee)};
return Rate{1'000'000'000u + (10'000 * sle->getFieldU16(sfTransferFee))};
return parityRate;
}
@@ -149,7 +149,7 @@ authorizeMPToken(
// When a holder wants to unauthorize/delete a MPT, the ledger must
// - delete mptokenKey from owner directory
// - delete the MPToken
if (flags & tfMPTUnauthorize)
if ((flags & tfMPTUnauthorize) != 0u)
{
auto const mptokenKey = keylet::mptoken(mptIssuanceID, account);
auto const sleMpt = view.peek(mptokenKey);
@@ -229,7 +229,7 @@ authorizeMPToken(
// Issuer wants to unauthorize the holder, unset lsfMPTAuthorized on
// their MPToken
if (flags & tfMPTUnauthorize)
if ((flags & tfMPTUnauthorize) != 0u)
{
flagsOut &= ~lsfMPTAuthorized;
}
@@ -489,7 +489,7 @@ canTransfer(
if (!sleIssuance)
return tecOBJECT_NOT_FOUND;
if (!(sleIssuance->getFieldU32(sfFlags) & lsfMPTCanTransfer))
if ((sleIssuance->getFieldU32(sfFlags) & lsfMPTCanTransfer) == 0u)
{
if (from != (*sleIssuance)[sfIssuer] && to != (*sleIssuance)[sfIssuer])
return TER{tecNO_AUTH};

View File

@@ -224,10 +224,10 @@ trustCreate(
bSetHigh ? sfLowLimit : sfHighLimit,
STAmount(Issue{saBalance.getCurrency(), bSetDst ? uSrcAccountID : uDstAccountID}));
if (uQualityIn)
if (uQualityIn != 0u)
sleRippleState->setFieldU32(bSetHigh ? sfHighQualityIn : sfLowQualityIn, uQualityIn);
if (uQualityOut)
if (uQualityOut != 0u)
sleRippleState->setFieldU32(bSetHigh ? sfHighQualityOut : sfLowQualityOut, uQualityOut);
std::uint32_t uFlags = bSetHigh ? lsfHighReserve : lsfLowReserve;
@@ -327,16 +327,16 @@ updateTrustLine(
// Sender balance was positive.
&& after <= beast::zero
// Sender is zero or negative.
&& (flags & (!bSenderHigh ? lsfLowReserve : lsfHighReserve))
&& ((flags & (!bSenderHigh ? lsfLowReserve : lsfHighReserve)) != 0u)
// Sender reserve is set.
&& static_cast<bool>(flags & (!bSenderHigh ? lsfLowNoRipple : lsfHighNoRipple)) !=
static_cast<bool>(wrappedAcct->getFlags() & lsfDefaultRipple) &&
!(flags & (!bSenderHigh ? lsfLowFreeze : lsfHighFreeze)) &&
((flags & (!bSenderHigh ? lsfLowFreeze : lsfHighFreeze)) == 0u) &&
!state->getFieldAmount(!bSenderHigh ? sfLowLimit : sfHighLimit)
// Sender trust limit is 0.
&& !state->getFieldU32(!bSenderHigh ? sfLowQualityIn : sfHighQualityIn)
&& (state->getFieldU32(!bSenderHigh ? sfLowQualityIn : sfHighQualityIn) == 0u)
// Sender quality in is 0.
&& !state->getFieldU32(!bSenderHigh ? sfLowQualityOut : sfHighQualityOut))
&& (state->getFieldU32(!bSenderHigh ? sfLowQualityOut : sfHighQualityOut) == 0u))
// Sender quality out is 0.
{
// VFALCO Where is the line being deleted?
@@ -348,7 +348,7 @@ updateTrustLine(
// Balance is zero, receiver reserve is clear.
if (!after // Balance is zero.
&& !(flags & (bSenderHigh ? lsfLowReserve : lsfHighReserve)))
&& ((flags & (bSenderHigh ? lsfLowReserve : lsfHighReserve)) == 0u))
return true;
}
return false;
@@ -539,11 +539,12 @@ requireAuth(ReadView const& view, Issue const& issue, AccountID const& account,
// If this is a weak or legacy check, or if the account has a line, fail if
// auth is required and not set on the line
auto const issuerAccount = AccountRoot(issue.account, view);
if (issuerAccount.exists() && (*issuerAccount)[sfFlags] & lsfRequireAuth)
if (issuerAccount.exists() && (((*issuerAccount)[sfFlags] & lsfRequireAuth) != 0u))
{
if (trustLine)
{
return ((*trustLine)[sfFlags] & ((account > issue.account) ? lsfLowAuth : lsfHighAuth))
return (((*trustLine)[sfFlags] &
((account > issue.account) ? lsfLowAuth : lsfHighAuth)) != 0u)
? tesSUCCESS
: TER{tecNO_AUTH};
}
@@ -575,7 +576,7 @@ canTransfer(ReadView const& view, Issue const& issue, AccountID const& from, Acc
bool const issuerHigh = issuerId > account;
return line->isFlag(issuerHigh ? lsfHighNoRipple : lsfLowNoRipple);
}
return issuer->isFlag(lsfDefaultRipple) == false;
return !issuer->isFlag(lsfDefaultRipple);
};
// Fail if rippling disabled on both trust lines
@@ -749,7 +750,7 @@ deleteAMMTrustLine(
}
auto const uFlags = !ammLow ? lsfLowReserve : lsfHighReserve;
if (!(sleState->getFlags() & uFlags))
if ((sleState->getFlags() & uFlags) == 0u)
return tecINTERNAL; // LCOV_EXCL_LINE
WritableAccountRoot wrappedHolder = !ammLow ? wrappedLow : wrappedHigh;

View File

@@ -574,16 +574,17 @@ rippleCreditIOU(
// Sender balance was positive.
&& saBalance <= beast::zero
// Sender is zero or negative.
&& (uFlags & (!bSenderHigh ? lsfLowReserve : lsfHighReserve))
&& ((uFlags & (!bSenderHigh ? lsfLowReserve : lsfHighReserve)) != 0u)
// Sender reserve is set.
&& static_cast<bool>(uFlags & (!bSenderHigh ? lsfLowNoRipple : lsfHighNoRipple)) !=
static_cast<bool>(AccountRoot(uSenderID, view)->getFlags() & lsfDefaultRipple) &&
!(uFlags & (!bSenderHigh ? lsfLowFreeze : lsfHighFreeze)) &&
((uFlags & (!bSenderHigh ? lsfLowFreeze : lsfHighFreeze)) == 0u) &&
!sleRippleState->getFieldAmount(!bSenderHigh ? sfLowLimit : sfHighLimit)
// Sender trust limit is 0.
&& !sleRippleState->getFieldU32(!bSenderHigh ? sfLowQualityIn : sfHighQualityIn)
&& (sleRippleState->getFieldU32(!bSenderHigh ? sfLowQualityIn : sfHighQualityIn) == 0u)
// Sender quality in is 0.
&& !sleRippleState->getFieldU32(!bSenderHigh ? sfLowQualityOut : sfHighQualityOut))
&&
(sleRippleState->getFieldU32(!bSenderHigh ? sfLowQualityOut : sfHighQualityOut) == 0u))
// Sender quality out is 0.
{
// Clear the reserve of the sender, possibly delete the line!
@@ -596,7 +597,7 @@ rippleCreditIOU(
// Balance is zero, receiver reserve is clear.
bDelete = !saBalance // Balance is zero.
&& !(uFlags & (bSenderHigh ? lsfLowReserve : lsfHighReserve));
&& ((uFlags & (bSenderHigh ? lsfLowReserve : lsfHighReserve)) == 0u);
// Receiver reserve is clear.
}

View File

@@ -214,7 +214,7 @@ AccountDelete::preclaim(PreclaimContext const& ctx)
if (!acctDst)
return tecNO_DST;
if (acctDst->getFlags() & lsfRequireDestTag && !ctx.tx[~sfDestinationTag])
if (((acctDst->getFlags() & lsfRequireDestTag) != 0u) && !ctx.tx[~sfDestinationTag])
return tecDST_TAG_NEEDED;
// If credentials are provided - check them anyway
@@ -226,7 +226,7 @@ AccountDelete::preclaim(PreclaimContext const& ctx)
if (!ctx.tx.isFieldPresent(sfCredentialIDs))
{
// Check whether the destination account requires deposit authorization.
if (acctDst->getFlags() & lsfDepositAuth)
if ((acctDst->getFlags() & lsfDepositAuth) != 0u)
{
if (!ctx.view.exists(keylet::depositPreauth(dst, account)))
return tecNO_PERMISSION;

View File

@@ -18,7 +18,7 @@ SetRegularKey::calculateBaseFee(ReadView const& view, STTx const& tx)
{
AccountRoot const acct(id, view);
if (acct && (!(acct->getFlags() & lsfPasswordSpent)))
if (acct && ((acct->getFlags() & lsfPasswordSpent) == 0u))
{
// flag is armed and they signed with the right account
return XRPAmount{0};

View File

@@ -108,7 +108,7 @@ checkAttestationPublicKey(
if (accountFromPK == attestationSignerAccount)
{
// master key
if (acctSigner->getFieldU32(sfFlags) & lsfDisableMaster)
if ((acctSigner->getFieldU32(sfFlags) & lsfDisableMaster) != 0u)
{
JLOG(j.trace()) << "Attempt to add an attestation with "
"disabled master key.";
@@ -384,7 +384,7 @@ transferHelper(
{
// Check dst tag and deposit auth
if ((acctDst->getFlags() & lsfRequireDestTag) && !dstTag)
if (((acctDst->getFlags() & lsfRequireDestTag) != 0u) && !dstTag)
return tecDST_TAG_NEEDED;
// If the destination is the claim owner, and this is a claim
@@ -393,7 +393,7 @@ transferHelper(
bool const canBypassDepositAuth =
dst == claimOwner && depositAuthPolicy == DepositAuthPolicy::dstCanBypass;
if (!canBypassDepositAuth && (acctDst->getFlags() & lsfDepositAuth) &&
if (!canBypassDepositAuth && ((acctDst->getFlags() & lsfDepositAuth) != 0u) &&
!psb.exists(keylet::depositPreauth(dst, src)))
{
return tecNO_PERMISSION;
@@ -1400,7 +1400,7 @@ XChainCreateBridge::preclaim(PreclaimContext const& ctx)
// Allowing clawing back funds would break the bridge's invariant that
// wrapped funds are always backed by locked funds
if (acctIssuer->getFlags() & lsfAllowTrustLineClawback)
if ((acctIssuer->getFlags() & lsfAllowTrustLineClawback) != 0u)
return tecNO_PERMISSION;
}

View File

@@ -82,7 +82,7 @@ CheckCash::preclaim(PreclaimContext const& ctx)
return tecNO_ENTRY;
}
if ((acctDst->getFlags() & lsfRequireDestTag) &&
if (((acctDst->getFlags() & lsfRequireDestTag) != 0u) &&
!sleCheck->isFieldPresent(sfDestinationTag))
{
// The tag is basically account-specific information we don't
@@ -156,7 +156,7 @@ CheckCash::preclaim(PreclaimContext const& ctx)
return tecNO_ISSUER;
}
if (acctIssuer->at(sfFlags) & lsfRequireAuth)
if ((acctIssuer->at(sfFlags) & lsfRequireAuth) != 0u)
{
auto const sleTrustLine = ctx.view.read(keylet::line(dstId, issuerId, currency));

View File

@@ -223,7 +223,7 @@ OfferCreate::checkAcceptAsset(
if (issue.account == id)
return tesSUCCESS;
if (issuerAcct->getFlags() & lsfRequireAuth)
if ((issuerAcct->getFlags() & lsfRequireAuth) != 0u)
{
auto const trustLine = view.read(keylet::line(id, issue.account, issue.currency));

View File

@@ -413,7 +413,7 @@ EscrowCreate::doApply()
AccountRoot const acctDest(ctx_.tx[sfDestination], ctx_.view());
if (!acctDest)
return tecNO_DST; // LCOV_EXCL_LINE
if ((acctDest->getFlags() & lsfRequireDestTag) && !ctx_.tx[~sfDestinationTag])
if (((acctDest->getFlags() & lsfRequireDestTag) != 0u) && !ctx_.tx[~sfDestinationTag])
return tecDST_TAG_NEEDED;
}

View File

@@ -887,7 +887,7 @@ tokenOfferCreatePreclaim(
return tecNO_DST;
// check if the destination has disallowed incoming offers
if (acctDst->getFlags() & lsfDisallowIncomingNFTokenOffer)
if ((acctDst->getFlags() & lsfDisallowIncomingNFTokenOffer) != 0u)
return tecNO_PERMISSION;
}
@@ -900,7 +900,7 @@ tokenOfferCreatePreclaim(
if (!acctOwner)
return tecNO_TARGET;
if (acctOwner->getFlags() & lsfDisallowIncomingNFTokenOffer)
if ((acctOwner->getFlags() & lsfDisallowIncomingNFTokenOffer) != 0u)
return tecNO_PERMISSION;
}

View File

@@ -313,7 +313,9 @@ Payment::preclaim(PreclaimContext const& ctx)
return tecNO_DST_INSUF_XRP;
}
}
else if ((dstAcct->getFlags() & lsfRequireDestTag) && !ctx.tx.isFieldPresent(sfDestinationTag))
else if (
((dstAcct->getFlags() & lsfRequireDestTag) != 0u) &&
!ctx.tx.isFieldPresent(sfDestinationTag))
{
// The tag is basically account-specific information we don't
// understand, but we can require someone to fill it in.
@@ -614,7 +616,7 @@ Payment::doApply()
dst->setFieldAmount(sfBalance, dst->getFieldAmount(sfBalance) + dstAmount);
// Re-arm the password change fee if we can and need to.
if ((dst->getFlags() & lsfPasswordSpent))
if ((dst->getFlags() & lsfPasswordSpent) != 0u)
dst->clearFlag(lsfPasswordSpent);
return tesSUCCESS;

View File

@@ -181,7 +181,7 @@ TrustSet::preclaim(PreclaimContext const& ctx)
bool const bSetAuth = (uTxFlags & tfSetfAuth) != 0u;
if (bSetAuth && !(acct->getFieldU32(sfFlags) & lsfRequireAuth))
if (bSetAuth && ((acct->getFieldU32(sfFlags) & lsfRequireAuth) == 0u))
{
JLOG(ctx.j.trace()) << "Retry: Auth not required.";
return tefNO_AUTH_REQUIRED;
@@ -203,7 +203,7 @@ TrustSet::preclaim(PreclaimContext const& ctx)
// If the destination has opted to disallow incoming trustlines
// then honour that flag
if (acctDst->getFlags() & lsfDisallowIncomingTrustline)
if ((acctDst->getFlags() & lsfDisallowIncomingTrustline) != 0u)
{
// The original implementation of featureDisallowIncoming was
// too restrictive. If
@@ -268,8 +268,8 @@ TrustSet::preclaim(PreclaimContext const& ctx)
if (ctx.view.rules().enabled(featureDeepFreeze))
{
bool const bNoFreeze = acct->isFlag(lsfNoFreeze);
bool const bSetFreeze = (uTxFlags & tfSetFreeze);
bool const bSetDeepFreeze = (uTxFlags & tfSetDeepFreeze);
bool const bSetFreeze = (uTxFlags & tfSetFreeze) != 0u;
bool const bSetDeepFreeze = (uTxFlags & tfSetDeepFreeze) != 0u;
if (bNoFreeze && (bSetFreeze || bSetDeepFreeze))
{
@@ -515,8 +515,8 @@ TrustSet::doApply()
if (QUALITY_ONE == uHighQualityOut)
uHighQualityOut = 0;
bool const bLowDefRipple = lowAcct->getFlags() & lsfDefaultRipple;
bool const bHighDefRipple = highAcct->getFlags() & lsfDefaultRipple;
bool const bLowDefRipple = (lowAcct->getFlags() & lsfDefaultRipple) != 0u;
bool const bHighDefRipple = (highAcct->getFlags() & lsfDefaultRipple) != 0u;
bool const bLowReserveSet = (uLowQualityIn != 0u) || (uLowQualityOut != 0u) ||
((uFlagsOut & lsfLowNoRipple) == 0) != bLowDefRipple ||

View File

@@ -192,7 +192,7 @@ PathRequest::isValid(std::shared_ptr<RippleLineCache> const& crCache)
}
else
{
bool const disallowXRP(acctDest->getFlags() & lsfDisallowXRP);
bool const disallowXRP((acctDest->getFlags() & lsfDisallowXRP) != 0u);
auto usDestCurrID = accountDestCurrencies(*raDstAccount, crCache, !disallowXRP);

View File

@@ -931,7 +931,7 @@ Pathfinder::addLink(
if (acctEnd)
{
bool const bRequireAuth(acctEnd->getFieldU32(sfFlags) & lsfRequireAuth);
bool const bRequireAuth((acctEnd->getFieldU32(sfFlags) & lsfRequireAuth) != 0u);
bool const bIsEndCurrency(uEndCurrency == mDstAmount.getCurrency());
bool const bIsNoRippleOut(isNoRippleOut(currentPath));
bool const bDestOnly((addFlags & afAC_LAST) != 0u);

View File

@@ -74,7 +74,7 @@ doDepositAuthorized(RPC::JsonContext& context)
return result;
}
bool const reqAuth = (acctDest->getFlags() & lsfDepositAuth) && (srcAcct != dstAcct);
bool const reqAuth = ((acctDest->getFlags() & lsfDepositAuth) != 0u) && (srcAcct != dstAcct);
bool const credentialsPresent = params.isMember(jss::credentials);
std::set<std::pair<AccountID, Slice>> sorted;

View File

@@ -108,7 +108,7 @@ doNoRippleCheck(RPC::JsonContext& context)
Json::Value& problems = (result["problems"] = Json::arrayValue);
bool bDefaultRipple = acct->getFieldU32(sfFlags) & lsfDefaultRipple;
bool bDefaultRipple = (acct->getFieldU32(sfFlags) & lsfDefaultRipple) != 0u;
if ((static_cast<int>(bDefaultRipple) & static_cast<int>(!roleGateway)) != 0)
{