Skip to content

Commit e123d28

Browse files
authored
nodiscard ChipError Batch project-chip#3: example apps J-Z (project-chip#41861)
* Batch project-chip#3 nodiscard errors: example apps J-Z * Fix CI * Clang tidy * Apply review suggestion
1 parent a951d78 commit e123d28

File tree

61 files changed

+291
-249
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+291
-249
lines changed

examples/jf-admin-app/linux/JFAManager.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,11 @@ void JFAManager::OnConnected(void * context, Messaging::ExchangeManager & exchan
194194
switch (jfaManager->mOnConnectedAction)
195195
{
196196
case kStandardCommissioningComplete: {
197-
jfaManager->SendCommissioningComplete();
197+
TEMPORARY_RETURN_IGNORED jfaManager->SendCommissioningComplete();
198198
break;
199199
}
200200
case kJCMCommissioning: {
201-
jfaManager->AnnounceJointFabricAdministrator();
201+
TEMPORARY_RETURN_IGNORED jfaManager->AnnounceJointFabricAdministrator();
202202
break;
203203
}
204204

@@ -243,7 +243,7 @@ void JFAManager::OnAnnounceJointFabricAdministratorResponse(void * context, cons
243243
ChipLogProgress(JointFabric, "OnAnnounceJointFabricAdministratorResponse");
244244

245245
/* TODO: https://github.com/project-chip/connectedhomeip/issues/38202 */
246-
jfaManagerCore->SendICACSRRequest();
246+
TEMPORARY_RETURN_IGNORED jfaManagerCore->SendICACSRRequest();
247247
}
248248

249249
void JFAManager::OnAnnounceJointFabricAdministratorFailure(void * context, CHIP_ERROR error)
@@ -282,7 +282,7 @@ void JFAManager::OnSendICACSRRequestResponse(void * context, const Commands::ICA
282282
jfaManagerCore->peerAdminICACPubKey.Matches(pubKey))
283283
{
284284
ChipLogProgress(JointFabric, "OnSendICACSRRequestResponse: validated ICAC CSR");
285-
jfaManagerCore->SendCommissioningComplete();
285+
TEMPORARY_RETURN_IGNORED jfaManagerCore->SendCommissioningComplete();
286286
}
287287
}
288288

examples/jf-admin-app/linux/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ void ApplicationInit()
9999
SetDeviceInstanceInfoProvider(&gExampleDeviceInstanceInfoProvider);
100100
}
101101

102-
JFAMgr().Init(Server::GetInstance());
103-
JFADSync().Init(Server::GetInstance());
102+
SuccessOrDie(JFAMgr().Init(Server::GetInstance()));
103+
SuccessOrDie(JFADSync().Init(Server::GetInstance()));
104104
Server::GetInstance().GetJointFabricAdministrator().SetDelegate(&JFAMgr());
105105
Server::GetInstance().GetJointFabricDatastore().SetDelegate(&JFADSync());
106106

107-
PlatformMgrImpl().AddEventHandler(EventHandler, 0);
107+
SuccessOrDie(PlatformMgrImpl().AddEventHandler(EventHandler, 0));
108108
}
109109

110110
void ApplicationShutdown() {}

examples/jf-admin-app/linux/rpc/RpcServer.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ ::pw::Status JointFabric::TransferOwnership(const ::OwnershipContext & request,
3636
request.node_id, request.jcm, ByteSpan(request.trustedIcacPublicKeyB.bytes, request.trustedIcacPublicKeyB.size),
3737
request.peerAdminJFAdminClusterEndpointId);
3838
VerifyOrReturnValue(data, pw::Status::Internal());
39-
DeviceLayer::PlatformMgr().ScheduleWork(FinalizeCommissioningWork, reinterpret_cast<intptr_t>(data));
39+
TEMPORARY_RETURN_IGNORED DeviceLayer::PlatformMgr().ScheduleWork(FinalizeCommissioningWork, reinterpret_cast<intptr_t>(data));
4040

