Skip to content

Commit e493889

Browse files
nodiscard ChipError Batch project-chip#24: platform-specific src: linux, nrfconnect,… (project-chip#42087)
* Batch project-chip#24 nodiscard errors: platform-specific src: linux, nrfconnect, nuttx, nxp * Apply suggestions from code review Co-authored-by: Junior Martinez <[email protected]> --------- Co-authored-by: Junior Martinez <[email protected]>
1 parent 1c69cb1 commit e493889

29 files changed

+119
-103
lines changed

src/platform/Linux/DnssdImpl.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ void Poller::WatchFree(AvahiWatch * watch)
217217

218218
void Poller::WatchFree(AvahiWatch & watch)
219219
{
220-
DeviceLayer::SystemLayerSockets().StopWatchingSocket(&watch.mSocketWatch);
220+
TEMPORARY_RETURN_IGNORED DeviceLayer::SystemLayerSockets().StopWatchingSocket(&watch.mSocketWatch);
221221
mWatches.erase(std::remove_if(mWatches.begin(), mWatches.end(),
222222
[&watch](const std::unique_ptr<AvahiWatch> & aValue) { return aValue.get() == &watch; }),
223223
mWatches.end());
@@ -320,7 +320,7 @@ void Poller::SystemTimerUpdate(AvahiTimeout * timer)
320320
{
321321
mEarliestTimeout = timer->mAbsTimeout;
322322
auto delay = std::chrono::duration_cast<chip::System::Clock::Milliseconds32>(steady_clock::now() - mEarliestTimeout);
323-
DeviceLayer::SystemLayer().StartTimer(delay, SystemTimerCallback, this);
323+
TEMPORARY_RETURN_IGNORED DeviceLayer::SystemLayer().StartTimer(delay, SystemTimerCallback, this);
324324
}
325325
}
326326

