Skip to content

Commit

Permalink
Restyled by clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
restyled-commits authored and nivi-apple committed May 28, 2024
1 parent 4663c46 commit 100dcd3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 29 deletions.
13 changes: 4 additions & 9 deletions src/darwin/Framework/CHIP/MTRDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2751,8 +2751,7 @@ - (void)_removeClusters:(NSSet *)clusterPathsToRemove

[_persistedClusters minusSet:clusterPathsToRemove];

for (MTRClusterPath * path in clusterPathsToRemove)
{
for (MTRClusterPath * path in clusterPathsToRemove) {
[_persistedClusterData removeObjectForKey:path];
[_persistedClusters removeObject:path];
[_clusterDataToPersist removeObjectForKey:path];
Expand All @@ -2762,14 +2761,12 @@ - (void)_removeClusters:(NSSet *)clusterPathsToRemove

- (void)_removeAttributes:(NSSet *)toBeRemovedAttributes fromCluster:(MTRClusterPath *)clusterPathToRemoveAttributesFrom
{
if (toBeRemovedAttributes == nil || clusterPathToRemoveAttributesFrom == nil)
{
if (toBeRemovedAttributes == nil || clusterPathToRemoveAttributesFrom == nil) {
return;
}
os_unfair_lock_assert_owner(&self->_lock);

for (NSNumber * attribute in toBeRemovedAttributes)
{
for (NSNumber * attribute in toBeRemovedAttributes) {
[self _removeCachedAttribute:attribute fromCluster:clusterPathToRemoveAttributesFrom];
}
[_persistedClusterData removeObjectForKey:clusterPathToRemoveAttributesFrom];
Expand Down Expand Up @@ -2808,9 +2805,7 @@ - (void)_pruneOrphanedEndpointsAndClusters:(MTRAttributePath *)attributePath
[self _removeClusters:[clusterPathsToRemove copy]];
[self.deviceController.controllerDataStore removeEndpointFromEndpointIndex:endpoint forNodeID:self.nodeID];
}
}
else if (attributePath.attribute.unsignedLongValue == MTRAttributeIDTypeClusterDescriptorAttributeServerListID)
{
} else if (attributePath.attribute.unsignedLongValue == MTRAttributeIDTypeClusterDescriptorAttributeServerListID) {

// If the server list changed and clusters were removed, remove the clusters from the _persistedClusters, _persistedClusterData and _clusterDataToPersist for all those clusters.
// Also remove it from the data store.
Expand Down
10 changes: 3 additions & 7 deletions src/darwin/Framework/CHIP/MTRDeviceControllerDataStore.mm
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@ - (BOOL)_storeEndpointIndex:(NSArray<NSNumber *> *)endpointIndex forNodeID:(NSNu
return [self _storeAttributeCacheValue:endpointIndex forKey:[self _endpointIndexKeyForNodeID:nodeID]];
}


- (void)removeEndpointFromEndpointIndex:(NSNumber *)endpointID forNodeID:(NSNumber *)nodeID
{
if (!endpointID || !nodeID) {
Expand All @@ -461,8 +460,7 @@ - (void)removeEndpointFromEndpointIndex:(NSNumber *)endpointID forNodeID:(NSNumb

[endpointIndex removeObject:endpointID];
BOOL success = [self _storeEndpointIndex:endpointIndex forNodeID:nodeID];
if (!success)
{
if (!success) {
MTR_LOG_ERROR("removeEndpointFromEndpointIndex: _storeEndpointIndex for node 0x%016llX", nodeID.unsignedLongLongValue);
}
});
Expand Down Expand Up @@ -745,12 +743,10 @@ - (void)clearStoredClusterDataForNodeID:(NSNumber *)nodeID endpointID:(NSNumber
- (void)removeAttributes:(NSSet<NSNumber *> *)attributes fromCluster:(MTRClusterPath *)path forNodeID:(NSNumber *)nodeID
{
MTRDeviceClusterData * clusterData = [self getStoredClusterDataForNodeID:nodeID endpointID:path.endpoint clusterID:path.cluster];
if (clusterData == nil)
{
if (clusterData == nil) {
return;
}
for (NSNumber * attribute in attributes)
{
for (NSNumber * attribute in attributes) {
[clusterData removeValueForAttribute:attribute];
}
[self _storeClusterData:clusterData forNodeID:nodeID endpointID:path.endpoint clusterID:path.cluster];
Expand Down
18 changes: 5 additions & 13 deletions src/darwin/Framework/CHIPTests/MTRPerControllerStorageTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -2222,7 +2222,6 @@ - (MTRDevice *)getMTRDevice:(NSNumber *)deviceID

[endpoints addObjectsFromArray:[device arrayOfNumbersFromAttributeValue:[device _dataValueWithoutDataVersion:partsList]]];
return endpoints;

}

- (void)test011_testDataStorageUpdatesWhenRemovingEndpoints
Expand Down Expand Up @@ -2265,7 +2264,7 @@ - (void)test011_testDataStorageUpdatesWhenRemovingEndpoints
}
};

__block NSMutableDictionary<NSNumber * , NSArray<NSNumber *> *> * initialClusterIndex = [[NSMutableDictionary alloc] init];
__block NSMutableDictionary<NSNumber *, NSArray<NSNumber *> *> * initialClusterIndex = [[NSMutableDictionary alloc] init];
__block NSMutableArray * testEndpoints;

delegate.onReportEnd = ^{
Expand All @@ -2279,8 +2278,7 @@ - (void)test011_testDataStorageUpdatesWhenRemovingEndpoints
dispatch_sync(self->_storageQueue, ^{
XCTAssertTrue([[controller.controllerDataStore _fetchEndpointIndexForNodeID:deviceID] isEqualToArray:testEndpoints]);
// Populate the initialClusterIndex to use as a reference for all cluster paths later.
for (NSNumber * endpoint in testEndpoints)
{
for (NSNumber * endpoint in testEndpoints) {
[initialClusterIndex setObject:[controller.controllerDataStore _fetchClusterIndexForNodeID:deviceID endpointID:endpoint] forKey:endpoint];
}
XCTAssertNotNil(initialClusterIndex);
Expand Down Expand Up @@ -2485,12 +2483,9 @@ - (void)test012_testDataStorageUpdatesWhenRemovingClusters
dispatch_sync(self->_storageQueue, ^{
XCTAssertFalse([[controller.controllerDataStore _fetchClusterIndexForNodeID:deviceID endpointID:testEndpoint] containsObject:toBeDeletedCluster]);
for (NSNumber * cluster in initialClusterIndex) {
if ([cluster isEqualToNumber:toBeDeletedCluster])
{
if ([cluster isEqualToNumber:toBeDeletedCluster]) {
XCTAssertNil([controller.controllerDataStore _fetchClusterDataForNodeID:deviceID endpointID:testEndpoint clusterID:cluster]);
}
else
{
} else {
XCTAssertNotNil([controller.controllerDataStore _fetchClusterDataForNodeID:deviceID endpointID:testEndpoint clusterID:cluster]);
}
}
Expand Down Expand Up @@ -2562,7 +2557,6 @@ - (void)test013_testDataStorageUpdatesWhenRemovingAttributes
XCTAssertNotNil(testClusterDataValue);

dispatch_sync(self->_storageQueue, ^{

initialClusterIndex = [[controller.controllerDataStore _fetchClusterIndexForNodeID:deviceID endpointID:testEndpoint] mutableCopy];
XCTAssertNotNil(initialClusterIndex);

Expand All @@ -2573,7 +2567,7 @@ - (void)test013_testDataStorageUpdatesWhenRemovingAttributes
// We will be paged in the cluster data from storage to check the above.
MTRClusterPath * path = [MTRClusterPath clusterPathWithEndpointID:testEndpoint clusterID:cluster];

if ([cluster isEqualToNumber:@(MTRClusterIDTypeIdentifyID)]) {
if ([cluster isEqualToNumber:@(MTRClusterIDTypeIdentifyID)]) {
MTRDeviceClusterData * data = [device _getClusterDataForPath:path];
XCTAssertNotNil(data);
XCTAssertNotNil(data.attributes);
Expand All @@ -2589,7 +2583,6 @@ - (void)test013_testDataStorageUpdatesWhenRemovingAttributes
}
}
}

});

[subscriptionExpectation fulfill];
Expand Down Expand Up @@ -2621,7 +2614,6 @@ - (void)test013_testDataStorageUpdatesWhenRemovingAttributes
};

delegate.onReportEnd = ^{

// Make sure that the cluster data in the data storage is populated with cluster data for MTRClusterIDTypeIdentifyID cluster
// and has all attributes except attribute 1 which was deleted.
// We will be paged in the cluster data from storage to check the above.
Expand Down

0 comments on commit 100dcd3

Please sign in to comment.