Skip to content

Commit

Permalink
[attribute storage] use decltype (C++11) instead of typeof (C++23)
Browse files Browse the repository at this point in the history
  • Loading branch information
plan44 committed Oct 31, 2024
1 parent fd5b66c commit 87a8f51
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/app/util/attribute-storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ CHIP_ERROR emberAfSetupDynamicEndpointDeclaration(EmberAfEndpointType & endpoint
VerifyOrReturnError(endpointType.clusterCount == 0, CHIP_ERROR_INVALID_ARGUMENT);
// check cluster count fits target struct's clusterCount field
size_t clusterCount = templateClusterSpecs.size();
VerifyOrReturnError(CanCastTo<typeof(endpointType.clusterCount)>(clusterCount), CHIP_ERROR_NO_MEMORY);
VerifyOrReturnError(CanCastTo<decltype(endpointType.clusterCount)>(clusterCount), CHIP_ERROR_NO_MEMORY);
// allocate new cluster array
auto newClusters = new EmberAfCluster[clusterCount];
VerifyOrReturnError(newClusters != nullptr, CHIP_ERROR_NO_MEMORY);
Expand All @@ -315,16 +315,16 @@ CHIP_ERROR emberAfSetupDynamicEndpointDeclaration(EmberAfEndpointType & endpoint
newClusters[i] = *cluster;
// sum up the needed storage, result must
endpointSize += cluster->clusterSize;
if (!CanCastTo<typeof(endpointType.endpointSize)>(endpointSize))
if (!CanCastTo<decltype(endpointType.endpointSize)>(endpointSize))
{
delete[] newClusters;
return CHIP_ERROR_NO_MEMORY;
}
}
// set up dynamic endpoint
endpointType.clusterCount = static_cast<typeof(endpointType.clusterCount)>(clusterCount);
endpointType.clusterCount = static_cast<decltype(endpointType.clusterCount)>(clusterCount);
endpointType.cluster = newClusters;
endpointType.endpointSize = static_cast<typeof(endpointType.endpointSize)>(endpointSize);
endpointType.endpointSize = static_cast<decltype(endpointType.endpointSize)>(endpointSize);
return CHIP_NO_ERROR;
}

Expand Down

0 comments on commit 87a8f51

Please sign in to comment.