From f64c597fc67dfc8584bc6494f811c53b6f38c9e7 Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Tue, 5 Jan 2021 09:35:45 -0800 Subject: [PATCH] [coap] fix order of operations in TxParameters::IsValid() (#6027) To match CalculateInitialRetransmissionTimeout() implementation. --- src/core/coap/coap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/coap/coap.cpp b/src/core/coap/coap.cpp index 36f4c9d2b..48302ca64 100644 --- a/src/core/coap/coap.cpp +++ b/src/core/coap/coap.cpp @@ -950,8 +950,8 @@ bool TxParameters::IsValid(void) const // Calulate exchange lifetime step by step and verify no overflow. uint32_t tmp = Multiply(mAckTimeout, (1U << (mMaxRetransmit + 1)) - 1); - tmp /= mAckRandomFactorDenominator; tmp = Multiply(tmp, mAckRandomFactorNumerator); + tmp /= mAckRandomFactorDenominator; rval = (tmp != 0 && (tmp + mAckTimeout + 2 * kDefaultMaxLatency) > tmp); }