[common] add ClearAllBytes() template function (#9818)

This commit introduces the `ClearAllBytes<ObjectType>()` template
function to zero out all bytes within an object. This replaces
`memset(0)` calls in OT core modules, simplifying code and improving
safety by automatically using the correct object size.
This commit is contained in:
Abtin Keshavarzian
2024-02-01 11:58:47 -08:00
committed by GitHub
parent fffb489b26
commit 686eb30e9a
45 changed files with 136 additions and 107 deletions
+2 -2
View File
@@ -47,7 +47,7 @@ UdpExample::UdpExample(otInstance *aInstance, OutputImplementer &aOutputImplemen
: Output(aInstance, aOutputImplementer)
, mLinkSecurityEnabled(true)
{
memset(&mSocket, 0, sizeof(mSocket));
ClearAllBytes(mSocket);
}
/**
@@ -258,7 +258,7 @@ template <> otError UdpExample::Process<Cmd("send")>(Arg aArgs[])
otMessageInfo messageInfo;
otMessageSettings messageSettings = {mLinkSecurityEnabled, OT_MESSAGE_PRIORITY_NORMAL};
memset(&messageInfo, 0, sizeof(messageInfo));
ClearAllBytes(messageInfo);
// Possible argument formats:
//