From c136ac2029a0433ccd51b9565dfc453603efdb1d Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Fri, 20 Mar 2020 14:49:07 -0700 Subject: [PATCH] [coap] avoid comparison of narrow type with wide type in loop (#4724) --- src/core/coap/coap_message.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/core/coap/coap_message.cpp b/src/core/coap/coap_message.cpp index 92a5fada5..258f17312 100644 --- a/src/core/coap/coap_message.cpp +++ b/src/core/coap/coap_message.cpp @@ -570,13 +570,12 @@ otError OptionIterator::GetOptionValue(uint64_t &aValue) const { otError error = OT_ERROR_NONE; uint8_t value[sizeof(aValue)]; - uint8_t pos = 0; VerifyOrExit(mOption.mLength <= sizeof(aValue), error = OT_ERROR_NO_BUFS); SuccessOrExit(error = GetOptionValue(value)); aValue = 0; - for (pos = 0; pos < mOption.mLength; pos++) + for (uint16_t pos = 0; pos < mOption.mLength; pos++) { aValue <<= 8; aValue |= value[pos];