Skip to content

Commit 51e654f

Browse files
authored
Batch project-chip#8 nodiscard errors: crypto, data-model, include (project-chip#41866)
1 parent e1bc066 commit 51e654f

File tree

9 files changed

+14
-15
lines changed

9 files changed

+14
-15
lines changed

src/crypto/CHIPCryptoPAL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,7 @@ CHIP_ERROR GenerateCertificateSigningRequest(const P256Keypair * keypair, Mutabl
11771177
* attributes [0] Attributes{{ CRIAttributes }}
11781178
* }
11791179
*/
1180-
GenerateCertificationRequestInformation(writer, keypair->Pubkey());
1180+
ReturnErrorOnFailure(GenerateCertificationRequestInformation(writer, keypair->Pubkey()));
11811181

11821182
// algorithm AlgorithmIdentifier
11831183
ASN1_START_SEQUENCE

src/crypto/CHIPCryptoPAL.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ class SensitiveDataBuffer
313313
return *this;
314314

315315
ClearSecretData(mBytes);
316-
SetLength(other.Length());
316+
TEMPORARY_RETURN_IGNORED SetLength(other.Length());
317317
::memcpy(Bytes(), other.ConstBytes(), other.Length());
318318
return *this;
319319
}

src/crypto/CHIPCryptoPALmbedTLS.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ CHIP_ERROR P256Keypair::Serialize(P256SerializedKeypair & output) const
722722
bbuf.Put(privkey, sizeof(privkey));
723723
VerifyOrExit(bbuf.Fit(), error = CHIP_ERROR_BUFFER_TOO_SMALL);
724724

725-
output.SetLength(bbuf.Needed());
725+
TEMPORARY_RETURN_IGNORED output.SetLength(bbuf.Needed());
726726

727727
exit:
728728
ClearSecretData(privkey, sizeof(privkey));