4141
return pw::OkStatus();
4242
}
@@ -53,7 +53,8 @@ ::pw::Status JointFabric::ResponseStream(const ::Response & ICACCSRBytes, ::pw_p
5353
{
5454
ChipLogProgress(JointFabric, "RPC ReplyWithICACCSR");
5555

56-
CopySpanToMutableSpan(ByteSpan(ICACCSRBytes.response_bytes.bytes, ICACCSRBytes.response_bytes.size), icacCSRSpan);
56+
TEMPORARY_RETURN_IGNORED CopySpanToMutableSpan(ByteSpan(ICACCSRBytes.response_bytes.bytes, ICACCSRBytes.response_bytes.size),
57+
icacCSRSpan);
5758

5859
responseReceived = true;
5960
responseCv.notify_one();
@@ -80,7 +81,7 @@ CHIP_ERROR JointFabric::GetICACCSRForJF(MutableByteSpan & icacCSR)
8081
// wait for the ICAC CSR from JFC
8182
if (responseCv.wait_for(lock, std::chrono::milliseconds(kRpcTimeoutMs), [] { return responseReceived; }))
8283
{
83-
CopySpanToMutableSpan(ByteSpan(icacCSRSpan.data(), icacCSRSpan.size()), icacCSR);
84+
ReturnErrorOnFailure(CopySpanToMutableSpan(ByteSpan(icacCSRSpan.data(), icacCSRSpan.size()), icacCSR));
8485
responseReceived = false;
8586

8687
return CHIP_NO_ERROR;

examples/jf-control-app/commands/common/CHIPCommand.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ CHIP_ERROR CHIPCommand::InitializeCommissioner(CommissionerIdentity & identity,
482482
#if CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY
483483
VerifyOrReturnError(chip::CanCastTo<uint16_t>(CHIP_UDC_PORT + fabricId), CHIP_ERROR_INVALID_ARGUMENT);
484484
uint16_t udcListenPort = static_cast<uint16_t>(CHIP_UDC_PORT + fabricId);
485-
deviceCommissioner->SetUdcListenPort(udcListenPort);
485+
ReturnLogErrorOnFailure(deviceCommissioner->SetUdcListenPort(udcListenPort));
486486
#endif // CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY
487487
chip::Controller::SetupParams commissionerParams;
488488
chip::CASEAuthTag administratorCAT = chip::GetAdminCATWithVersion(CHIP_CONFIG_ADMINISTRATOR_CAT_INITIAL_VERSION);
@@ -508,7 +508,7 @@ CHIP_ERROR CHIPCommand::InitializeCommissioner(CommissionerIdentity & identity,
508508
ReturnLogErrorOnFailure(mCredIssuerCmds->InitializeCredentialsIssuer(mCommissionerStorage));
509509

510510
/* a NOC with Administrator CAT will be issued to JFC */
511-
mCommissionerStorage.SetCommissionerCATs({ { administratorCAT } });
511+
ReturnLogErrorOnFailure(mCommissionerStorage.SetCommissionerCATs({ { administratorCAT } }));
512512

513513
chip::MutableByteSpan nocSpan(identity.mNOC);
514514
chip::MutableByteSpan icacSpan(identity.mICAC);
@@ -557,7 +557,7 @@ CHIP_ERROR CHIPCommand::InitializeCommissioner(CommissionerIdentity & identity,
557557
chip::Credentials::SetSingleIpkEpochKey(&sGroupDataProvider, fabricIndex, defaultIpk, compressed_fabric_id_span));
558558
}
559559

560-
CHIPCommand::sICDClientStorage.UpdateFabricList(deviceCommissioner->GetFabricIndex());
560+
ReturnLogErrorOnFailure(CHIPCommand::sICDClientStorage.UpdateFabricList(deviceCommissioner->GetFabricIndex()));
561561

562562
mCommissioners[identity] = std::move(deviceCommissioner);
563563

examples/jf-control-app/commands/example/ExampleOperationalCredentialsIssuer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ CHIP_ERROR ExampleOperationalCredentialsIssuer::Initialize(PersistentStorageDele
179179

180180
PERSISTENT_KEY_OP(mIndex, kOperationalCredentialsIssuerKeypairStorage, key,
181181
err = storage.SyncGetKeyValue(key, serializedKey.Bytes(), keySize));
182-
serializedKey.SetLength(keySize);
182+
err = (err == CHIP_NO_ERROR) ? serializedKey.SetLength(keySize) : err;
183183
}
184184

185185
if (err != CHIP_NO_ERROR)
@@ -205,7 +205,7 @@ CHIP_ERROR ExampleOperationalCredentialsIssuer::Initialize(PersistentStorageDele
205205

206206
PERSISTENT_KEY_OP(mIndex, kOperationalCredentialsIntermediateIssuerKeypairStorage, key,
207207
err = storage.SyncGetKeyValue(key, serializedKey.Bytes(), keySize));
208-
serializedKey.SetLength(keySize);
208+
err = (err == CHIP_NO_ERROR) ? serializedKey.SetLength(keySize) : err;
209209
}
210210

211211
if (err != CHIP_NO_ERROR)
@@ -232,7 +232,7 @@ CHIP_ERROR ExampleOperationalCredentialsIssuer::Initialize(PersistentStorageDele
232232

233233
PERSISTENT_KEY_OP(mIndex, kOperationalCredentialsAnchorIntermediateIssuerKeypairStorage, key,
234234
err = storage.SyncGetKeyValue(key, serializedKey.Bytes(), keySize));
235-
serializedKey.SetLength(keySize);
235+
err = (err == CHIP_NO_ERROR) ? serializedKey.SetLength(keySize) : err;
236236
}
237237

238238
if (err != CHIP_NO_ERROR)
@@ -417,7 +417,7 @@ ExampleOperationalCredentialsIssuer::GenerateNOCChain(const ByteSpan & csrElemen
417417
ReturnErrorOnFailure(reader.Next(kTLVType_ByteString, TLV::ContextTag(1)));
418418

419419
ByteSpan csr(reader.GetReadPoint(), reader.GetLength());
420-
reader.ExitContainer(containerType);
420+
ReturnErrorOnFailure(reader.ExitContainer(containerType));
421421

422422
P256PublicKey pubkey;
423423
ReturnErrorOnFailure(VerifyCertificateSigningRequest(csr.data(), csr.size(), pubkey));

examples/jf-control-app/commands/pairing/PairingCommand.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,8 @@ CommissioningParameters PairingCommand::GetCommissioningParameters()
286286

287287
if (!mICDSymmetricKey.HasValue())
288288
{
289-
Crypto::DRBG_get_bytes(mRandomGeneratedICDSymmetricKey, sizeof(mRandomGeneratedICDSymmetricKey));
289+
TEMPORARY_RETURN_IGNORED Crypto::DRBG_get_bytes(mRandomGeneratedICDSymmetricKey,
290+
sizeof(mRandomGeneratedICDSymmetricKey));
290291
mICDSymmetricKey.SetValue(ByteSpan(mRandomGeneratedICDSymmetricKey));
291292
}
292293
if (!mICDCheckInNodeId.HasValue())
@@ -659,7 +660,7 @@ void OnGetStreamOnNext(const RequestOptions & requestOptions)
659660

660661
if (options)
661662
{
662-
DeviceLayer::PlatformMgr().ScheduleWork(GenerateReplyWork, reinterpret_cast<intptr_t>(options));
663+
TEMPORARY_RETURN_IGNORED DeviceLayer::PlatformMgr().ScheduleWork(GenerateReplyWork, reinterpret_cast<intptr_t>(options));
663664
}
664665
}
665666

@@ -684,7 +685,7 @@ void PairingCommand::OnCommissioningComplete(NodeId nodeId, CHIP_ERROR err)
684685
if (!mSkipCommissioningComplete.ValueOr(false))
685686
{
686687
ChipLogProgress(JointFabric, "Anchor Administrator (nodeId=%ld) commissioned with success", nodeId);
687-
SetAnchorNodeId(nodeId);
688+
TEMPORARY_RETURN_IGNORED SetAnchorNodeId(nodeId);
688689

689690
_pw_protobuf_Empty request;
690691

@@ -796,8 +797,9 @@ void PairingCommand::OnICDRegistrationComplete(ScopedNodeId nodeId, uint32_t icd
796797
{
797798
char icdSymmetricKeyHex[Crypto::kAES_CCM128_Key_Length * 2 + 1];
798799

799-
Encoding::BytesToHex(mICDSymmetricKey.Value().data(), mICDSymmetricKey.Value().size(), icdSymmetricKeyHex,
800-
sizeof(icdSymmetricKeyHex), Encoding::HexFlags::kNullTerminate);
800+
TEMPORARY_RETURN_IGNORED Encoding::BytesToHex(mICDSymmetricKey.Value().data(), mICDSymmetricKey.Value().size(),
801+
icdSymmetricKeyHex, sizeof(icdSymmetricKeyHex),
802+
Encoding::HexFlags::kNullTerminate);
801803

802804
app::ICDClientInfo clientInfo;
803805
clientInfo.check_in_node = ScopedNodeId(mICDCheckInNodeId.Value(), nodeId.GetFabricIndex());

examples/lighting-app-data-mode-no-unique-id/linux/LightingAppCommandDelegate.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ void LightingAppCommandHandler::OnRebootSignalHandler(BootReasonType bootReason)
165165
if (ConfigurationMgr().StoreBootReason(static_cast<uint32_t>(bootReason)) == CHIP_NO_ERROR)
166166
{
167167
Server::GetInstance().GenerateShutDownEvent();
168-
PlatformMgr().ScheduleWork([](intptr_t) { PlatformMgr().StopEventLoopTask(); });
168+
TEMPORARY_RETURN_IGNORED PlatformMgr().ScheduleWork(
169+
[](intptr_t) { TEMPORARY_RETURN_IGNORED PlatformMgr().StopEventLoopTask(); });
169170
}
170171
else
171172
{
@@ -358,5 +359,6 @@ void LightingAppCommandDelegate::OnEventCommandReceived(const char * json)
358359
return;
359360
}
360361

361-
chip::DeviceLayer::PlatformMgr().ScheduleWork(LightingAppCommandHandler::HandleCommand, reinterpret_cast<intptr_t>(handler));
362+
TEMPORARY_RETURN_IGNORED chip::DeviceLayer::PlatformMgr().ScheduleWork(LightingAppCommandHandler::HandleCommand,
363+
reinterpret_cast<intptr_t>(handler));
362364
}

examples/lighting-app-data-mode-no-unique-id/linux/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ void ApplicationInit()
8383
if ((!path.empty()) and (sChipNamedPipeCommands.Start(path, &sLightingAppCommandDelegate) != CHIP_NO_ERROR))
8484
{
8585
ChipLogError(NotSpecified, "Failed to start CHIP NamedPipeCommands");
86-
sChipNamedPipeCommands.Stop();
86+
RETURN_SAFELY_IGNORED sChipNamedPipeCommands.Stop();
8787
}
88-
IdentifyInit();
88+
SuccessOrDie(IdentifyInit());
8989
}
9090

9191
void ApplicationShutdown()

examples/lighting-app/linux/LightingAppCommandDelegate.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ void LightingAppCommandHandler::OnRebootSignalHandler(BootReasonType bootReason)
127127
if (ConfigurationMgr().StoreBootReason(static_cast<uint32_t>(bootReason)) == CHIP_NO_ERROR)
128128
{
129129
Server::GetInstance().GenerateShutDownEvent();
130-
PlatformMgr().ScheduleWork([](intptr_t) { PlatformMgr().StopEventLoopTask(); });
130+
TEMPORARY_RETURN_IGNORED PlatformMgr().ScheduleWork(
131+
[](intptr_t) { TEMPORARY_RETURN_IGNORED PlatformMgr().StopEventLoopTask(); });
131132
}
132133
else
133134
{
@@ -228,5 +229,6 @@ void LightingAppCommandDelegate::OnEventCommandReceived(const char * json)
228229
return;
229230
}
230231

231-
chip::DeviceLayer::PlatformMgr().ScheduleWork(LightingAppCommandHandler::HandleCommand, reinterpret_cast<intptr_t>(handler));
232+
TEMPORARY_RETURN_IGNORED chip::DeviceLayer::PlatformMgr().ScheduleWork(LightingAppCommandHandler::HandleCommand,
233+
reinterpret_cast<intptr_t>(handler));
232234
}

examples/lighting-app/linux/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ void ApplicationInit()
8282
if ((!path.empty()) and (sChipNamedPipeCommands.Start(path, &sLightingAppCommandDelegate) != CHIP_NO_ERROR))
8383
{
8484
ChipLogError(NotSpecified, "Failed to start CHIP NamedPipeCommands");
85-
sChipNamedPipeCommands.Stop();
85+
TEMPORARY_RETURN_IGNORED sChipNamedPipeCommands.Stop();
8686
}
8787
}
8888

0 commit comments

Comments
 (0)