[ncp] add static assert to check size of changed set entries array (#3571)

This commit is contained in:
Abtin Keshavarzian
2019-02-11 10:50:20 -08:00
committed by Jonathan Hui
parent 7494216415
commit 4219b5bb04
+5
View File
@@ -27,6 +27,8 @@
#include "changed_props_set.hpp"
#include <limits.h>
#include "common/code_utils.hpp"
namespace ot {
@@ -96,6 +98,9 @@ const ChangedPropsSet::Entry ChangedPropsSet::mSupportedProps[] = {
uint8_t ChangedPropsSet::GetNumEntries(void) const
{
OT_STATIC_ASSERT(OT_ARRAY_LENGTH(mSupportedProps) <= sizeof(mChangedSet) * CHAR_BIT,
"Changed set size is smaller than number of entries in `mSupportedProps[]` array");
return OT_ARRAY_LENGTH(mSupportedProps);
}