[code-utils] adding helper macro OT_ARRAY_LENGTH() (#2743)

This commit adds helper macro `OT_ARRAY_LENGTH()` to get the number
of elements in an array.
This commit is contained in:
Abtin Keshavarzian
2018-05-29 15:53:53 -07:00
committed by Jonathan Hui
parent ae7984d3a7
commit 2abd7a2822
16 changed files with 61 additions and 61 deletions
+4 -3
View File
@@ -32,6 +32,7 @@
#include <openthread/openthread.h>
#include "test_util.h"
#include "common/code_utils.hpp"
#include "common/instance.hpp"
#include "thread/child_table.hpp"
@@ -109,7 +110,7 @@ void VerifyChildTableContent(ChildTable &aTable, uint8_t aChildListLength, const
{
printf("Test ChildTable with %d entries", aChildListLength);
for (uint8_t k = 0; k < sizeof(kAllFilters) / sizeof(kAllFilters[0]); k++)
for (uint8_t k = 0; k < OT_ARRAY_LENGTH(kAllFilters); k++)
{
ChildTable::StateFilter filter = kAllFilters[k];
@@ -296,7 +297,7 @@ void TestChildTable(void)
},
};
const uint8_t testListLength = sizeof(testChildList) / sizeof(testChildList[0]);
const uint8_t testListLength = OT_ARRAY_LENGTH(testChildList);
uint8_t testNumAllowedChildren = 2;
@@ -314,7 +315,7 @@ void TestChildTable(void)
VerifyOrQuit(table->GetMaxChildrenAllowed() == table->GetMaxChildren(),
"GetMaxChildrenAllowed() initial value is incorrect ");
for (uint8_t i = 0; i < sizeof(kAllFilters) / sizeof(kAllFilters[0]); i++)
for (uint8_t i = 0; i < OT_ARRAY_LENGTH(kAllFilters); i++)
{
ChildTable::StateFilter filter = kAllFilters[i];