mirror of
https://github.com/espressif/openthread.git
synced 2026-07-29 23:27:46 +00:00
[settings] add Clear() method for all setting structures (#4315)
This commit is contained in:
committed by
Jonathan Hui
parent
b5846532fe
commit
bf4dae0c18
@@ -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
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user