From 6a625add8733bea6971043c36040a377bcb0ffc3 Mon Sep 17 00:00:00 2001 From: "restyled-io[bot]" <32688539+restyled-io[bot]@users.noreply.github.com> Date: Sat, 10 Sep 2022 15:19:35 -0700 Subject: [PATCH] Restyled by clang-format (#22524) Co-authored-by: Restyled.io --- src/controller/CHIPDeviceController.cpp | 82 ++++++++++++------------- 1 file changed, 40 insertions(+), 42 deletions(-) diff --git a/src/controller/CHIPDeviceController.cpp b/src/controller/CHIPDeviceController.cpp index f7739dca742dd4..f1c600772e4c34 100644 --- a/src/controller/CHIPDeviceController.cpp +++ b/src/controller/CHIPDeviceController.cpp @@ -1737,54 +1737,52 @@ void DeviceCommissioner::OnDone(app::ReadClient *) // Try to parse as much as we can here before returning, even if this is an error. return_err = (err == CHIP_NO_ERROR) ? return_err : err; - err = - mAttributeCache->ForEachAttribute(OperationalCredentials::Id, [this, &info](const app::ConcreteAttributePath & path) { - // this code is checking if the device is already on the commissioner's fabric. - // if a matching fabric is found, then remember the nodeId so that the commissioner - // can, if it decides to, cancel commissioning (before it fails in AddNoc) and know - // the device's nodeId on its fabric. - switch (path.mAttributeId) + err = mAttributeCache->ForEachAttribute(OperationalCredentials::Id, [this, &info](const app::ConcreteAttributePath & path) { + // this code is checking if the device is already on the commissioner's fabric. + // if a matching fabric is found, then remember the nodeId so that the commissioner + // can, if it decides to, cancel commissioning (before it fails in AddNoc) and know + // the device's nodeId on its fabric. + switch (path.mAttributeId) + { + case OperationalCredentials::Attributes::Fabrics::Id: { + OperationalCredentials::Attributes::Fabrics::TypeInfo::DecodableType fabrics; + ReturnErrorOnFailure(this->mAttributeCache->Get(path, fabrics)); + auto iter = fabrics.begin(); + while (iter.Next()) { - case OperationalCredentials::Attributes::Fabrics::Id: { - OperationalCredentials::Attributes::Fabrics::TypeInfo::DecodableType fabrics; - ReturnErrorOnFailure( - this->mAttributeCache->Get(path, fabrics)); - auto iter = fabrics.begin(); - while (iter.Next()) + auto & fabricDescriptor = iter.GetValue(); + ChipLogProgress(AppServer, + "DeviceCommissioner::OnDone - fabric.vendorId=0x%04X fabric.fabricId=0x" ChipLogFormatX64 + " fabric.nodeId=0x" ChipLogFormatX64, + fabricDescriptor.vendorId, ChipLogValueX64(fabricDescriptor.fabricId), + ChipLogValueX64(fabricDescriptor.nodeId)); + // need to add check for root public key + if (GetFabricId() == fabricDescriptor.fabricId) { - auto & fabricDescriptor = iter.GetValue(); - ChipLogProgress(AppServer, - "DeviceCommissioner::OnDone - fabric.vendorId=0x%04X fabric.fabricId=0x" ChipLogFormatX64 - " fabric.nodeId=0x" ChipLogFormatX64, - fabricDescriptor.vendorId, ChipLogValueX64(fabricDescriptor.fabricId), - ChipLogValueX64(fabricDescriptor.nodeId)); - // need to add check for root public key - if (GetFabricId() == fabricDescriptor.fabricId) - { - ChipLogProgress(AppServer, "DeviceCommissioner::OnDone - found a matching fabric id"); - chip::ByteSpan rootKeySpan = fabricDescriptor.rootPublicKey; - P256PublicKeySpan rootPubKeySpan(rootKeySpan.data()); - Crypto::P256PublicKey deviceRootPublicKey(rootPubKeySpan); + ChipLogProgress(AppServer, "DeviceCommissioner::OnDone - found a matching fabric id"); + chip::ByteSpan rootKeySpan = fabricDescriptor.rootPublicKey; + P256PublicKeySpan rootPubKeySpan(rootKeySpan.data()); + Crypto::P256PublicKey deviceRootPublicKey(rootPubKeySpan); - Crypto::P256PublicKey commissionerRootPublicKey; - if (CHIP_NO_ERROR != GetRootPublicKey(commissionerRootPublicKey)) - { - ChipLogError(AppServer, "DeviceCommissioner::OnDone - error reading commissioner root public key"); - } - else if (commissionerRootPublicKey.Matches(deviceRootPublicKey)) - { - ChipLogProgress(AppServer, "DeviceCommissioner::OnDone - fabric root keys match"); - info.nodeId = fabricDescriptor.nodeId; - } + Crypto::P256PublicKey commissionerRootPublicKey; + if (CHIP_NO_ERROR != GetRootPublicKey(commissionerRootPublicKey)) + { + ChipLogError(AppServer, "DeviceCommissioner::OnDone - error reading commissioner root public key"); + } + else if (commissionerRootPublicKey.Matches(deviceRootPublicKey)) + { + ChipLogProgress(AppServer, "DeviceCommissioner::OnDone - fabric root keys match"); + info.nodeId = fabricDescriptor.nodeId; } } - - return CHIP_NO_ERROR; - } - default: - return CHIP_NO_ERROR; } - }); + + return CHIP_NO_ERROR; + } + default: + return CHIP_NO_ERROR; + } + }); // Try to parse as much as we can here before returning, even if this is an error. return_err = err == CHIP_NO_ERROR ? return_err : err;