mirror of
https://fuchsia.googlesource.com/third_party/openthread
synced 2024-07-12 01:05:25 +00:00
[clang-tidy] fix bugprone-too-small-loop-variable
warnings (#9321)
This commit is contained in:
parent
94822eadb5
commit
7d6740c9b5
|
@ -2,6 +2,7 @@
|
|||
Checks: >
|
||||
-*,
|
||||
bugprone-argument-comment,
|
||||
bugprone-too-small-loop-variable,
|
||||
google-explicit-constructor,
|
||||
google-readability-casting,
|
||||
misc-unused-using-decls,
|
||||
|
|
|
@ -84,7 +84,7 @@ void otPlatFlashInit(otInstance *aInstance)
|
|||
|
||||
if (create)
|
||||
{
|
||||
for (uint8_t index = 0; index < SWAP_NUM; index++)
|
||||
for (uint8_t index = 0; index < (uint8_t)SWAP_NUM; index++)
|
||||
{
|
||||
otPlatFlashErase(aInstance, index);
|
||||
}
|
||||
|
|
|
@ -236,7 +236,7 @@ otError ProcessNodeIdFilter(void *aContext, uint8_t aArgsLength, char *aArgs[])
|
|||
break;
|
||||
}
|
||||
|
||||
for (uint16_t nodeId = 0; nodeId <= MAX_NETWORK_SIZE; nodeId++)
|
||||
for (uint16_t nodeId = 0; nodeId <= (uint16_t)MAX_NETWORK_SIZE; nodeId++)
|
||||
{
|
||||
if (FilterContainsId(nodeId))
|
||||
{
|
||||
|
|
|
@ -5256,7 +5256,7 @@ void Interpreter::HandleMeshDiagDiscoverDone(otError aError, otMeshDiagRouterInf
|
|||
{
|
||||
OutputFormat(kIndentSize, "%u-links:{ ", linkQuality);
|
||||
|
||||
for (uint8_t id = 0; id < OT_ARRAY_LENGTH(aRouterInfo->mLinkQualities); id++)
|
||||
for (uint8_t id = 0; id < static_cast<uint8_t>(OT_ARRAY_LENGTH(aRouterInfo->mLinkQualities)); id++)
|
||||
{
|
||||
if (aRouterInfo->mLinkQualities[id] == linkQuality)
|
||||
{
|
||||
|
|
|
@ -496,7 +496,7 @@ otError Dns::ParseDnsServiceMode(const Arg &aArg, otDnsServiceMode &aMode) const
|
|||
ExitNow();
|
||||
}
|
||||
|
||||
for (uint8_t index = 0; index < OT_ARRAY_LENGTH(kServiceModeStrings); index++)
|
||||
for (size_t index = 0; index < OT_ARRAY_LENGTH(kServiceModeStrings); index++)
|
||||
{
|
||||
if (aArg == kServiceModeStrings[index])
|
||||
{
|
||||
|
|
|
@ -173,7 +173,7 @@ template <> otError MacFilter::Process<Cmd("addr")>(Arg aArgs[])
|
|||
"denylist", // (2) OT_MAC_FILTER_ADDRESS_MODE_DENYLIST
|
||||
};
|
||||
|
||||
for (uint8_t index = 0; index < OT_ARRAY_LENGTH(kModeCommands); index++)
|
||||
for (size_t index = 0; index < OT_ARRAY_LENGTH(kModeCommands); index++)
|
||||
{
|
||||
if (aArgs[0] == kModeCommands[index])
|
||||
{
|
||||
|
|
|
@ -64,7 +64,7 @@ bool JoinerPskd::operator==(const JoinerPskd &aOther) const
|
|||
{
|
||||
bool isEqual = true;
|
||||
|
||||
for (uint8_t i = 0; i < sizeof(m8); i++)
|
||||
for (size_t i = 0; i < sizeof(m8); i++)
|
||||
{
|
||||
if (m8[i] != aOther.m8[i])
|
||||
{
|
||||
|
|
|
@ -340,7 +340,7 @@ Error Server::AppendDiagTlv(uint8_t aTlvType, Message &aMessage)
|
|||
|
||||
tlv.Init();
|
||||
|
||||
for (uint8_t page = 0; page < sizeof(Radio::kSupportedChannelPages) * CHAR_BIT; page++)
|
||||
for (uint8_t page = 0; page < static_cast<uint8_t>(sizeof(Radio::kSupportedChannelPages) * CHAR_BIT); page++)
|
||||
{
|
||||
if (Radio::kSupportedChannelPages & (1 << page))
|
||||
{
|
||||
|
|
|
@ -309,7 +309,7 @@ void TestParsingHexStrings(void)
|
|||
|
||||
for (uint8_t testIter = 0; testIter <= 1; testIter++)
|
||||
{
|
||||
for (uint8_t segmentLen = 1; segmentLen <= sizeof(buffer); segmentLen++)
|
||||
for (size_t segmentLen = 1; segmentLen <= sizeof(buffer); segmentLen++)
|
||||
{
|
||||
if (testIter == 0)
|
||||
{
|
||||
|
@ -324,7 +324,7 @@ void TestParsingHexStrings(void)
|
|||
|
||||
len = segmentLen;
|
||||
|
||||
printf("\"%s\" segLen:%d -> ", string, segmentLen);
|
||||
printf("\"%s\" segLen:%zu -> ", string, segmentLen);
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
|
|
@ -150,7 +150,7 @@ void TestHkdfSha256(void)
|
|||
|
||||
VerifyOrQuit(memcmp(outKey, test->mOutKey, test->mOutKeyLength) == 0, "HKDF-SHA-256 failed");
|
||||
|
||||
for (uint16_t i = test->mOutKeyLength + 1; i < sizeof(outKey); i++)
|
||||
for (size_t i = test->mOutKeyLength + 1; i < sizeof(outKey); i++)
|
||||
{
|
||||
VerifyOrQuit(outKey[i] == kFillByte, "HKDF-SHA-256 wrote beyond output key length");
|
||||
}
|
||||
|
|
|
@ -366,7 +366,7 @@ bool CheckInterfaceId(const ot::Ip6::Address &aAddress1, const ot::Ip6::Address
|
|||
|
||||
bool matches = true;
|
||||
|
||||
for (uint8_t bit = aPrefixLength; bit < sizeof(ot::Ip6::Address) * CHAR_BIT; bit++)
|
||||
for (size_t bit = aPrefixLength; bit < sizeof(ot::Ip6::Address) * CHAR_BIT; bit++)
|
||||
{
|
||||
uint8_t index = bit / CHAR_BIT;
|
||||
uint8_t mask = (0x80 >> (bit % CHAR_BIT));
|
||||
|
@ -403,14 +403,14 @@ void TestIp6AddressSetPrefix(void)
|
|||
memcpy(address.mFields.m8, prefix, sizeof(address));
|
||||
printf("Prefix is %s\n", address.ToString().AsCString());
|
||||
|
||||
for (uint8_t prefixLength = 0; prefixLength <= sizeof(ot::Ip6::Address) * CHAR_BIT; prefixLength++)
|
||||
for (size_t prefixLength = 0; prefixLength <= sizeof(ot::Ip6::Address) * CHAR_BIT; prefixLength++)
|
||||
{
|
||||
ip6Prefix.Clear();
|
||||
ip6Prefix.Set(prefix, prefixLength);
|
||||
|
||||
address = allZeroAddress;
|
||||
address.SetPrefix(ip6Prefix);
|
||||
printf(" prefix-len:%-3d --> %s\n", prefixLength, address.ToString().AsCString());
|
||||
printf(" prefix-len:%-3zu --> %s\n", prefixLength, address.ToString().AsCString());
|
||||
VerifyOrQuit(CheckPrefix(address, prefix, prefixLength), "Prefix does not match after SetPrefix()");
|
||||
VerifyOrQuit(CheckInterfaceId(address, allZeroAddress, prefixLength),
|
||||
"SetPrefix changed bits beyond the prefix length");
|
||||
|
|
|
@ -442,7 +442,7 @@ void TestMacChannelMask(void)
|
|||
VerifyChannelMaskContent(mask1, allChannels, sizeof(allChannels));
|
||||
|
||||
// Test ChannelMask::RemoveChannel()
|
||||
for (uint8_t index = 0; index < sizeof(allChannels) - 1; index++)
|
||||
for (size_t index = 0; index < sizeof(allChannels) - 1; index++)
|
||||
{
|
||||
mask1.RemoveChannel(allChannels[index]);
|
||||
VerifyChannelMaskContent(mask1, &allChannels[index + 1], sizeof(allChannels) - 1 - index);
|
||||
|
|
|
@ -50,7 +50,7 @@ void DumpMessageInHex(const char *prefix, const uint8_t *aBuf, size_t aBufLen)
|
|||
{
|
||||
// This function dumps all packets the output of this function can be imported to packet analyser for debugging.
|
||||
printf("%s", prefix);
|
||||
for (uint16_t i = 0; i < aBufLen; i++)
|
||||
for (size_t i = 0; i < aBufLen; i++)
|
||||
{
|
||||
printf("%02x", aBuf[i]);
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ bool CheckMessage(const Message &aMessage, const uint8_t *aExpectedMessage, size
|
|||
if (!success)
|
||||
{
|
||||
printf("Expected Message\n");
|
||||
for (uint16_t i = 0; i < aExpectedMessageLen; i++)
|
||||
for (size_t i = 0; i < aExpectedMessageLen; i++)
|
||||
{
|
||||
printf("%02x%c", aExpectedMessage[i], " \n"[(i & 0xf) == 0xf]);
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ void test_packed_alignment(void)
|
|||
packedStruct.mByte = 0xfe;
|
||||
packedStruct.mUint16 = 0xabcd;
|
||||
|
||||
for (uint16_t start = 0; start < sizeof(PackedStruct); start++)
|
||||
for (size_t start = 0; start < sizeof(PackedStruct); start++)
|
||||
{
|
||||
uint8_t *ptr = &buffer[start];
|
||||
|
||||
|
@ -140,14 +140,14 @@ void test_packed_alignment(void)
|
|||
|
||||
*reinterpret_cast<PackedStruct *>(ptr) = packedStruct;
|
||||
|
||||
for (uint16_t i = 0; i < start; i++)
|
||||
for (size_t i = 0; i < start; i++)
|
||||
{
|
||||
VerifyOrQuit(buffer[i] == 0, "OT_TOOL_PACKED alignment failed - pre-size write");
|
||||
}
|
||||
|
||||
VerifyOrQuit(memcmp(ptr, packedStructBytes, sizeof(PackedStruct)) == 0, "OT_TOOL_PACKED alignment failed");
|
||||
|
||||
for (uint16_t i = start + sizeof(packedStruct); i < sizeof(buffer); i++)
|
||||
for (size_t i = start + sizeof(packedStruct); i < sizeof(buffer); i++)
|
||||
{
|
||||
VerifyOrQuit(buffer[i] == 0, "OT_TOOL_PACKED alignment failed - post-size write");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user