[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
@@ -219,7 +219,7 @@ template <> otError TcpExample::Process<Cmd("init")>(Arg aArgs[])
{
otTcpEndpointInitializeArgs endpointArgs;
memset(&endpointArgs, 0x00, sizeof(endpointArgs));
ClearAllBytes(endpointArgs);
endpointArgs.mEstablishedCallback = HandleTcpEstablishedCallback;
if (mUseCircularSendBuffer)
{
@@ -241,7 +241,7 @@ template <> otError TcpExample::Process<Cmd("init")>(Arg aArgs[])
{
otTcpListenerInitializeArgs listenerArgs;
memset(&listenerArgs, 0x00, sizeof(listenerArgs));
ClearAllBytes(listenerArgs);
listenerArgs.mAcceptReadyCallback = HandleTcpAcceptReadyCallback;
listenerArgs.mAcceptDoneCallback = HandleTcpAcceptDoneCallback;
listenerArgs.mContext = this;