src/crypto/CHIPCryptoPALmbedTLSCert.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ CHIP_ERROR VerifyCertificateSigningRequest(const uint8_t * csr_buf, size_t csr_l
8383

8484
VerifyOrExit(error == CHIP_NO_ERROR, error = CHIP_ERROR_INVALID_ARGUMENT);
8585
VerifyOrExit(out_raw_sig_span.size() == (kP256_FE_Length * 2), error = CHIP_ERROR_INTERNAL);
86-
signature.SetLength(out_raw_sig_span.size());
86+
TEMPORARY_RETURN_IGNORED signature.SetLength(out_raw_sig_span.size());
8787

8888
// Verify the signature using the public key
8989
error = pubkey.ECDSA_validate_msg_signature(csr.CHIP_CRYPTO_PAL_PRIVATE_X509(cri).CHIP_CRYPTO_PAL_PRIVATE_X509(p),

src/crypto/P256KeyPairOpenSSL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ CHIP_ERROR P256Keypair::Serialize(P256SerializedKeypair & output) const
308308
bbuf.Put(mPublicKey, mPublicKey.Length());
309309
bbuf.Put(privkey, sizeof(privkey));
310310
VerifyOrExit(bbuf.Fit(), error = CHIP_ERROR_NO_MEMORY);
311-
output.SetLength(bbuf.Needed());
311+
TEMPORARY_RETURN_IGNORED output.SetLength(bbuf.Needed());
312312
}
313313

314314
exit:

src/crypto/PersistentStorageOperationalKeystore.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ CHIP_ERROR ExportStoredOpKey(FabricIndex fabricIndex, PersistentStorageDelegate
100100
ReturnErrorOnFailure(
101101
storage->SyncGetKeyValue(DefaultStorageKeyAllocator::FabricOpKey(fabricIndex).KeyName(), buf.Bytes(), size));
102102

103-
buf.SetLength(static_cast<size_t>(size));
103+
TEMPORARY_RETURN_IGNORED buf.SetLength(static_cast<size_t>(size));
104104

105105
// Read-out the operational key TLV entry.
106106
TLV::ContiguousBufferTLVReader reader;
@@ -126,10 +126,8 @@ CHIP_ERROR ExportStoredOpKey(FabricIndex fabricIndex, PersistentStorageDelegate
126126
ReturnErrorOnFailure(reader.ExitContainer(containerType));
127127

128128
memcpy(serializedOpKey.Bytes(), keyData.data(), keyData.size());
129-
serializedOpKey.SetLength(keyData.size());
129+
return serializedOpKey.SetLength(keyData.size());
130130
}
131-
132-
return CHIP_NO_ERROR;
133131
}
134132

135133
/** WARNING: This can leave the operational key on the stack somewhere, since many of the platform
@@ -212,7 +210,7 @@ CHIP_ERROR PersistentStorageOperationalKeystore::NewOpKeypairForFabric(FabricInd
212210
mPendingKeypair = Platform::New<Crypto::P256Keypair>();
213211
VerifyOrReturnError(mPendingKeypair != nullptr, CHIP_ERROR_NO_MEMORY);
214212

215-
mPendingKeypair->Initialize(Crypto::ECPKeyTarget::ECDSA);
213+
TEMPORARY_RETURN_IGNORED mPendingKeypair->Initialize(Crypto::ECPKeyTarget::ECDSA);
216214
size_t csrLength = outCertificateSigningRequest.size();
217215
CHIP_ERROR err = mPendingKeypair->NewCertificateSigningRequest(outCertificateSigningRequest.data(), csrLength);
218216
if (err != CHIP_NO_ERROR)

src/data-model-providers/codegen/CodegenDataModelProvider.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ CHIP_ERROR CodegenDataModelProvider::EndpointUniqueID(EndpointId endpointId, Mut
538538
{
539539
char buffer[Clusters::Descriptor::Attributes::EndpointUniqueID::TypeInfo::MaxLength()] = { 0 };
540540
MutableCharSpan epUniqueIdSpan(buffer);
541-
emberAfGetEndpointUniqueIdForEndPoint(endpointId, epUniqueIdSpan);
541+
ReturnErrorOnFailure(emberAfGetEndpointUniqueIdForEndPoint(endpointId, epUniqueIdSpan));
542542

543543
memcpy(epUniqueId.data(), epUniqueIdSpan.data(), epUniqueIdSpan.size());
544544
return CHIP_NO_ERROR;

src/include/platform/internal/GenericConfigurationManagerImpl.ipp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ CHIP_ERROR GenericConfigurationManagerImpl<ConfigClass>::Init()
245245
CHIP_ERROR err = CHIP_NO_ERROR;
246246

247247
#if CHIP_ENABLE_ROTATING_DEVICE_ID && defined(CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID)
248-
mLifetimePersistedCounter.Init(CHIP_CONFIG_LIFETIIME_PERSISTED_COUNTER_KEY);
248+
err = mLifetimePersistedCounter.Init(CHIP_CONFIG_LIFETIIME_PERSISTED_COUNTER_KEY);
249249
#endif
250250

251251
#if CHIP_USE_TRANSITIONAL_DEVICE_INSTANCE_INFO_PROVIDER
@@ -443,7 +443,7 @@ void GenericConfigurationManagerImpl<ImplClass>::NotifyOfAdvertisementStart()
443443
{
444444
#if CHIP_ENABLE_ROTATING_DEVICE_ID && defined(CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID)
445445
// Increment life time counter to protect against long-term tracking of rotating device ID.
446-
IncrementLifetimeCounter();
446+
TEMPORARY_RETURN_IGNORED IncrementLifetimeCounter();
447447
// Inheriting classes should call this method so the lifetime counter is updated if necessary.
448448
#endif
449449
}

src/include/platform/internal/GenericPlatformManagerImpl.ipp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,9 @@ void GenericPlatformManagerImpl<ImplClass>::_Shutdown()
165165

166166
#if CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
167167
ChipLogProgress(DeviceLayer, "WiFi-PAF Layer shutdown");
168-
WiFiPAF::WiFiPAFLayer::GetWiFiPAFLayer().Shutdown(
169-
[](uint32_t id, WiFiPAF::WiFiPafRole role) { DeviceLayer::ConnectivityMgr().WiFiPAFShutdown(id, role); });
168+
WiFiPAF::WiFiPAFLayer::GetWiFiPAFLayer().Shutdown([](uint32_t id, WiFiPAF::WiFiPafRole role) {
169+
TEMPORARY_RETURN_IGNORED DeviceLayer::ConnectivityMgr().WiFiPAFShutdown(id, role);
170+
});
170171
#endif
171172

172173
#if CHIP_DEVICE_CONFIG_ENABLE_NFC_BASED_COMMISSIONING

0 commit comments

Comments
 (0)