Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0f8fac1

Browse files
dhrishibzbarsky-apple
andauthoredJun 2, 2023
Add a lint for SuccessOrExit without assignment. (project-chip#26854) (project-chip#27029)
* Add a lint for SuccessOrExit without assignment. This is almost always a mistake, since it loses track of the error involved. * Address review comment. Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
1 parent dcd13d3 commit 0f8fac1

25 files changed

+96
-105
lines changed
 

‎examples/platform/nxp/se05x/DeviceAttestationSe05xCredsExample_v2.cpp

+10-9
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ CHIP_ERROR ExampleSe05xDACProviderv2::SignWithDeviceAttestationKey(const ByteSpa
196196
};
197197

198198
tempBuf[0] = (uint8_t) TLV::TLVElementType::Structure;
199-
SuccessOrExit(se05xSetCertificate(START_CONTAINER_SE05X_ID, tempBuf, 1));
199+
SuccessOrExit(err = se05xSetCertificate(START_CONTAINER_SE05X_ID, tempBuf, 1));
200200

201201
for (int i = 1; i <= NO_OF_DEV_ATTEST_MSG_TAGS_TO_PARSE; i++)
202202
{
@@ -206,6 +206,7 @@ CHIP_ERROR ExampleSe05xDACProviderv2::SignWithDeviceAttestationKey(const ByteSpa
206206
{
207207
continue;
208208
}
209+
// TODO: Should this be setting err = tlverr?
209210
SuccessOrExit(tlverr);
210211

211212
// Transient binary object ids starting from location 0x7D300005 (TAG1_ID) to 0x7D30000D (TAG3_VALUE_ID)
@@ -215,35 +216,35 @@ CHIP_ERROR ExampleSe05xDACProviderv2::SignWithDeviceAttestationKey(const ByteSpa
215216
taglen = tagReader.GetLength();
216217
tempBuf[0] = tagReader.GetControlByte();
217218
tempBuf[1] = i;
218-
SuccessOrExit(se05xSetCertificate(TAG1_ID + (3 /* tag + length + value ids */ * (i - 1)), tempBuf, 2));
219+
SuccessOrExit(err = se05xSetCertificate(TAG1_ID + (3 /* tag + length + value ids */ * (i - 1)), tempBuf, 2));
219220
if (taglen > 256)
220221
{
221222
tempBuf[0] = taglen & 0xFF;
222223
tempBuf[1] = (taglen >> 8) & 0xFF;
223-
SuccessOrExit(se05xSetCertificate(TAG1_LEN_ID + (3 * (i - 1)), tempBuf, 2));
224+
SuccessOrExit(err = se05xSetCertificate(TAG1_LEN_ID + (3 * (i - 1)), tempBuf, 2));
224225
}
225226
else
226227
{
227228
tempBuf[0] = taglen;
228-
SuccessOrExit(se05xSetCertificate(TAG1_LEN_ID + (3 * (i - 1)), tempBuf, 1));
229+
SuccessOrExit(err = se05xSetCertificate(TAG1_LEN_ID + (3 * (i - 1)), tempBuf, 1));
229230
}
230231
if (taglen > 0)
231232
{
232-
SuccessOrExit(tagReader.Get(tagvalue));
233-
SuccessOrExit(se05xSetCertificate(TAG1_VALUE_ID + (3 * (i - 1)), tagvalue.data(), taglen));
233+
SuccessOrExit(err = tagReader.Get(tagvalue));
234+
SuccessOrExit(err = se05xSetCertificate(TAG1_VALUE_ID + (3 * (i - 1)), tagvalue.data(), taglen));
234235
}
235236
}
236237

237238
tempBuf[0] = (uint8_t) TLV::TLVElementType::EndOfContainer;
238-
SuccessOrExit(se05xSetCertificate(END_CONTAINER_SE05X_ID, tempBuf, 1));
239+
SuccessOrExit(err = se05xSetCertificate(END_CONTAINER_SE05X_ID, tempBuf, 1));
239240

240241
if ((tagReader.GetRemainingLength() + 1 /* End container */) >= 16)
241242
{
242243
/* Set attestation challenge */
243-
SuccessOrExit(se05xSetCertificate(ATTEST_CHALLENGE_ID, (message_to_sign.end() - 16), 16));
244+
SuccessOrExit(err = se05xSetCertificate(ATTEST_CHALLENGE_ID, (message_to_sign.end() - 16), 16));
244245
}
245246

246-
SuccessOrExit(se05xPerformInternalSign(DEV_ATTESTATION_KEY_SE05X_ID_IS, signature_se05x, &signature_se05x_len));
247+
SuccessOrExit(err = se05xPerformInternalSign(DEV_ATTESTATION_KEY_SE05X_ID_IS, signature_se05x, &signature_se05x_len));
247248

248249
err = chip::Crypto::EcdsaAsn1SignatureToRaw(chip::Crypto::kP256_FE_Length, ByteSpan{ signature_se05x, signature_se05x_len },
249250
out_signature_buffer);

‎src/access/AccessControl.cpp

+16-8
Original file line numberDiff line numberDiff line change
@@ -555,11 +555,12 @@ bool AccessControl::IsValid(const Entry & entry)
555555
size_t subjectCount = 0;
556556
size_t targetCount = 0;
557557

558-
SuccessOrExit(entry.GetAuthMode(authMode));
559-
SuccessOrExit(entry.GetFabricIndex(fabricIndex));
560-
SuccessOrExit(entry.GetPrivilege(privilege));
561-
SuccessOrExit(entry.GetSubjectCount(subjectCount));
562-
SuccessOrExit(entry.GetTargetCount(targetCount));
558+
CHIP_ERROR err = CHIP_NO_ERROR;
559+
SuccessOrExit(err = entry.GetAuthMode(authMode));
560+
SuccessOrExit(err = entry.GetFabricIndex(fabricIndex));
561+
SuccessOrExit(err = entry.GetPrivilege(privilege));
562+
SuccessOrExit(err = entry.GetSubjectCount(subjectCount));
563+
SuccessOrExit(err = entry.GetTargetCount(targetCount));
563564

564565
#if CHIP_CONFIG_ACCESS_CONTROL_POLICY_LOGGING_VERBOSITY > 1
565566
ChipLogProgress(DataManagement, "AccessControl: validating f=%u p=%c a=%c s=%d t=%d", fabricIndex,
@@ -582,7 +583,7 @@ bool AccessControl::IsValid(const Entry & entry)
582583
for (size_t i = 0; i < subjectCount; ++i)
583584
{
584585
NodeId subject;
585-
SuccessOrExit(entry.GetSubject(i, subject));
586+
SuccessOrExit(err = entry.GetSubject(i, subject));
586587
const bool kIsCase = authMode == AuthMode::kCase;
587588
const bool kIsGroup = authMode == AuthMode::kGroup;
588589
#if CHIP_CONFIG_ACCESS_CONTROL_POLICY_LOGGING_VERBOSITY > 1
@@ -594,7 +595,7 @@ bool AccessControl::IsValid(const Entry & entry)
594595
for (size_t i = 0; i < targetCount; ++i)
595596
{
596597
Entry::Target target;
597-
SuccessOrExit(entry.GetTarget(i, target));
598+
SuccessOrExit(err = entry.GetTarget(i, target));
598599
const bool kHasCluster = target.flags & Entry::Target::kCluster;
599600
const bool kHasEndpoint = target.flags & Entry::Target::kEndpoint;
600601
const bool kHasDeviceType = target.flags & Entry::Target::kDeviceType;
@@ -608,7 +609,14 @@ bool AccessControl::IsValid(const Entry & entry)
608609
return true;
609610

610611
exit:
611-
ChipLogError(DataManagement, "AccessControl: %s", log);
612+
if (err != CHIP_NO_ERROR)
613+
{
614+
ChipLogError(DataManagement, "AccessControl: %s %" CHIP_ERROR_FORMAT, log, err.Format());
615+
}
616+
else
617+
{
618+
ChipLogError(DataManagement, "AccessControl: %s", log);
619+
}
612620
return false;
613621
}
614622

‎src/app/CommandHandler.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ Status CommandHandler::ProcessCommandDataIB(CommandDataIB::Parser & aCommandElem
326326
{
327327
ChipLogDetail(DataManagement, "Received command for Endpoint=%u Cluster=" ChipLogFormatMEI " Command=" ChipLogFormatMEI,
328328
concretePath.mEndpointId, ChipLogValueMEI(concretePath.mClusterId), ChipLogValueMEI(concretePath.mCommandId));
329-
SuccessOrExit(MatterPreCommandReceivedCallback(concretePath, GetSubjectDescriptor()));
329+
SuccessOrExit(err = MatterPreCommandReceivedCallback(concretePath, GetSubjectDescriptor()));
330330
mpCallback->DispatchCommand(*this, concretePath, commandDataReader);
331331
MatterPostCommandReceivedCallback(concretePath, GetSubjectDescriptor());
332332
}

‎src/app/WriteClient.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ CHIP_ERROR WriteClient::OnMessageReceived(Messaging::ExchangeContext * apExchang
460460
if (!mChunks.IsNull())
461461
{
462462
// Send the next chunk.
463-
SuccessOrExit(SendWriteRequest());
463+
SuccessOrExit(err = SendWriteRequest());
464464
}
465465
}
466466
else if (aPayloadHeader.HasMessageType(MsgType::StatusResponse))

‎src/app/reporting/Engine.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ CHIP_ERROR Engine::BuildAndSendSingleReportData(ReadHandler * apReadHandler)
529529
}
530530
}
531531

532-
SuccessOrExit(reportDataBuilder.GetError());
532+
SuccessOrExit(err = reportDataBuilder.GetError());
533533
SuccessOrExit(err = reportDataWriter.UnreserveBuffer(kReservedSizeForMoreChunksFlag + kReservedSizeForIMRevision +
534534
kReservedSizeForEndOfReportMessage));
535535
if (hasMoreChunks)

‎src/app/server/Server.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams)
147147

148148
// Set up attribute persistence before we try to bring up the data model
149149
// handler.
150-
SuccessOrExit(mAttributePersister.Init(mDeviceStorage));
150+
SuccessOrExit(err = mAttributePersister.Init(mDeviceStorage));
151151
SetAttributePersistenceProvider(&mAttributePersister);
152152

153153
{

‎src/app/tests/integration/chip_im_initiator.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ CHIP_ERROR SendReadRequest()
347347
chip::Platform::MakeUnique<chip::app::ReadClient>(chip::app::InteractionModelEngine::GetInstance(), &gExchangeManager,
348348
gMockDelegate, chip::app::ReadClient::InteractionType::Read);
349349

350-
SuccessOrExit(readClient->SendRequest(readPrepareParams));
350+
SuccessOrExit(err = readClient->SendRequest(readPrepareParams));
351351

352352
gMockDelegate.AdoptReadClient(std::move(readClient));
353353

‎src/controller/java/AndroidCommissioningWindowOpener.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ void AndroidCommissioningWindowOpener::OnOpenCommissioningWindowResponse(void *
121121
std::string QRCode;
122122
std::string manualPairingCode;
123123

124-
SuccessOrExit(ManualSetupPayloadGenerator(payload).payloadDecimalStringRepresentation(manualPairingCode));
125-
SuccessOrExit(QRCodeSetupPayloadGenerator(payload).payloadBase38Representation(QRCode));
124+
SuccessOrExit(status = ManualSetupPayloadGenerator(payload).payloadDecimalStringRepresentation(manualPairingCode));
125+
SuccessOrExit(status = QRCodeSetupPayloadGenerator(payload).payloadBase38Representation(QRCode));
126126

127127
if (self->mOnSuccessMethod != nullptr)
128128
{

‎src/controller/java/CHIPDeviceController-JNI.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,7 @@ JNI_METHOD(void, write)
15561556
VerifyOrExit(device != nullptr, err = CHIP_ERROR_INCORRECT_STATE);
15571557
VerifyOrExit(device->GetSecureSession().HasValue(), err = CHIP_ERROR_MISSING_SECURE_SESSION);
15581558
VerifyOrExit(attributeList != nullptr, err = CHIP_ERROR_INVALID_ARGUMENT);
1559-
SuccessOrExit(JniReferences::GetInstance().GetListSize(attributeList, listSize));
1559+
SuccessOrExit(err = JniReferences::GetInstance().GetListSize(attributeList, listSize));
15601560

15611561
writeClient = Platform::New<app::WriteClient>(device->GetExchangeManager(), callback->GetChunkedWriteCallback(),
15621562
timedRequestTimeoutMs != 0 ? Optional<uint16_t>(timedRequestTimeoutMs)
@@ -1708,7 +1708,8 @@ JNI_METHOD(void, invoke)
17081708
"()Lchip/devicecontroller/model/ChipPathId;", &getClusterIdMethod));
17091709
SuccessOrExit(err = JniReferences::GetInstance().FindMethod(env, invokeElement, "getCommandId",
17101710
"()Lchip/devicecontroller/model/ChipPathId;", &getCommandIdMethod));
1711-
SuccessOrExit(JniReferences::GetInstance().FindMethod(env, invokeElement, "getTlvByteArray", "()[B", &getTlvByteArrayMethod));
1711+
SuccessOrExit(
1712+
err = JniReferences::GetInstance().FindMethod(env, invokeElement, "getTlvByteArray", "()[B", &getTlvByteArrayMethod));
17121713

17131714
endpointIdObj = env->CallObjectMethod(invokeElement, getEndpointIdMethod);
17141715
VerifyOrExit(!env->ExceptionCheck(), err = CHIP_JNI_ERROR_EXCEPTION_THROWN);

‎src/controller/python/chip/clusters/command.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ PyChipError pychip_CommandSender_SendCommand(void * appContext, DeviceProxy * de
153153
VerifyOrExit(writer != nullptr, err = CHIP_ERROR_INCORRECT_STATE);
154154
reader.Init(payload, length);
155155
reader.Next();
156-
SuccessOrExit(writer->CopyContainer(TLV::ContextTag(CommandDataIB::Tag::kFields), reader));
156+
SuccessOrExit(err = writer->CopyContainer(TLV::ContextTag(CommandDataIB::Tag::kFields), reader));
157157
}
158158

159159
SuccessOrExit(err = sender->FinishCommand(timedRequestTimeoutMs != 0 ? Optional<uint16_t>(timedRequestTimeoutMs)
@@ -197,7 +197,7 @@ PyChipError pychip_CommandSender_SendGroupCommand(chip::GroupId groupId, chip::C
197197
VerifyOrExit(writer != nullptr, err = CHIP_ERROR_INCORRECT_STATE);
198198
reader.Init(payload, length);
199199
reader.Next();
200-
SuccessOrExit(writer->CopyContainer(TLV::ContextTag(CommandDataIB::Tag::kFields), reader));
200+
SuccessOrExit(err = writer->CopyContainer(TLV::ContextTag(CommandDataIB::Tag::kFields), reader));
201201
}
202202

203203
SuccessOrExit(err = sender->FinishCommand(Optional<uint16_t>::Missing()));

‎src/controller/python/chip/internal/CommissionerImpl.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -183,17 +183,17 @@ extern "C" chip::Controller::DeviceCommissioner * pychip_internal_Commissioner_N
183183
commissionerParams.controllerICAC = icacSpan;
184184
commissionerParams.controllerNOC = nocSpan;
185185

186-
SuccessOrExit(DeviceControllerFactory::GetInstance().Init(factoryParams));
187-
err = DeviceControllerFactory::GetInstance().SetupCommissioner(commissionerParams, *result);
186+
SuccessOrExit(err = DeviceControllerFactory::GetInstance().Init(factoryParams));
187+
SuccessOrExit(err = DeviceControllerFactory::GetInstance().SetupCommissioner(commissionerParams, *result));
188188

189-
SuccessOrExit(result->GetCompressedFabricIdBytes(compressedFabricIdSpan));
189+
SuccessOrExit(err = result->GetCompressedFabricIdBytes(compressedFabricIdSpan));
190190
ChipLogProgress(Support, "Setting up group data for Fabric Index %u with Compressed Fabric ID:",
191191
static_cast<unsigned>(result->GetFabricIndex()));
192192
ChipLogByteSpan(Support, compressedFabricIdSpan);
193193

194194
defaultIpk = chip::GroupTesting::DefaultIpkValue::GetDefaultIpk();
195-
SuccessOrExit(chip::Credentials::SetSingleIpkEpochKey(&gGroupDataProvider, result->GetFabricIndex(), defaultIpk,
196-
compressedFabricIdSpan));
195+
SuccessOrExit(err = chip::Credentials::SetSingleIpkEpochKey(&gGroupDataProvider, result->GetFabricIndex(), defaultIpk,
196+
compressedFabricIdSpan));
197197
}
198198
exit:
199199
ChipLogProgress(Controller, "Commissioner initialization status: %s", chip::ErrorStr(err));

‎src/crypto/CHIPCryptoPALOpenSSL.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ CHIP_ERROR P256Keypair::ECDH_derive_secret(const P256PublicKey & remote_public_k
940940
out_buf_length = (out_secret.Length() == 0) ? out_secret.Capacity() : out_secret.Length();
941941
result = EVP_PKEY_derive(context, out_secret.Bytes(), &out_buf_length);
942942
VerifyOrExit(result == 1, error = CHIP_ERROR_INTERNAL);
943-
SuccessOrExit(out_secret.SetLength(out_buf_length));
943+
SuccessOrExit(error = out_secret.SetLength(out_buf_length));
944944

945945
exit:
946946
if (ec_key != nullptr)

‎src/crypto/CHIPCryptoPALPSA.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ CHIP_ERROR P256Keypair::ECDH_derive_secret(const P256PublicKey & remote_public_k
589589
status = psa_raw_key_agreement(PSA_ALG_ECDH, context.key_id, remote_public_key.ConstBytes(), remote_public_key.Length(),
590590
out_secret.Bytes(), outputSize, &outputLength);
591591
VerifyOrExit(status == PSA_SUCCESS, error = CHIP_ERROR_INTERNAL);
592-
SuccessOrExit(out_secret.SetLength(outputLength));
592+
SuccessOrExit(error = out_secret.SetLength(outputLength));
593593

594594
exit:
595595
logPsaError(status);
@@ -1420,7 +1420,9 @@ CHIP_ERROR ValidateCertificateChain(const uint8_t * rootCertificate, size_t root
14201420
error = CHIP_ERROR_CERT_NOT_TRUSTED;
14211421
break;
14221422
default:
1423-
SuccessOrExit((result = CertificateChainValidationResult::kInternalFrameworkError, error = CHIP_ERROR_INTERNAL));
1423+
result = CertificateChainValidationResult::kInternalFrameworkError;
1424+
error = CHIP_ERROR_INTERNAL;
1425+
break;
14241426
}
14251427

14261428
exit:

‎src/crypto/CHIPCryptoPALmbedTLS.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ CHIP_ERROR P256Keypair::ECDH_derive_secret(const P256PublicKey & remote_public_k
653653

654654
result = mbedtls_mpi_write_binary(&mpi_secret, out_secret.Bytes(), secret_length);
655655
VerifyOrExit(result == 0, error = CHIP_ERROR_INTERNAL);
656-
SuccessOrExit(out_secret.SetLength(secret_length));
656+
SuccessOrExit(error = out_secret.SetLength(secret_length));
657657

658658
exit:
659659
keypair = nullptr;
@@ -1537,7 +1537,9 @@ CHIP_ERROR ValidateCertificateChain(const uint8_t * rootCertificate, size_t root
15371537
error = CHIP_ERROR_CERT_NOT_TRUSTED;
15381538
break;
15391539
default:
1540-
SuccessOrExit((result = CertificateChainValidationResult::kInternalFrameworkError, error = CHIP_ERROR_INTERNAL));
1540+
result = CertificateChainValidationResult::kInternalFrameworkError;
1541+
error = CHIP_ERROR_INTERNAL;
1542+
break;
15411543
}
15421544

15431545
exit:

‎src/crypto/hsm/nxp/CHIPCryptoPALHsm_SE05X_P256.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ CHIP_ERROR P256KeypairHSM::ECDSA_sign_msg(const uint8_t * msg, size_t msg_length
190190
error = EcdsaAsn1SignatureToRaw(kP256_FE_Length, ByteSpan{ signature_se05x, signature_se05x_len }, out_raw_sig_span);
191191
SuccessOrExit(error);
192192

193-
SuccessOrExit(out_signature.SetLength(2 * kP256_FE_Length));
193+
SuccessOrExit(error = out_signature.SetLength(2 * kP256_FE_Length));
194194

195195
error = CHIP_NO_ERROR;
196196
exit:

‎src/platform/Infineon/CYW30739/FactoryDataProvider.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ CHIP_ERROR FactoryDataProvider::LoadKeypairFromDer(const ByteSpan & der_buffer,
111111
mbedtls_result = mbedtls_ecp_write_key(ecp, private_key.data(), private_key.size());
112112
VerifyOrExit(mbedtls_result == 0, error = CHIP_ERROR_INTERNAL);
113113

114-
SuccessOrExit(serializedKeypair.SetLength(public_key.size() + private_key.size()));
115-
SuccessOrExit(keypair.Deserialize(serializedKeypair));
114+
SuccessOrExit(error = serializedKeypair.SetLength(public_key.size() + private_key.size()));
115+
SuccessOrExit(error = keypair.Deserialize(serializedKeypair));
116116

117117
exit:
118118
if (mbedtls_result != 0)

‎src/platform/mbed/BLEManagerImpl.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void)
770770
VerifyOrExit(mbed_err == BLE_ERROR_NONE, err = CHIP_ERROR(chip::ChipError::Range::kOS, mbed_err));
771771

772772
dev_id_info.Init();
773-
SuccessOrExit(ConfigurationMgr().GetBLEDeviceIdentificationInfo(dev_id_info));
773+
SuccessOrExit(err = ConfigurationMgr().GetBLEDeviceIdentificationInfo(dev_id_info));
774774
mbed_err = adv_data_builder.setServiceData(
775775
ShortUUID_CHIPoBLEService, mbed::make_Span<const uint8_t>(reinterpret_cast<uint8_t *>(&dev_id_info), sizeof dev_id_info));
776776
VerifyOrExit(mbed_err == BLE_ERROR_NONE, err = CHIP_ERROR(chip::ChipError::Range::kOS, mbed_err));

‎src/platform/nxp/common/crypto/CHIPCryptoPALTinyCrypt.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ CHIP_ERROR P256Keypair::ECDH_derive_secret(const P256PublicKey & remote_public_k
599599
result = uECC_shared_secret(remote_public_key.ConstBytes() + 1, keypair->private_key, out_secret.Bytes());
600600
VerifyOrExit(result == UECC_SUCCESS, error = CHIP_ERROR_INTERNAL);
601601

602-
SuccessOrExit(out_secret.SetLength(secret_length));
602+
SuccessOrExit(error = out_secret.SetLength(secret_length));
603603

604604
exit:
605605
keypair = nullptr;
@@ -1377,7 +1377,9 @@ CHIP_ERROR ValidateCertificateChain(const uint8_t * rootCertificate, size_t root
13771377
error = CHIP_ERROR_CERT_NOT_TRUSTED;
13781378
break;
13791379
default:
1380-
SuccessOrExit((result = CertificateChainValidationResult::kInternalFrameworkError, error = CHIP_ERROR_INTERNAL));
1380+
result = CertificateChainValidationResult::kInternalFrameworkError;
1381+
error = CHIP_ERROR_INTERNAL;
1382+
break;
13811383
}
13821384

13831385
exit:

‎src/platform/nxp/k32w/k32w0/crypto/CHIPCryptoPALNXPUltrafastP256.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ CHIP_ERROR P256Keypair::ECDH_derive_secret(const P256PublicKey & remote_public_k
594594
out_secret.Bytes());
595595
VerifyOrExit(result == gSecEcdhSuccess_c, error = CHIP_ERROR_INTERNAL);
596596

597-
SuccessOrExit(out_secret.SetLength(secret_length));
597+
SuccessOrExit(error = out_secret.SetLength(secret_length));
598598
exit:
599599
keypair = nullptr;
600600
_log_mbedTLS_error(result);
@@ -1347,7 +1347,9 @@ CHIP_ERROR ValidateCertificateChain(const uint8_t * rootCertificate, size_t root
13471347
error = CHIP_ERROR_CERT_NOT_TRUSTED;
13481348
break;
13491349
default:
1350-
SuccessOrExit((result = CertificateChainValidationResult::kInternalFrameworkError, error = CHIP_ERROR_INTERNAL));
1350+
result = CertificateChainValidationResult::kInternalFrameworkError;
1351+
error = CHIP_ERROR_INTERNAL;
1352+
break;
13511353
}
13521354

13531355
exit:

‎src/platform/silabs/SiWx917/CHIPCryptoPALTinyCrypt.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ CHIP_ERROR P256Keypair::ECDH_derive_secret(const P256PublicKey & remote_public_k
569569
result = uECC_shared_secret(remote_public_key.ConstBytes() + 1, keypair->private_key, out_secret.Bytes());
570570
VerifyOrExit(result == UECC_SUCCESS, error = CHIP_ERROR_INTERNAL);
571571

572-
SuccessOrExit(out_secret.SetLength(secret_length));
572+
SuccessOrExit(error = out_secret.SetLength(secret_length));
573573

574574
exit:
575575
keypair = nullptr;
@@ -1378,7 +1378,9 @@ CHIP_ERROR ValidateCertificateChain(const uint8_t * rootCertificate, size_t root
13781378
error = CHIP_ERROR_CERT_NOT_TRUSTED;
13791379
break;
13801380
default:
1381-
SuccessOrExit((result = CertificateChainValidationResult::kInternalFrameworkError, error = CHIP_ERROR_INTERNAL));
1381+
result = CertificateChainValidationResult::kInternalFrameworkError;
1382+
error = CHIP_ERROR_INTERNAL;
1383+
break;
13821384
}
13831385

13841386
exit:

0 commit comments

Comments
 (0)
Please sign in to comment.