Skip to content

Commit

Permalink
Renamed CHIP_ERROR_INVALID_FABRIC_ID to CHIP_ERROR_INVALID_FABRIC_IND…
Browse files Browse the repository at this point in the history
…EX (#18579)
  • Loading branch information
emargolis authored May 19, 2022
1 parent 6fc3432 commit 70e259c
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ NS_ASSUME_NONNULL_BEGIN
if (CHIP_ERROR_FABRIC_EXISTS == err) {
return StatusIB(Status::Failure, to_underlying(OperationalCertStatus::kFabricConflict));
}
if (CHIP_ERROR_INVALID_FABRIC_ID == err) {
if (CHIP_ERROR_INVALID_FABRIC_INDEX == err) {
return StatusIB(Status::Failure, to_underlying(OperationalCertStatus::kInvalidFabricIndex));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020 Project CHIP Authors
* Copyright (c) 2020-2022 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -52,7 +52,7 @@ CHIP_ERROR ModelCommand::RunCommand()
if (fabric == nullptr)
{
ChipLogError(AppServer, "Did not find fabric for index %d", fabricIndex);
return CHIP_ERROR_INVALID_FABRIC_ID;
return CHIP_ERROR_INVALID_FABRIC_INDEX;
}

PeerId peerID = fabric->GetPeerIdForNode(mNodeId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ CHIP_ERROR TargetVideoPlayerInfo::Initialize(NodeId nodeId, FabricIndex fabricIn
if (fabric == nullptr)
{
ChipLogError(AppServer, "Did not find fabric for index %d", fabricIndex);
return CHIP_ERROR_INVALID_FABRIC_ID;
return CHIP_ERROR_INVALID_FABRIC_INDEX;
}

PeerId peerID = fabric->GetPeerIdForNode(nodeId);
Expand Down
4 changes: 2 additions & 2 deletions src/app/AttributeAccessInterface.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2021 Project CHIP Authors
* Copyright (c) 2021-2022 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -111,7 +111,7 @@ class AttributeValueEncoder
template <typename T, std::enable_if_t<DataModel::IsFabricScoped<T>::value, bool> = true>
CHIP_ERROR Encode(T && aArg) const
{
VerifyOrReturnError(aArg.GetFabricIndex() != kUndefinedFabricIndex, CHIP_ERROR_INVALID_FABRIC_ID);
VerifyOrReturnError(aArg.GetFabricIndex() != kUndefinedFabricIndex, CHIP_ERROR_INVALID_FABRIC_INDEX);

// If we are encoding for a fabric filtered attribute read and the fabric index does not match that present in the
// request, skip encoding this list item.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
*
* Copyright (c) 2020 Project CHIP Authors
* Copyright (c) 2020-2022 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -202,7 +202,7 @@ class GroupKeyManagementAttributeAccess : public AttributeAccessInterface
while (iter.Next())
{
const auto & value = iter.GetValue();
VerifyOrReturnError(fabric_index == value.fabricIndex, CHIP_ERROR_INVALID_FABRIC_ID);
VerifyOrReturnError(fabric_index == value.fabricIndex, CHIP_ERROR_INVALID_FABRIC_INDEX);
// Cannot map to IPK, see `GroupKeyMapStruct` in Group Key Management cluster spec
VerifyOrReturnError(value.groupKeySetID != 0, CHIP_IM_GLOBAL_STATUS(ConstraintError));

Expand All @@ -217,7 +217,7 @@ class GroupKeyManagementAttributeAccess : public AttributeAccessInterface
size_t current_count = 0;
VerifyOrReturnError(nullptr != provider, CHIP_ERROR_INTERNAL);
ReturnErrorOnFailure(aDecoder.Decode(value));
VerifyOrReturnError(fabric_index == value.fabricIndex, CHIP_ERROR_INVALID_FABRIC_ID);
VerifyOrReturnError(fabric_index == value.fabricIndex, CHIP_ERROR_INVALID_FABRIC_INDEX);
// Cannot map to IPK, see `GroupKeyMapStruct` in Group Key Management cluster spec
VerifyOrReturnError(value.groupKeySetID != 0, CHIP_IM_GLOBAL_STATUS(ConstraintError));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ bool emberAfOperationalCredentialsClusterUpdateFabricLabelCallback(app::CommandH

// Fetch current fabric
FabricInfo * fabric = RetrieveCurrentFabric(commandObj);
VerifyOrExit(fabric != nullptr, err = CHIP_ERROR_INVALID_FABRIC_ID);
VerifyOrExit(fabric != nullptr, err = CHIP_ERROR_INVALID_FABRIC_INDEX);

// Set Label on fabric
err = fabric->SetFabricLabel(Label);
Expand Down Expand Up @@ -593,7 +593,7 @@ OperationalCertStatus ConvertToNOCResponseStatus(CHIP_ERROR err)
{
return OperationalCertStatus::kInvalidPublicKey;
}
if (err == CHIP_ERROR_INVALID_FABRIC_ID || err == CHIP_ERROR_WRONG_NODE_ID)
if (err == CHIP_ERROR_INVALID_FABRIC_INDEX || err == CHIP_ERROR_WRONG_NODE_ID)
{
return OperationalCertStatus::kInvalidNodeOpId;
}
Expand Down Expand Up @@ -777,7 +777,7 @@ bool emberAfOperationalCredentialsClusterUpdateNOCCallback(app::CommandHandler *

// Fetch current fabric
FabricInfo * fabric = RetrieveCurrentFabric(commandObj);
VerifyOrExit(fabric != nullptr, nocResponse = ConvertToNOCResponseStatus(CHIP_ERROR_INVALID_FABRIC_ID));
VerifyOrExit(fabric != nullptr, nocResponse = ConvertToNOCResponseStatus(CHIP_ERROR_INVALID_FABRIC_INDEX));

// Flag on the fail-safe context that the UpdateNOC command was invoked.
err = failSafeContext.SetUpdateNocCommandInvoked();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ chip::app::StatusIB ConvertToStatusIB(CHIP_ERROR err)
{
return StatusIB(Status::Failure, to_underlying(OperationalCertStatus::kFabricConflict));
}
if (CHIP_ERROR_INVALID_FABRIC_ID == err)
if (CHIP_ERROR_INVALID_FABRIC_INDEX == err)
{
return StatusIB(Status::Failure, to_underlying(OperationalCertStatus::kInvalidFabricIndex));
}
Expand Down
2 changes: 1 addition & 1 deletion src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,7 @@ CHIP_ERROR DeviceCommissioner::ConvertFromOperationalCertStatus(OperationalCrede
case OperationalCertStatus::kLabelConflict:
return CHIP_ERROR_INVALID_ARGUMENT;
case OperationalCertStatus::kInvalidFabricIndex:
return CHIP_ERROR_INVALID_FABRIC_ID;
return CHIP_ERROR_INVALID_FABRIC_INDEX;
}

return CHIP_ERROR_CERT_LOAD_FAILED;
Expand Down
28 changes: 14 additions & 14 deletions src/credentials/GroupDataProviderImpl.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2021 Project CHIP Authors
* Copyright (c) 2021-2022 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -182,7 +182,7 @@ struct FabricData : public PersistentData<kPersistentBufferMax>
uint16_t group_count = 0;
uint16_t first_map = 0;
uint16_t map_count = 0;
chip::KeysetId first_keyset = 0xffff;
chip::KeysetId first_keyset = kInvalidKeysetId;
uint16_t keyset_count = 0;
chip::FabricIndex next = kUndefinedFabricIndex;

Expand All @@ -191,7 +191,7 @@ struct FabricData : public PersistentData<kPersistentBufferMax>

CHIP_ERROR UpdateKey(DefaultStorageKeyAllocator & key) override
{
VerifyOrReturnError(kUndefinedFabricIndex != fabric_index, CHIP_ERROR_INVALID_FABRIC_ID);
VerifyOrReturnError(kUndefinedFabricIndex != fabric_index, CHIP_ERROR_INVALID_FABRIC_INDEX);
key.FabricGroups(fabric_index);
return CHIP_NO_ERROR;
}
Expand All @@ -200,7 +200,7 @@ struct FabricData : public PersistentData<kPersistentBufferMax>
{
first_group = kUndefinedGroupId;
group_count = 0;
first_keyset = 0xffff;
first_keyset = kInvalidKeysetId;
keyset_count = 0;
next = kUndefinedFabricIndex;
}
Expand Down Expand Up @@ -389,7 +389,7 @@ struct GroupData : public GroupDataProvider::GroupInfo, PersistentData<kPersiste

CHIP_ERROR UpdateKey(DefaultStorageKeyAllocator & key) override
{
VerifyOrReturnError(kUndefinedFabricIndex != fabric_index, CHIP_ERROR_INVALID_FABRIC_ID);
VerifyOrReturnError(kUndefinedFabricIndex != fabric_index, CHIP_ERROR_INVALID_FABRIC_INDEX);
key.FabricGroup(fabric_index, group_id);
return CHIP_NO_ERROR;
}
Expand Down Expand Up @@ -512,7 +512,7 @@ struct KeyMapData : public GroupDataProvider::GroupKey, LinkedData

CHIP_ERROR UpdateKey(DefaultStorageKeyAllocator & key) override
{
VerifyOrReturnError(kUndefinedFabricIndex != fabric_index, CHIP_ERROR_INVALID_FABRIC_ID);
VerifyOrReturnError(kUndefinedFabricIndex != fabric_index, CHIP_ERROR_INVALID_FABRIC_INDEX);
key.FabricGroupKey(fabric_index, id);
return CHIP_NO_ERROR;
}
Expand Down Expand Up @@ -632,7 +632,7 @@ struct EndpointData : GroupDataProvider::GroupEndpoint, PersistentData<kPersiste

CHIP_ERROR UpdateKey(DefaultStorageKeyAllocator & key) override
{
VerifyOrReturnError(kUndefinedFabricIndex != fabric_index, CHIP_ERROR_INVALID_FABRIC_ID);
VerifyOrReturnError(kUndefinedFabricIndex != fabric_index, CHIP_ERROR_INVALID_FABRIC_INDEX);
key.FabricGroupEndpoint(fabric_index, group_id, endpoint_id);
return CHIP_NO_ERROR;
}
Expand Down Expand Up @@ -718,8 +718,8 @@ struct KeySetData : PersistentData<kPersistentBufferMax>
static constexpr TLV::Tag TagNext() { return TLV::ContextTag(7); }

chip::FabricIndex fabric_index = kUndefinedFabricIndex;
chip::KeysetId next = 0xffff;
chip::KeysetId prev = 0xffff;
chip::KeysetId next = kInvalidKeysetId;
chip::KeysetId prev = kInvalidKeysetId;
bool first = true;

uint16_t keyset_id = 0;
Expand All @@ -735,8 +735,8 @@ struct KeySetData : PersistentData<kPersistentBufferMax>

CHIP_ERROR UpdateKey(DefaultStorageKeyAllocator & key) override
{
VerifyOrReturnError(kUndefinedFabricIndex != fabric_index, CHIP_ERROR_INVALID_FABRIC_ID);
VerifyOrReturnError(kUndefinedFabricIndex != fabric_index, CHIP_ERROR_INVALID_KEY_ID);
VerifyOrReturnError(kUndefinedFabricIndex != fabric_index, CHIP_ERROR_INVALID_FABRIC_INDEX);
VerifyOrReturnError(kInvalidKeysetId != keyset_id, CHIP_ERROR_INVALID_KEY_ID);
key.FabricKeyset(fabric_index, keyset_id);
return CHIP_NO_ERROR;
}
Expand All @@ -746,7 +746,7 @@ struct KeySetData : PersistentData<kPersistentBufferMax>
policy = GroupDataProvider::SecurityPolicy::kCacheAndSync;
keys_count = 0;
memset(operational_keys, 0x00, sizeof(operational_keys));
next = 0xffff;
next = kInvalidKeysetId;
}

OperationalKey * GetCurrentKey()
Expand Down Expand Up @@ -1397,7 +1397,7 @@ CHIP_ERROR GroupDataProviderImpl::RemoveEndpoints(chip::FabricIndex fabric_index
FabricData fabric(fabric_index);
GroupData group;

VerifyOrReturnError(CHIP_NO_ERROR == fabric.Load(mStorage), CHIP_ERROR_INVALID_FABRIC_ID);
VerifyOrReturnError(CHIP_NO_ERROR == fabric.Load(mStorage), CHIP_ERROR_INVALID_FABRIC_INDEX);
VerifyOrReturnError(group.Find(mStorage, fabric, group_id), CHIP_ERROR_KEY_NOT_FOUND);

EndpointData endpoint(fabric_index, group.group_id, group.first_endpoint);
Expand Down Expand Up @@ -1523,7 +1523,7 @@ CHIP_ERROR GroupDataProviderImpl::RemoveGroupKeys(chip::FabricIndex fabric_index
VerifyOrReturnError(IsInitialized(), CHIP_ERROR_INTERNAL);

FabricData fabric(fabric_index);
VerifyOrReturnError(CHIP_NO_ERROR == fabric.Load(mStorage), CHIP_ERROR_INVALID_FABRIC_ID);
VerifyOrReturnError(CHIP_NO_ERROR == fabric.Load(mStorage), CHIP_ERROR_INVALID_FABRIC_INDEX);

size_t count = 0;
KeyMapData map(fabric_index, fabric.first_map);
Expand Down
6 changes: 3 additions & 3 deletions src/credentials/tests/TestGroupDataProvider.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2021 Project CHIP Authors
* Copyright (c) 2021-2022 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -237,7 +237,7 @@ void TestGroupInfo(nlTestSuite * apSuite, void * apContext)

// Get Group Info

NL_TEST_ASSERT(apSuite, CHIP_ERROR_INVALID_FABRIC_ID == provider->GetGroupInfoAt(kUndefinedFabricIndex, 0, group));
NL_TEST_ASSERT(apSuite, CHIP_ERROR_INVALID_FABRIC_INDEX == provider->GetGroupInfoAt(kUndefinedFabricIndex, 0, group));
NL_TEST_ASSERT(apSuite, CHIP_ERROR_NOT_FOUND == provider->GetGroupInfoAt(kFabric2, 999, group));

NL_TEST_ASSERT(apSuite, sListener.latest == kGroupInfo2_3);
Expand Down Expand Up @@ -583,7 +583,7 @@ void TestGroupKeys(nlTestSuite * apSuite, void * apContext)

// Get Group Info

NL_TEST_ASSERT(apSuite, CHIP_ERROR_INVALID_FABRIC_ID == provider->GetGroupKeyAt(kUndefinedFabricIndex, 0, pair));
NL_TEST_ASSERT(apSuite, CHIP_ERROR_INVALID_FABRIC_INDEX == provider->GetGroupKeyAt(kUndefinedFabricIndex, 0, pair));
NL_TEST_ASSERT(apSuite, CHIP_ERROR_NOT_FOUND == provider->GetGroupKeyAt(kFabric2, 999, pair));

NL_TEST_ASSERT(apSuite, CHIP_NO_ERROR == provider->GetGroupKeyAt(kFabric1, 3, pair));
Expand Down
4 changes: 2 additions & 2 deletions src/lib/core/CHIPError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,8 @@ bool FormatCHIPError(char * buf, uint16_t bufSize, CHIP_ERROR err)
case CHIP_ERROR_UNSOLICITED_MSG_NO_ORIGINATOR.AsInteger():
desc = "Unsolicited msg with originator bit clear";
break;
case CHIP_ERROR_INVALID_FABRIC_ID.AsInteger():
desc = "Invalid Fabric Id";
case CHIP_ERROR_INVALID_FABRIC_INDEX.AsInteger():
desc = "Invalid Fabric Index";
break;
case CHIP_ERROR_TOO_MANY_CONNECTIONS.AsInteger():
desc = "Too many connections";
Expand Down
6 changes: 3 additions & 3 deletions src/lib/core/CHIPError.h
Original file line number Diff line number Diff line change
Expand Up @@ -1448,13 +1448,13 @@ using CHIP_ERROR = ::chip::ChipError;
#define CHIP_ERROR_UNSOLICITED_MSG_NO_ORIGINATOR CHIP_CORE_ERROR(0x70)

/**
* @def CHIP_ERROR_INVALID_FABRIC_ID
* @def CHIP_ERROR_INVALID_FABRIC_INDEX
*
* @brief
* A fabric id is invalid.
* A fabric index is invalid.
*
*/
#define CHIP_ERROR_INVALID_FABRIC_ID CHIP_CORE_ERROR(0x71)
#define CHIP_ERROR_INVALID_FABRIC_INDEX CHIP_CORE_ERROR(0x71)

/**
* @def CHIP_ERROR_TOO_MANY_CONNECTIONS
Expand Down
1 change: 1 addition & 0 deletions src/lib/core/DataModelTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ constexpr FabricIndex kUndefinedFabricIndex = 0;
constexpr EndpointId kInvalidEndpointId = 0xFFFF;
constexpr EndpointId kRootEndpointId = 0;
constexpr ListIndex kInvalidListIndex = 0xFFFF; // List index is a uint16 thus 0xFFFF is a invalid list index.
constexpr KeysetId kInvalidKeysetId = 0xFFFF;

// These are MEIs, 0xFFFF is not a valid manufacturer code,
// thus 0xFFFF'FFFF is not a valid MEI.
Expand Down
2 changes: 1 addition & 1 deletion src/lib/core/tests/TestCHIPErrorStr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ static const CHIP_ERROR kTestElements[] =
CHIP_ERROR_INVALID_PASE_CONFIGURATION,
CHIP_ERROR_NO_COMMON_PASE_CONFIGURATIONS,
CHIP_ERROR_UNSOLICITED_MSG_NO_ORIGINATOR,
CHIP_ERROR_INVALID_FABRIC_ID,
CHIP_ERROR_INVALID_FABRIC_INDEX,
CHIP_ERROR_TOO_MANY_CONNECTIONS,
CHIP_ERROR_SHUT_DOWN,
CHIP_ERROR_CANCELLED,
Expand Down

0 comments on commit 70e259c

Please sign in to comment.