[coap] avoid comparison of narrow type with wide type in loop (#4724)

This commit is contained in:
Jonathan Hui
2020-03-24 11:09:20 -07:00
parent 2b11826fbe
commit c136ac2029
+1 -2
View File
@@ -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];