[settings] add Clear() method for all setting structures (#4315)

This commit is contained in:
Abtin Keshavarzian
2019-12-04 12:42:33 -08:00
committed by Jonathan Hui
parent b5846532fe
commit bf4dae0c18
3 changed files with 21 additions and 3 deletions
+18
View File
@@ -86,6 +86,12 @@ public:
*/
struct NetworkInfo
{
/**
* This method clears the struct object (setting all the fields to zero).
*
*/
void Clear(void) { memset(this, 0, sizeof(*this)); }
uint8_t mRole; ///< Current Thread role.
uint8_t mDeviceMode; ///< Device mode setting.
uint16_t mRloc16; ///< RLOC16
@@ -103,6 +109,12 @@ public:
*/
struct ParentInfo
{
/**
* This method clears the struct object (setting all the fields to zero).
*
*/
void Clear(void) { memset(this, 0, sizeof(*this)); }
Mac::ExtAddress mExtAddress; ///< Extended Address
};
@@ -112,6 +124,12 @@ public:
*/
struct ChildInfo
{
/**
* This method clears the struct object (setting all the fields to zero).
*
*/
void Clear(void) { memset(this, 0, sizeof(*this)); }
Mac::ExtAddress mExtAddress; ///< Extended Address
uint32_t mTimeout; ///< Timeout
uint16_t mRloc16; ///< RLOC16
+2 -2
View File
@@ -447,7 +447,7 @@ otError Mle::Store(void)
otError error = OT_ERROR_NONE;
Settings::NetworkInfo networkInfo;
memset(&networkInfo, 0, sizeof(networkInfo));
networkInfo.Clear();
if (IsAttached())
{
@@ -465,7 +465,7 @@ otError Mle::Store(void)
{
Settings::ParentInfo parentInfo;
memset(&parentInfo, 0, sizeof(parentInfo));
parentInfo.Clear();
parentInfo.mExtAddress = mParent.GetExtAddress();
SuccessOrExit(error = Get<Settings>().SaveParentInfo(parentInfo));
+1 -1
View File
@@ -3571,7 +3571,7 @@ otError MleRouter::StoreChild(const Child &aChild)
IgnoreReturnValue(RemoveStoredChild(aChild.GetRloc16()));
memset(&childInfo, 0, sizeof(childInfo));
childInfo.Clear();
childInfo.mExtAddress = aChild.GetExtAddress();
childInfo.mTimeout = aChild.GetTimeout();
childInfo.mRloc16 = aChild.GetRloc16();