From 950f6fd4db1b4266955e431e53a40470992601cd Mon Sep 17 00:00:00 2001 From: Vito <5780819+Tapanito@users.noreply.github.com> Date: Tue, 2 Jun 2026 17:46:30 +0200 Subject: [PATCH] address reviewer feedback --- include/xrpl/beast/utility/instrumentation.h | 10 +++++----- src/libxrpl/ledger/helpers/LendingHelpers.cpp | 17 ++++++++--------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/include/xrpl/beast/utility/instrumentation.h b/include/xrpl/beast/utility/instrumentation.h index a8bd2f398f..a152744d50 100644 --- a/include/xrpl/beast/utility/instrumentation.h +++ b/include/xrpl/beast/utility/instrumentation.h @@ -11,6 +11,8 @@ // Macros below are copied from antithesis_sdk.h and slightly simplified // The duplication is because Visual Studio 2019 cannot compile that header // even with the option -Zc:__cplusplus added. +// // NOTE: cond must not contain bare commas outside () or []. Commas inside {} +// are not protected by the preprocessor and would be parsed as extra arguments. #define ALWAYS(cond, message, ...) assert((message) && (cond)) #define ALWAYS_OR_UNREACHABLE(cond, message) assert((message) && (cond)) #define SOMETIMES(cond, message, ...) @@ -21,15 +23,13 @@ #define XRPL_ASSERT ALWAYS_OR_UNREACHABLE #define XRPL_ASSERT_PARTS(cond, function, description, ...) \ XRPL_ASSERT(cond, function " : " description) -// clang-format off -// NOTE: cond must not contain bare commas outside () or []. Commas inside {} -// are not protected by the preprocessor and would be parsed as extra arguments. + #define XRPL_ASSERT_IF(guard, cond, message) \ - do { \ + do \ + { \ if ((guard)) \ XRPL_ASSERT(cond, message); \ } while (false) -// clang-format on // How to use the instrumentation macros: // diff --git a/src/libxrpl/ledger/helpers/LendingHelpers.cpp b/src/libxrpl/ledger/helpers/LendingHelpers.cpp index 0062b8f969..0a195f9cbe 100644 --- a/src/libxrpl/ledger/helpers/LendingHelpers.cpp +++ b/src/libxrpl/ledger/helpers/LendingHelpers.cpp @@ -822,15 +822,14 @@ doOverpayment( XRPL_ASSERT_IF( fix320Enabled, - loanPaymentParts.valueChange == - [&] { - Number const tvoChange = newRoundedLoanState.valueOutstanding - - (totalValueOutstandingProxy - overpaymentComponents.trackedPrincipalDelta); - Number const managementFeeReleased = - managementFeeOutstandingProxy - newRoundedLoanState.managementFeeDue; - Number const interestPart = overpaymentComponents.trackedInterestPart(); - return tvoChange + managementFeeReleased + interestPart; - }(), + [&] { + Number const tvoChange = newRoundedLoanState.valueOutstanding - + (totalValueOutstandingProxy - overpaymentComponents.trackedPrincipalDelta); + Number const managementFeeReleased = + managementFeeOutstandingProxy - newRoundedLoanState.managementFeeDue; + Number const interestPart = overpaymentComponents.trackedInterestPart(); + return loanPaymentParts.valueChange == tvoChange + managementFeeReleased + interestPart; + }(), "xrpl::detail::doOverpayment : interest paid agrees"); XRPL_ASSERT_IF(