Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit c63e5a1

Browse files
authored
Merge pull request #423 from anqid-g/pr/default-ctor-assign
Use default-construct and assign for some variables
2 parents deba689 + fb37b42 commit c63e5a1

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

src/lib/core/WeaveExchangeMgr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ ExchangeContext *WeaveExchangeManager::AllocContext()
557557
for (int i = 0; i < WEAVE_CONFIG_MAX_EXCHANGE_CONTEXTS; i++, ec++)
558558
if (ec->ExchangeMgr == NULL)
559559
{
560-
memset(ec, 0, sizeof(ExchangeContext));
560+
*ec = ExchangeContext();
561561
ec->ExchangeMgr = this;
562562
ec->mRefCount = 1;
563563
mContextsInUse++;

src/lib/profiles/data-management/Current/LoggingManagement.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1586,7 +1586,7 @@ WEAVE_ERROR LoggingManagement::FetchEventParameters(const TLVReader & aReader, s
15861586
if ((reader.GetTag() == nl::Weave::TLV::ContextTag(kTag_ExternalEventStructure)) && (envelope->mExternalEvents != NULL))
15871587
{
15881588
err = reader.GetBytes(static_cast<uint8_t *>(static_cast<void *>(envelope->mExternalEvents)), sizeof(ExternalEvents));
1589-
VerifyOrExit(err == WEAVE_NO_ERROR, memset(envelope->mExternalEvents, 0, sizeof(ExternalEvents)));
1589+
VerifyOrExit(err == WEAVE_NO_ERROR, *(envelope->mExternalEvents) = ExternalEvents());
15901590
envelope->mNumFieldsToRead--;
15911591
}
15921592

src/lib/profiles/device-description/DeviceDescription.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ WEAVE_ERROR IdentifyRequestMessage::Decode(PacketBuffer *msgBuf, uint64_t msgDes
10771077

10781078
VerifyOrExit(msgBuf->DataLength() == 16, err = WEAVE_ERROR_INVALID_MESSAGE_LENGTH);
10791079

1080-
memset(&msg, 0, sizeof(msg));
1080+
msg = IdentifyRequestMessage();
10811081
p = msgBuf->Start();
10821082
msg.TargetFabricId = LittleEndian::Read64(p);
10831083
msg.TargetModes = LittleEndian::Read32(p);

src/lib/profiles/weave-tunneling/WeaveTunnelConnectionMgr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ void WeaveTunnelConnectionMgr::HandleServiceConnectionComplete(WeaveConnection *
741741

742742
// Create tunnel route for Service and send Tunnel control message.
743743

744-
memset(&tunRoute, 0, sizeof(tunRoute));
744+
tunRoute = WeaveTunnelRoute();
745745
globalId = WeaveFabricIdToIPv6GlobalId(tConnMgr->mTunAgent->mExchangeMgr->FabricState->FabricId);
746746
if (tConnMgr->mTunAgent->mRole == kClientRole_BorderGateway)
747747
{

src/ra-daemon/RADaemon.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ void RADaemon::DelPrefixInfo(InterfaceId link, IPPrefix ipPrefix)
629629
currIPPrefixInfo = &currLinkInfo->IPPrefixInfo[k];
630630
if (currIPPrefixInfo->IPPrefx == ipPrefix)
631631
{
632-
memset(&currIPPrefixInfo->IPPrefx, 0, sizeof(IPPrefix));
632+
currIPPrefixInfo->IPPrefx = IPPrefix();
633633
prefix_removed = 1;
634634
num_free_prefixes++;
635635
}
@@ -672,7 +672,7 @@ void RADaemon::DelLinkInfo(InterfaceId link)
672672
currLinkInfo->RawEP = NULL;
673673
SystemLayer->CancelTimer(MulticastPeriodicRA, currLinkInfo);
674674
SystemLayer->CancelTimer(TrackRSes, currLinkInfo);
675-
memset(currLinkInfo, 0, sizeof(RADaemon::LinkInformation));
675+
*currLinkInfo = RADaemon::LinkInformation();
676676
currLinkInfo->Self = this;
677677
break;
678678
}

0 commit comments

Comments
 (0)