@@ -347,7 +347,7 @@ CHIP_ERROR MdnsAvahi::Init(DnssdAsyncReturnCallback initCallback, DnssdAsyncRetu
347347

348348
void MdnsAvahi::Shutdown()
349349
{
350-
StopPublish();
350+
TEMPORARY_RETURN_IGNORED StopPublish();
351351
if (mClient)
352352
{
353353
avahi_client_free(mClient);
@@ -389,7 +389,7 @@ void MdnsAvahi::HandleClientState(AvahiClient * client, AvahiClientState state)
389389
case AVAHI_CLIENT_S_COLLISION:
390390
case AVAHI_CLIENT_S_REGISTERING:
391391
ChipLogProgress(DeviceLayer, "Avahi re-register required");
392-
StopPublish();
392+
TEMPORARY_RETURN_IGNORED StopPublish();
393393
mErrorCallback(mAsyncReturnContext, CHIP_ERROR_FORCED_RESET);
394394
break;
395395
case AVAHI_CLIENT_CONNECTING:

src/platform/NuttX/CHIPLinuxStorage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ CHIP_ERROR ChipLinuxStorage::WriteValueBin(const char * key, const uint8_t * dat
264264
// Store it
265265
if (retval == CHIP_NO_ERROR)
266266
{
267-
WriteValueStr(key, encodedData.Get());
267+
return WriteValueStr(key, encodedData.Get());
268268
}
269269

270270
return retval;

src/platform/NuttX/ConfigurationManagerImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ bool ConfigurationManagerImpl::CanFactoryReset()
179179

180180
void ConfigurationManagerImpl::InitiateFactoryReset()
181181
{
182-
PlatformMgr().ScheduleWork(DoFactoryReset);
182+
TEMPORARY_RETURN_IGNORED PlatformMgr().ScheduleWork(DoFactoryReset);
183183
}
184184

185185
CHIP_ERROR ConfigurationManagerImpl::ReadPersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t & value)

src/platform/NuttX/NetworkCommissioningEthernetDriver.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ namespace NetworkCommissioning {
3333
NetworkIterator * LinuxEthernetDriver::GetNetworks()
3434
{
3535
auto ret = new EthernetNetworkIterator();
36-
ConnectivityUtils::GetEthInterfaceName(SafePointerCast<char *>(ret->interfaceName), sizeof(ret->interfaceName));
36+
TEMPORARY_RETURN_IGNORED ConnectivityUtils::GetEthInterfaceName(SafePointerCast<char *>(ret->interfaceName),
37+
sizeof(ret->interfaceName));
3738
ret->interfaceNameLen = static_cast<uint8_t>(strnlen(SafePointerCast<char *>(ret->interfaceName), sizeof(ret->interfaceName)));
3839
return ret;
3940
}

src/platform/NuttX/PlatformManagerImpl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@ void PlatformManagerImpl::_Shutdown()
259259

260260
if (ConfigurationMgr().GetTotalOperationalHours(totalOperationalHours) == CHIP_NO_ERROR)
261261
{
262-
ConfigurationMgr().StoreTotalOperationalHours(totalOperationalHours + static_cast<uint32_t>(upTime / 3600));
262+
TEMPORARY_RETURN_IGNORED ConfigurationMgr().StoreTotalOperationalHours(totalOperationalHours +
263+
static_cast<uint32_t>(upTime / 3600));
263264
}
264265
else
265266
{

src/platform/nrfconnect/OTAImageProcessorImpl.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ CHIP_ERROR OTAImageProcessorImpl::PrepareDownload()
8080
CHIP_ERROR err = PrepareDownloadImpl();
8181
if (err != CHIP_NO_ERROR)
8282
{
83-
DFUSync::GetInstance().Free(mDfuSyncMutexId);
83+
TEMPORARY_RETURN_IGNORED DFUSync::GetInstance().Free(mDfuSyncMutexId);
8484
}
85-
mDownloader->OnPreparedForDownload(err);
85+
TEMPORARY_RETURN_IGNORED mDownloader->OnPreparedForDownload(err);
8686
});
8787
}
8888

@@ -127,15 +127,15 @@ CHIP_ERROR OTAImageProcessorImpl::PrepareDownloadImpl()
127127
CHIP_ERROR OTAImageProcessorImpl::Finalize()
128128
{
129129
PostOTAStateChangeEvent(DeviceLayer::kOtaDownloadComplete);
130-
DFUSync::GetInstance().Free(mDfuSyncMutexId);
130+
TEMPORARY_RETURN_IGNORED DFUSync::GetInstance().Free(mDfuSyncMutexId);
131131
return System::MapErrorZephyr(dfu_multi_image_done(true));
132132
}
133133

134134
CHIP_ERROR OTAImageProcessorImpl::Abort()
135135
{
136136
CHIP_ERROR error = System::MapErrorZephyr(dfu_multi_image_done(false));
137137

138-
DFUSync::GetInstance().Free(mDfuSyncMutexId);
138+
TEMPORARY_RETURN_IGNORED DFUSync::GetInstance().Free(mDfuSyncMutexId);
139139
TriggerFlashAction(ExternalFlashManager::Action::SLEEP);
140140
PostOTAStateChangeEvent(DeviceLayer::kOtaDownloadAborted);
141141

@@ -199,7 +199,7 @@ CHIP_ERROR OTAImageProcessorImpl::ProcessBlock(ByteSpan & aBlock)
199199
{
200200
ChipLogDetail(SoftwareUpdate, "Downloaded %u/%u bytes", static_cast<unsigned>(mParams.downloadedBytes),
201201
static_cast<unsigned>(mParams.totalFileBytes));
202-
mDownloader->FetchNextData();
202+
TEMPORARY_RETURN_IGNORED mDownloader->FetchNextData();
203203
}
204204
else
205205
{

src/platform/nxp/common/ConfigurationManagerImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ bool ConfigurationManagerImpl::CanFactoryReset()
217217

218218
void ConfigurationManagerImpl::InitiateFactoryReset()
219219
{
220-
PlatformMgr().ScheduleWork(DoFactoryReset);
220+
TEMPORARY_RETURN_IGNORED PlatformMgr().ScheduleWork(DoFactoryReset);
221221
}
222222

223223
CHIP_ERROR ConfigurationManagerImpl::ReadPersistedStorageValue(::chip::Platform::PersistedStorage::Key persistedStorageKey,

src/platform/nxp/common/ConnectivityManagerImpl.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ void ConnectivityManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event)
168168
}
169169
else if (event->Type == kPlatformNxpStartWlanInitWaitTimerEvent)
170170
{
171-
DeviceLayer::SystemLayer().StartTimer(System::Clock::Milliseconds32(kWlanInitWaitMs), ConnectNetworkTimerHandler,
172-
(void *) event->Platform.pNetworkDataEvent);
171+
TEMPORARY_RETURN_IGNORED DeviceLayer::SystemLayer().StartTimer(
172+
System::Clock::Milliseconds32(kWlanInitWaitMs), ConnectNetworkTimerHandler, (void *) event->Platform.pNetworkDataEvent);
173173
}
174174
else if (event->Type == DeviceLayer::DeviceEventType::kFailSafeTimerExpired)
175175
{
@@ -471,7 +471,7 @@ void ConnectivityManagerImpl::ProcessWlanEvent(enum wlan_event_reason wlanEvent)
471471
*/
472472
if (mWiFiStationState == kWiFiStationState_Connecting_Failed)
473473
{
474-
NetworkCommissioning::NXPWiFiDriver::GetInstance().RevertConfiguration();
474+
TEMPORARY_RETURN_IGNORED NetworkCommissioning::NXPWiFiDriver::GetInstance().RevertConfiguration();
475475
mWifiIsProvisioned = false;
476476
}
477477
sInstance._SetWiFiStationState(kWiFiStationState_NotConnected);
@@ -484,7 +484,7 @@ void ConnectivityManagerImpl::ProcessWlanEvent(enum wlan_event_reason wlanEvent)
484484

485485
case WLAN_REASON_INITIALIZED:
486486
sInstance._SetWiFiStationState(kWiFiStationState_NotConnected);
487-
sInstance._SetWiFiStationMode(kWiFiStationMode_Enabled);
487+
TEMPORARY_RETURN_IGNORED sInstance._SetWiFiStationMode(kWiFiStationMode_Enabled);
488488
if (mIsWifiRecovering)
489489
{
490490
/*
@@ -636,8 +636,8 @@ void ConnectivityManagerImpl::BrHandleStateChange()
636636
mThreadNetIf = tmpThrIf;
637637
mBorderRouterInit = true;
638638

639-
DeviceLayer::ConfigurationMgr().GetPrimaryMACAddress(mac);
640-
chip::Dnssd::MakeHostName(mHostname, sizeof(mHostname), mac);
639+
TEMPORARY_RETURN_IGNORED DeviceLayer::ConfigurationMgr().GetPrimaryMACAddress(mac);
640+
TEMPORARY_RETURN_IGNORED chip::Dnssd::MakeHostName(mHostname, sizeof(mHostname), mac);
641641

642642
BrInitAppLock(LockThreadStack, UnlockThreadStack);
643643
BrInitPlatform(ThreadStackMgrImpl().OTInstance(), extNetIfPtr, thrNetIfPtr);

src/platform/nxp/common/DiagnosticDataProviderImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface **
233233
ifp->offPremiseServicesReachableIPv4.SetNull();
234234
ifp->offPremiseServicesReachableIPv6.SetNull();
235235
ifp->type = app::Clusters::GeneralDiagnostics::InterfaceTypeEnum::kThread;
236-
ConfigurationMgr().GetPrimary802154MACAddress(ifp->MacAddress);
236+
TEMPORARY_RETURN_IGNORED ConfigurationMgr().GetPrimary802154MACAddress(ifp->MacAddress);
237237
ifp->hardwareAddress = ByteSpan(ifp->MacAddress, kMaxHardwareAddrSize);
238238
#elif CHIP_DEVICE_CONFIG_ENABLE_WPA
239239
struct netif * netif = nullptr;

src/platform/nxp/common/DnssdImplBr.cpp

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,8 @@ CHIP_ERROR NxpChipDnssdBrowse(const char * type, DnssdServiceProtocol protocol,
464464
// browse results coming but the result is no error since we have a match in the SRP cache.
465465
error = CHIP_NO_ERROR;
466466
pBrowseContext->error = CHIP_NO_ERROR;
467-
DeviceLayer::PlatformMgr().ScheduleWork(DispatchBrowseEmpty, reinterpret_cast<intptr_t>(pBrowseContext));
467+
TEMPORARY_RETURN_IGNORED DeviceLayer::PlatformMgr().ScheduleWork(DispatchBrowseEmpty,
468+
reinterpret_cast<intptr_t>(pBrowseContext));
468469
}
469470
else
470471
{
@@ -583,7 +584,8 @@ CHIP_ERROR BrowseBySrp(otInstance * thrInstancePtr, char * serviceName, mDnsQuer
583584
{
584585
// Set error to CHIP_NO_ERROR to signal that there was at least one service found in the cache
585586
error = CHIP_NO_ERROR;
586-
DeviceLayer::PlatformMgr().ScheduleWork(DispatchBrowse, reinterpret_cast<intptr_t>(serviceContext));
587+
TEMPORARY_RETURN_IGNORED DeviceLayer::PlatformMgr().ScheduleWork(
588+
DispatchBrowse, reinterpret_cast<intptr_t>(serviceContext));
587589
}
588590
else
589591
{
@@ -613,7 +615,8 @@ CHIP_ERROR ResolveBySrp(otInstance * thrInstancePtr, char * serviceName, mDnsQue
613615
error = FromSrpCacheToMdnsData(service, host, mdnsReq, context->mMdnsService, context->mServiceTxtEntry);
614616
if (error == CHIP_NO_ERROR)
615617
{
616-
DeviceLayer::PlatformMgr().ScheduleWork(DispatchResolveSrp, reinterpret_cast<intptr_t>(context));
618+
TEMPORARY_RETURN_IGNORED DeviceLayer::PlatformMgr().ScheduleWork(DispatchResolveSrp,
619+
reinterpret_cast<intptr_t>(context));
617620
}
618621
break;
619622
}
@@ -809,7 +812,7 @@ static void OtBrowseCallback(otInstance * aInstance, const otMdnsBrowseResult *
809812

810813
if (CHIP_NO_ERROR == error)
811814
{
812-
DeviceLayer::PlatformMgr().ScheduleWork(DispatchBrowse, reinterpret_cast<intptr_t>(tmpContext));
815+
TEMPORARY_RETURN_IGNORED DeviceLayer::PlatformMgr().ScheduleWork(DispatchBrowse, reinterpret_cast<intptr_t>(tmpContext));
813816
}
814817
else
815818
{
@@ -840,7 +843,8 @@ static void OtServiceCallback(otInstance * aInstance, const otMdnsSrvResult * aR
840843

841844
pResolveContext->mMdnsService.mPort = aResult->mPort;
842845
pResolveContext->mMdnsService.mTtlSeconds = aResult->mTtl;
843-
DeviceLayer::PlatformMgr().ScheduleWork(DispatchTxtResolve, reinterpret_cast<intptr_t>(pResolveContext));
846+
TEMPORARY_RETURN_IGNORED DeviceLayer::PlatformMgr().ScheduleWork(DispatchTxtResolve,
847+
reinterpret_cast<intptr_t>(pResolveContext));
844848
}
845849
else
846850
{
@@ -898,7 +902,8 @@ static void OtTxtCallback(otInstance * aInstance, const otMdnsTxtResult * aResul
898902

899903
if (bSendDispatch)
900904
{
901-
DeviceLayer::PlatformMgr().ScheduleWork(DispatchAddressResolve, reinterpret_cast<intptr_t>(pResolveContext));
905+
TEMPORARY_RETURN_IGNORED DeviceLayer::PlatformMgr().ScheduleWork(DispatchAddressResolve,
906+
reinterpret_cast<intptr_t>(pResolveContext));
902907
}
903908
else
904909
{
@@ -917,7 +922,7 @@ static void OtAddressCallback(otInstance * aInstance, const otMdnsAddressResult
917922
pResolveContext->mMdnsService.mAddressType = Inet::IPAddressType::kIPv6;
918923
pResolveContext->mMdnsService.mAddress = std::optional(ToIPAddress(aResult->mAddresses[0].mAddress));
919924

920-
DeviceLayer::PlatformMgr().ScheduleWork(DispatchResolve, reinterpret_cast<intptr_t>(pResolveContext));
925+
TEMPORARY_RETURN_IGNORED DeviceLayer::PlatformMgr().ScheduleWork(DispatchResolve, reinterpret_cast<intptr_t>(pResolveContext));
921926
}
922927

923928
static void DispatchBrowseEmpty(intptr_t context)
@@ -951,7 +956,8 @@ static void DispatchTxtResolve(intptr_t context)
951956
if (error != OT_ERROR_NONE)
952957
{
953958
resolveContext->error = MapOpenThreadError(error);
954-
DeviceLayer::PlatformMgr().ScheduleWork(DispatchResolveError, reinterpret_cast<intptr_t>(resolveContext));
959+
TEMPORARY_RETURN_IGNORED DeviceLayer::PlatformMgr().ScheduleWork(DispatchResolveError,
960+
reinterpret_cast<intptr_t>(resolveContext));
955961
}
956962
}
957963

@@ -970,7 +976,8 @@ static void DispatchAddressResolve(intptr_t context)
970976
if (error != OT_ERROR_NONE)
971977
{
972978
resolveContext->error = MapOpenThreadError(error);
973-
DeviceLayer::PlatformMgr().ScheduleWork(DispatchResolveError, reinterpret_cast<intptr_t>(resolveContext));
979+
TEMPORARY_RETURN_IGNORED DeviceLayer::PlatformMgr().ScheduleWork(DispatchResolveError,
980+
reinterpret_cast<intptr_t>(resolveContext));
974981
}
975982
}
976983

@@ -1048,7 +1055,8 @@ static void HandleResolveCleanup(mDnsQueryCtx & resolveContext, ResolveStep step
10481055
// DispatchResolveError to handle the Matter callback with an error case. No IP address is reported and
10491056
// the address resolve operation doesn’t need to be stopped again as was not started in the first place
10501057
// or it's already handled by HandleResolveCleanup.
1051-
DeviceLayer::PlatformMgr().ScheduleWork(DispatchResolveError, reinterpret_cast<intptr_t>(&resolveContext));
1058+
TEMPORARY_RETURN_IGNORED DeviceLayer::PlatformMgr().ScheduleWork(DispatchResolveError,
1059+
reinterpret_cast<intptr_t>(&resolveContext));
10521060
}
10531061

10541062
static mDnsQueryCtx * GetResolveElement(const char * aName, NameType aType)

0 commit comments

Comments
 (0)